pdns-3.3/0000755000014601777760000000000012165464054013572 5ustar00jenkinsnogroup00000000000000pdns-3.3/depcomp0000755000014601777760000004426712165464024015161 0ustar00jenkinsnogroup00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pdns-3.3/COPYING0000644000014601777760000004325312136555572014640 0ustar00jenkinsnogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General Public License instead of this License.pdns-3.3/bootstrap0000755000014601777760000000005712136555572015543 0ustar00jenkinsnogroup00000000000000#!/bin/sh autoreconf -i automake --add-missing pdns-3.3/AUTHORS0000644000014601777760000000005312136555572014644 0ustar00jenkinsnogroup00000000000000PowerDNS.COM BV and a cast of thousands ;-)pdns-3.3/pdns.spec0000644000014601777760000000316312165464014015411 0ustar00jenkinsnogroup00000000000000BuildRoot: /tmp/pdns Name: pdns-static Version: 3.3 Release: 1 Summary: extremely powerful and versatile nameserver License: GPL Distribution: Neutral Vendor: PowerDNS.COM BV Group: System/DNS AutoReqProv: no Requires: glibc >= 2.4 %define _rpmdir ../ %define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm %description PowerDNS is a versatile nameserver which supports a large number of different backends ranging from simple zonefiles to relational databases and load balancing/failover algorithms. This RPM is statically compiled and should work on all Linux distributions. It comes with support for MySQL, PostgreSQL, Bind zonefiles and the 'pipe backend'. %files %defattr(-,root,root) "/usr/sbin/pdns_server" "/usr/bin/pdns_control" "/usr/bin/zone2sql" "/usr/bin/zone2json" "/usr/bin/pdnssec" #"/usr/bin/zone2ldap" "/usr/man/man8/pdns_control.8" "/usr/man/man8/pdns_server.8" "/usr/man/man8/zone2sql.8" "/usr/man/man8/pdnssec.8" %dir "/etc/powerdns/" %config(noreplace) "/etc/powerdns/pdns.conf" %config "/etc/init.d/pdns" %post echo Remember to create a 'pdns' user before starting pdns %package -n pdns-tools Summary: extremely powerful and versatile nameserver License: GPL Distribution: Neutral Vendor: PowerDNS.COM BV Group: System/DNS AutoReqProv: no %description -n pdns-tools These are the tools %files -n pdns-tools %defattr(-,root,root) "/usr/bin/dnsbulktest" "/usr/bin/dnsreplay" "/usr/bin/dnsscan" "/usr/bin/dnsscope" "/usr/bin/dnstcpbench" "/usr/bin/dnswasher" "/usr/bin/nproxy" "/usr/bin/nsec3dig" "/usr/man/man8/dnsreplay.8" "/usr/man/man8/dnsscope.8" "/usr/man/man8/dnswasher.8" "/usr/man/man1/dnstcpbench.1" pdns-3.3/config.h0000644000014601777760000001341412165464050015207 0ustar00jenkinsnogroup00000000000000/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ /* Skip gcc locking */ /* #undef GCC_SKIP_LOCKING */ /* Defined if the requested minimum BOOST version is satisfied */ #define HAVE_BOOST 1 /* Define to 1 if you have */ #define HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP 1 /* Define to 1 if you have */ #define HAVE_BOOST_FOREACH_HPP 1 /* Define to 1 if you have */ #define HAVE_BOOST_PROGRAM_OPTIONS_HPP 1 /* Define to 1 if you have */ #define HAVE_BOOST_TEST_UNIT_TEST_HPP 1 /* If we have botan 1.10 */ /* #undef HAVE_BOTAN110 */ /* If we have botan 1.8 */ /* #undef HAVE_BOTAN18 */ /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the `gethostname' function. */ #define HAVE_GETHOSTNAME 1 /* Define to 1 if you have the header file. */ #define HAVE_GETOPT_H 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* If the host operating system understands IPv6 */ #define HAVE_IPV6 1 /* Define to 1 if you have the header file. */ #define HAVE_LBER_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LDAP_H 1 /* Define to 1 if you have ldap_initialize */ #define HAVE_LDAP_INITIALIZE 1 /* Define to 1 if you have ldap_sasl_bind */ #define HAVE_LDAP_SASL_BIND 1 /* Define to 1 if you have the `crypt' library (-lcrypt). */ #define HAVE_LIBCRYPT 1 /* If we have libcurl */ #define HAVE_LIBCURL 1 /* Define to 1 if you have the `dl' library (-ldl). */ #define HAVE_LIBDL 1 /* Have -lldap */ /* #undef HAVE_LIBLDAP */ /* Have -lldap_r */ #define HAVE_LIBLDAP_R 1 /* Have -lopendbx */ #define HAVE_LIBOPENDBX 1 /* Define to 1 if you have the `polarssl' library (-lpolarssl). */ /* #undef HAVE_LIBPOLARSSL */ /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 /* liblua */ #define HAVE_LUA 1 /* lua.h */ #define HAVE_LUA_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `mkdir' function. */ #define HAVE_MKDIR 1 /* Define to 1 if you have the `mktime' function. */ #define HAVE_MKTIME 1 /* Define to 1 if you have the header file. */ #define HAVE_ODBX_H 1 /* Define to 1 if you have the `select' function. */ #define HAVE_SELECT 1 /* Define to 1 if you have the `socket' function. */ #define HAVE_SOCKET 1 /* If we have sqlite3 */ #define HAVE_SQLITE3 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `strcasestr' function. */ #define HAVE_STRCASESTR 1 /* Define to 1 if you have the `strerror' function. */ #define HAVE_STRERROR 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYSLOG_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* If your OS is so broken that it needs an additional prototype */ /* #undef NEED_INET_NTOP_PROTO */ /* If POSIX typedefs need to be defined */ /* #undef NEED_POSIX_TYPEDEF */ /* If host OS misses RTLD_NOW */ /* #undef NEED_RTLD_NOW */ /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* #undef NO_MINUS_C_MINUS_O */ /* Name of package */ #define PACKAGE "pdns" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "pdns" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "pdns 3.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pdns" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "3.3" /* If we want HTTP connector */ #define REMOTEBACKEND_HTTP 1 /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Define to 1 if your declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ /* If verbose logging should be enabled */ /* #undef VERBOSELOG */ /* Version number of package */ #define VERSION "3.3" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN /* # undef WORDS_BIGENDIAN */ # endif #endif /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #define YYTEXT_POINTER 1 /* Define to `unsigned int' if does not define. */ /* #undef size_t */ pdns-3.3/HACKING0000644000014601777760000000051212140525670014552 0ustar00jenkinsnogroup00000000000000PowerDNS has moved to GitHub, the repository is at https://github.com/PowerDNS/pdns Then: $ ./bootstrap you may need to do that twice. You also need libtool-1.4, 1.3 won't work. Automake 1.6 is (almost) required. Send any patches you may have to the mailinglist: pdns-dev@mailman.powerdns.com Thanks! pdns-3.3/modules/0000755000014601777760000000000012165464053015241 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/pipebackend/0000755000014601777760000000000012165464054017507 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/pipebackend/coprocess.cc0000644000014601777760000001311212136555572022020 0ustar00jenkinsnogroup00000000000000#include "coprocess.hh" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include CoProcess::CoProcess(const string &command,int timeout, int infd, int outfd) { vector v; split(v, command, is_any_of(" ")); const char *argv[v.size()+1]; argv[v.size()]=0; for (size_t n = 0; n < v.size(); n++) argv[n]=v[n].c_str(); // we get away with not copying since nobody resizes v launch(argv, timeout, infd, outfd); } void CoProcess::launch(const char **argv, int timeout, int infd, int outfd) { d_timeout=timeout; d_infd=infd; d_outfd=outfd; signal(SIGPIPE, SIG_IGN); if(access(argv[0],X_OK)) // check before fork so we can throw throw AhuException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror()); if(pipe(d_fd1)<0 || pipe(d_fd2)<0) throw AhuException("Unable to open pipe for coprocess: "+string(strerror(errno))); if((d_pid=fork())<0) throw AhuException("Unable to fork for coprocess: "+stringerror()); else if(d_pid>0) { // parent speaking close(d_fd1[0]); Utility::setCloseOnExec(d_fd1[1]); close(d_fd2[1]); Utility::setCloseOnExec(d_fd2[0]); if(!(d_fp=fdopen(d_fd2[0],"r"))) throw AhuException("Unable to associate a file pointer with pipe: "+stringerror()); setbuf(d_fp,0); // no buffering please, confuses select } else if(!d_pid) { // child signal(SIGCHLD, SIG_DFL); // silence a warning from perl close(d_fd1[1]); close(d_fd2[0]); if(d_fd1[0]!= infd) { dup2(d_fd1[0], infd); close(d_fd1[0]); } if(d_fd2[1]!= outfd) { dup2(d_fd2[1], outfd); close(d_fd2[1]); } // stdin & stdout are now connected, fire up our coprocess! if(execv(argv[0], const_cast(argv))<0) // now what exit(123); /* not a lot we can do here. We shouldn't return because that will leave a forked process around. no way to log this either - only thing we can do is make sure that our parent catches this soonest! */ } } CoProcess::~CoProcess() { int status; if(!waitpid(d_pid, &status, WNOHANG)) { kill(d_pid, 9); waitpid(d_pid, &status, 0); } close(d_fd1[1]); fclose(d_fp); } void CoProcess::checkStatus() { int status; int ret=waitpid(d_pid, &status, WNOHANG); if(ret<0) throw AhuException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno))); else if(ret) { if(WIFEXITED(status)) { int ret=WEXITSTATUS(status); throw AhuException("Coprocess exited with code "+itoa(ret)); } if(WIFSIGNALED(status)) { int sig=WTERMSIG(status); string reason="CoProcess died on receiving signal "+itoa(sig); #ifdef WCOREDUMP if(WCOREDUMP(status)) reason+=". Dumped core"; #endif throw AhuException(reason); } } } void CoProcess::send(const string &snd) { checkStatus(); string line(snd); line.append(1,'\n'); unsigned int sent=0; int bytes; // writen routine - socket may not accept al data in one go while(sent; chomp($line); unless($line eq "HELO\t1") { print "FAIL\n"; print STDERR "Received '$line'\n"; <>; exit; } print "OK Sample backend firing up\n"; # print our banner while(<>) { print STDERR "$$ Received: $_"; chomp(); my @arr=split(/\t/); if(@arr<6) { print "LOG PowerDNS sent unparseable line\n"; print "FAIL\n"; next; } my ($type,$qname,$qclass,$qtype,$id,$ip)=split(/\t/); if(($qtype eq "SOA" || $qtype eq "ANY") && $qname eq "example.com") { print STDERR "$$ Sent SOA records\n"; print "DATA $qname $qclass SOA 3600 -1 ahu.example.com ns1.example.com 2008080300 1800 3600 604800 3600\n"; } if(($qtype eq "NS" || $qtype eq "ANY") && $qname eq "example.com") { print STDERR "$$ Sent NS records\n"; print "DATA $qname $qclass NS 3600 -1 ns1.example.com\n"; print "DATA $qname $qclass NS 3600 -1 ns2.example.com\n"; } if(($qtype eq "TXT" || $qtype eq "ANY") && $qname eq "example.com") { print STDERR "$$ Sent NS records\n"; print "DATA $qname $qclass TXT 3600 -1 \"hallo allemaal!\"\n"; } if(($qtype eq "A" || $qtype eq "ANY") && $qname eq "webserver.example.com") { print STDERR "$$ Sent A records\n"; print "DATA $qname $qclass A 3600 -1 1.2.3.4\n"; print "DATA $qname $qclass A 3600 -1 1.2.3.5\n"; print "DATA $qname $qclass A 3600 -1 1.2.3.6\n"; } elsif(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq "www.example.com") { print STDERR "$$ Sent CNAME records\n"; print "DATA $qname $qclass CNAME 3600 -1 webserver.example.com\n"; } elsif($qtype eq "MBOXFW") { print STDERR "$$ Sent MBOXFW records\n"; print "DATA $qname $qclass MBOXFW 3600 -1 powerdns\@example.com\n"; } print STDERR "$$ End of data\n"; print "END\n"; } pdns-3.3/modules/pipebackend/OBJECTLIBS0000644000014601777760000000000012136555572021044 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/pipebackend/pipebackend.cc0000644000014601777760000001766012136555572022301 0ustar00jenkinsnogroup00000000000000// -*- sateh-c -*- // File : pdnsbackend.cc // Version : $Id$ // #include #include #include #include #include #include "coprocess.hh" #include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include #include #include #include #include "pipebackend.hh" static const char *kBackendId = "[PIPEBackend]"; CoWrapper::CoWrapper(const string &command, int timeout) { d_cp=0; d_command=command; d_timeout=timeout; launch(); // let exceptions fall through - if initial launch fails, we want to die // I think } CoWrapper::~CoWrapper() { if(d_cp) delete d_cp; } void CoWrapper::launch() { if(d_cp) return; if(isUnixSocket(d_command)) d_cp = new UnixRemote(d_command, d_timeout); else d_cp = new CoProcess(d_command, d_timeout); d_cp->send("HELO\t"+lexical_cast(::arg().asNum("pipebackend-abi-version"))); string banner; d_cp->receive(banner); L<send(line); return; } catch(AhuException &ae) { delete d_cp; d_cp=0; throw; } } void CoWrapper::receive(string &line) { launch(); try { d_cp->receive(line); return; } catch(AhuException &ae) { L<(new CoWrapper(getArg("command"), getArgAsNum("timeout"))); d_regex=getArg("regex").empty() ? 0 : new Regex(getArg("regex")); d_regexstr=getArg("regex"); } catch(const ArgException &A) { L<match(qname+";"+qtype.getName())) { if(::arg().mustDo("query-logging")) L<getLocal(); realRemote = pkt_p->getRealRemote(); remoteIP = pkt_p->getRemote(); } int abiVersion = ::arg().asNum("pipebackend-abi-version"); // pipebackend-abi-version = 1 // type qname qclass qtype id remote-ip-address query<<"Q\t"<= 2) query<<"\t"<= 3) query <<"\t"<send(query.str()); } } catch(AhuException &ae) { L<send(query.str()); } catch(AhuException &ae) { L<receive(line); vectorparts; stringtok(parts,line,"\t"); if(parts.empty()) { L< #include #include #include "pdns/namespaces.hh" class CoRemote { public: virtual ~CoRemote() {} virtual void sendReceive(const string &send, string &receive) = 0; virtual void receive(string &rcv) = 0; virtual void send(const string &send) = 0; }; class CoProcess : public CoRemote { public: CoProcess(const string &command,int timeout=0, int infd=0, int outfd=1); ~CoProcess(); void sendReceive(const string &send, string &receive); void receive(string &rcv); void send(const string &send); private: void launch(const char **argv, int timeout=0, int infd=0, int outfd=1); void checkStatus(); int d_fd1[2], d_fd2[2]; int d_pid; int d_infd; int d_outfd; int d_timeout; FILE *d_fp; }; class UnixRemote : public CoRemote { public: UnixRemote(const string &path, int timeout=0); ~UnixRemote(); void sendReceive(const string &send, string &receive); void receive(string &rcv); void send(const string &send); private: int d_fd; FILE *d_fp; }; bool isUnixSocket(const string& fname); #endif pdns-3.3/modules/pipebackend/OBJECTFILES0000644000014601777760000000003212136555572021162 0ustar00jenkinsnogroup00000000000000coprocess.o pipebackend.o pdns-3.3/modules/pipebackend/Makefile.in0000644000014601777760000004773712165464027021576 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/pipebackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libpipebackend_la_LIBADD = am_libpipebackend_la_OBJECTS = pipebackend.lo coprocess.lo libpipebackend_la_OBJECTS = $(am_libpipebackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libpipebackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libpipebackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libpipebackend_la_SOURCES) DIST_SOURCES = $(libpipebackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ $(BOOST_CPPFLAGS) #if !ALLSTATIC #install-exec-local: # install .lib/libpipebackend.so.0.0.0 @libdir@ #endif EXTRA_DIST = OBJECTFILES OBJECTLIBS backend.pl lib_LTLIBRARIES = libpipebackend.la libpipebackend_la_SOURCES = pipebackend.cc pipebackend.hh coprocess.cc coprocess.hh libpipebackend_la_LDFLAGS = -module -avoid-version all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/pipebackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/pipebackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libpipebackend.la: $(libpipebackend_la_OBJECTS) $(libpipebackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libpipebackend_la_LINK) -rpath $(libdir) $(libpipebackend_la_OBJECTS) $(libpipebackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coprocess.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipebackend.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/pipebackend/pipebackend.hh0000644000014601777760000000206112136555572022300 0ustar00jenkinsnogroup00000000000000// // File : pdnsbackend.hh // Version : $Id$ // #ifndef PIPEBACKEND_HH #define PIPEBACKEND_HH #include #include #include #include #include "pdns/namespaces.hh" #include "pdns/misc.hh" /** The CoWrapper class wraps around a coprocess and restarts it if needed. It may also send out pings and expect banners */ class CoWrapper { public: CoWrapper(const string &command, int timeout=0); ~CoWrapper(); void send(const string &line); void receive(string &line); private: CoRemote* d_cp; string d_command; void launch(); int d_timeout; }; class PipeBackend : public DNSBackend { public: PipeBackend(const string &suffix=""); ~PipeBackend(); void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1); bool list(const string &target, int domain_id); bool get(DNSResourceRecord &r); static DNSBackend *maker(); private: shared_ptr d_coproc; string d_qname; QType d_qtype; Regex* d_regex; string d_regexstr; bool d_disavow; }; #endif pdns-3.3/modules/pipebackend/Makefile.am0000644000014601777760000000053612136555572021553 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ $(BOOST_CPPFLAGS) #if !ALLSTATIC #install-exec-local: # install .lib/libpipebackend.so.0.0.0 @libdir@ #endif EXTRA_DIST=OBJECTFILES OBJECTLIBS backend.pl lib_LTLIBRARIES = libpipebackend.la libpipebackend_la_SOURCES=pipebackend.cc pipebackend.hh coprocess.cc coprocess.hh libpipebackend_la_LDFLAGS=-module -avoid-version pdns-3.3/modules/goraclebackend/0000755000014601777760000000000012165464054020166 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/goraclebackend/soracle.cc0000644000014601777760000001471512136555572022141 0ustar00jenkinsnogroup00000000000000/* Copyright 2005 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE for more information. */ #include "soracle.hh" #include #include #include "pdns/misc.hh" #include "pdns/logger.hh" #include "pdns/dns.hh" #include #include "pdns/namespaces.hh" bool SOracle::s_dolog; string SOracle::getOracleError() { string mReason = "ORA-UNKNOWN"; if (d_errorHandle != NULL) { text msg[512]; sb4 errcode = 0; memset( msg, 0, 512); OCIErrorGet((dvoid *) d_errorHandle,1, NULL, &errcode, msg, sizeof(msg), OCI_HTYPE_ERROR); if (errcode) { char *p = (char*) msg; while (*p++ != 0x00) { if (*p == '\n' || *p == '\r') { *p = ';'; } } mReason = (char*) msg; } } return mReason; } SOracle::SOracle(const string &database, const string &user, const string &password) { d_environmentHandle = NULL; d_errorHandle = NULL; d_serviceContextHandle = NULL; int err = OCIInitialize(OCI_THREADED, 0, NULL, NULL, NULL); if (err) { throw sPerrorException("OCIInitialize"); } err = OCIEnvInit(&d_environmentHandle, OCI_DEFAULT, 0, 0); if (err) { throw sPerrorException("OCIEnvInit"); } // Allocate an error handle err = OCIHandleAlloc(d_environmentHandle, (dvoid**) &d_errorHandle, OCI_HTYPE_ERROR, 0, NULL); if (err) { throw sPerrorException("OCIHandleAlloc"); } // Logon to the database const char *username = user.c_str(); err = OCILogon(d_environmentHandle, d_errorHandle, &d_serviceContextHandle, (OraText*) username, strlen(username), (OraText*) password.c_str(), strlen(password.c_str()), (OraText*) database.c_str(), strlen(database.c_str())); if (err) throw sPerrorException("Loging in to Oracle gave error: " + getOracleError()); } void SOracle::setLog(bool state) { s_dolog=state; } SOracle::~SOracle() { if(d_handle) { OCIHandleFree(d_handle, OCI_HTYPE_STMT); d_handle=0; } int err; if (d_serviceContextHandle != NULL) { err=OCILogoff(d_serviceContextHandle, d_errorHandle); if(err) { cerr<<"Problems logging out: "+getOracleError()< #ifndef dsword typedef sb4 dsword; #endif class SOracle : public SSql { public: SOracle(const string &database, const string &user="", const string &password=""); ~SOracle(); SSqlException sPerrorException(const string &reason); int doQuery(const string &query, result_t &result); int doQuery(const string &query); int doCommand(const string &query); bool getRow(row_t &row); string escape(const string &str); void setLog(bool state); private: OCIEnv *d_environmentHandle; OCIError *d_errorHandle; OCISvcCtx *d_serviceContextHandle; OCIStmt *d_statementHandles[10]; struct oresult { char content[4000]; sb2 indicator; } d_fields[10]; OCIStmt* d_handle; dsword d_queryResult; string getOracleError(); static bool s_dolog; int d_numfields; // int getNumFields(const string& query); }; #endif /* SSORACLE_HH */ pdns-3.3/modules/goraclebackend/OBJECTLIBS0000644000014601777760000000000012136555572021523 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/goraclebackend/goraclebackend.cc0000644000014601777760000002462312145157064023426 0ustar00jenkinsnogroup00000000000000 #include #include #include "pdns/namespaces.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "goraclebackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "soracle.hh" #include gOracleBackend::gOracleBackend(const string &mode, const string &suffix) : GSQLBackend(mode,suffix) { try { // set some envionment variables setenv("ORACLE_HOME", getArg("home").c_str(), 1); setenv("ORACLE_SID", getArg("sid").c_str(), 1); setenv("NLS_LANG", getArg("nls-lang").c_str(), 1); setDB(new SOracle(getArg("tnsname"), getArg("user"), getArg("password"))); } catch(SSqlException &e) { L< '%s' and domain_id=%d and ordername is not null"); declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null and rownum=1 order by 1 desc"); declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'"); declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'"); declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'"); declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'"); declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d"); declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d"); declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d"); declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); declare(suffix,"delete-zone-query","", "delete from records where domain_id=%d"); declare(suffix,"delete-rrset-query","","delete from records where domain_id=%d and name='%s' and type='%s'"); declare(suffix,"add-domain-key-query","", "insert into cryptokeys (id, domain_id, flags, active, content) select cryptokeys_id_sequence.nextval, id, %d, %d, '%s' from domains where name='%s'"); declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='%s'"); declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='%s' and domainmetadata.kind='%s'"); declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'"); declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (id, domain_id, kind, content) select domainmetadata_sequence_id.nextval, id, '%s', '%s' from domains where name='%s'"); declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=1 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=0 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"get-tsig-key-query","", "select algorithm, secret from tsigkeys where name='%s'"); declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'"); } DNSBackend *make(const string &suffix="") { return new gOracleBackend(d_mode,suffix); } private: const string d_mode; }; //! Magic class that is activated when the dynamic library is loaded class gOracleLoader { public: //! This reports us to the main UeberBackend class gOracleLoader() { BackendMakers().report(new gOracleFactory("goracle")); L< #include #include "pdns/backends/gsql/gsqlbackend.hh" #include "pdns/namespaces.hh" /** The gOracleBackend is a DNSBackend that can answer DNS related questions. It looks up data in PostgreSQL */ class gOracleBackend : public GSQLBackend { public: gOracleBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails. private: }; pdns-3.3/modules/goraclebackend/Makefile.am0000644000014601777760000000075612140444471022224 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=$(ORACLE_CFLAGS) @THREADFLAGS@ lib_LTLIBRARIES = libgoraclebackend.la #bin_PROGRAMS = soracle #soracle_SOURCES=soracle.cc soracle.hh EXTRA_DIST=OBJECTFILES OBJECTLIBS libgoraclebackend_la_SOURCES=goraclebackend.cc goraclebackend.hh \ soracle.hh soracle.cc libgoraclebackend_la_LDFLAGS=-module -avoid-version $(ORACLE_LIBS) #soracle_LDFLAGS=-module -L$(ORACLE_HOME)/lib -lclient9 -lclntst9 -ldl -pthread # -Wl,-Bstatic -lpq++ -lpq -Wl,-Bdynamic -lssl -lcrypt -lcrypto pdns-3.3/modules/luabackend/0000755000014601777760000000000012165464054017333 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/luabackend/lua_functions.hh0000644000014601777760000000027612136555572022536 0ustar00jenkinsnogroup00000000000000#ifndef LUABACKEND_EXTERN_F_HH #define LUABACKEND_EXTERN_F_HH //extern LUABackend* lb; extern int my_lua_panic(lua_State* lua); extern void register_lua_functions(lua_State* lua); #endif pdns-3.3/modules/luabackend/OBJECTLIBS0000644000014601777760000000001012136555572020671 0ustar00jenkinsnogroup00000000000000-llua5.1pdns-3.3/modules/luabackend/luabackend.hh0000644000014601777760000001434012136555572021753 0ustar00jenkinsnogroup00000000000000#ifndef LUABACKEND_HH #define LUABACKEND_HH #include "lua.hpp" //extern "C" { //#include "lua.h" //#include "lualib.h" //#include "lauxlib.h" //} #include "pdns/dnsbackend.hh" #undef VERSION #include using std::string; //#undef L class LUAException { public: LUAException(const string &ex) : what(ex){} string what; }; class LUABackend : public DNSBackend { public: // MINIMAL BACKEND LUABackend(const string &suffix=""); ~LUABackend(); bool list(const string &target, int domain_id); void lookup(const QType &qtype, const string &qname, DNSPacket *p, int domain_id); bool get(DNSResourceRecord &rr); //! fills the soadata struct with the SOA details. Returns false if there is no SOA. bool getSOA(const string &name, SOAData &soadata, DNSPacket *p=0); // MASTER BACKEND void getUpdatedMasters(vector* domains); void setNotifed(int id, u_int32_t serial); // SLAVE BACKEND bool getDomainInfo(const string &domain, DomainInfo &di); bool isMaster(const string &name, const string &ip); void getUnfreshSlaveInfos(vector* domains); void setFresh(int id); bool startTransaction(const string &qname, int id); bool commitTransaction(); bool abortTransaction(); bool feedRecord(const DNSResourceRecord &rr); // SUPERMASTER BACKEND bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db); bool createSlaveDomain(const string &ip, const string &domain, const string &account); // DNSSEC BACKEND //! get a list of IP addresses that should also be notified for a domain void alsoNotifies(const string &domain, set *ips); bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); bool setDomainMetadata(const string& name, const std::string& kind, std::vector& meta); bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys); bool removeDomainKey(const string& name, unsigned int id); bool activateDomainKey(const string& name, unsigned int id); bool deactivateDomainKey(const string& name, unsigned int id); bool getTSIGKey(const string& name, string* algorithm, string* content); int addDomainKey(const string& name, const KeyData& key); bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth); bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth); // OTHER void reload(); void rediscover(string* status=0); string backend_name; lua_State *lua; DNSPacket *dnspacket; //private.cc string my_getArg(string a); bool my_mustDo(string a); private: pthread_t backend_pid; unsigned int backend_count; int f_lua_exec_error; //minimal functions.... int f_lua_list; int f_lua_lookup; int f_lua_get; int f_lua_getsoa; //master functions.... int f_lua_getupdatedmasters; int f_lua_setnotifed; //slave functions.... int f_lua_getdomaininfo; int f_lua_ismaster; int f_lua_getunfreshslaveinfos; int f_lua_setfresh; int f_lua_starttransaction; int f_lua_committransaction; int f_lua_aborttransaction; int f_lua_feedrecord; //supermaster functions.... int f_lua_supermasterbackend; int f_lua_createslavedomain; //rediscover int f_lua_rediscover; //dnssec int f_lua_alsonotifies; int f_lua_getdomainmetadata; int f_lua_setdomainmetadata; int f_lua_getdomainkeys; int f_lua_removedomainkey; int f_lua_activatedomainkey; int f_lua_deactivatedomainkey; int f_lua_updatedomainkey; int f_lua_gettsigkey; int f_lua_adddomainkey; int f_lua_getbeforeandafternamesabsolute; int f_lua_updatednssecorderandauthabsolute; int f_lua_updatednssecorderandauth; // int my_lua_panic (lua_State *lua); // FUNCTIONS TO THIS BACKEND bool getValueFromTable(lua_State *lua, const std::string& key, string& value); bool getValueFromTable(lua_State *lua, uint32_t key, string& value); bool getValueFromTable(lua_State *lua, const std::string& key, time_t& value); bool getValueFromTable(lua_State *lua, const std::string& key, uint32_t& value); bool getValueFromTable(lua_State *lua, const std::string& key, uint16_t& value); bool getValueFromTable(lua_State *lua, const std::string& key, int& value); bool getValueFromTable(lua_State *lua, const std::string& key, bool& value); //private.cc bool domaininfo_from_table(DomainInfo *di); void domains_from_table(vector* domains, const char *f_name); void dnsrr_to_table(lua_State *lua, const DNSResourceRecord *rr); //reload.cc void get_lua_function(lua_State *lua, const char *name, int *function); bool dnssec; bool logging; //dnssec.cc bool updateDomainKey(const string& name, unsigned int &id, bool toowhat); /* //minimal.cc bool content(DNSResourceRecord* rr); void getTheFreshOnes(vector* domains, string *type, string *f_name); bool checkDomainInfo(const string *domain, mongo::BSONObj *mongo_r, string *f_name, string *mongo_q, DomainInfo *di, SOAData *soadata = NULL); //crc32.cc int generateCRC32(const string& my_string); string mongo_db; string collection_domains; string collection_records; string collection_domainmetadata; string collection_cryptokeys; string collection_tsigkeys; mongo::DBClientConnection m_db; auto_ptr cursor; string q_name; // long long unsigned int count; mongo::Query mongo_query; mongo::BSONObj mongo_record; bool elements; DNSResourceRecord rr_record; string type; mongo::BSONObjIterator* contents; unsigned int default_ttl; bool logging_cerr; bool logging_content; bool checkindex; bool use_default_ttl; bool axfr_soa; SOAData last_soadata; */ }; #endif pdns-3.3/modules/luabackend/minimal.cc0000644000014601777760000001356512136555572021306 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" //#include "lua_functions.hh" /* FIRST PART */ LUABackend::LUABackend(const string &suffix) { setArgPrefix("lua"+suffix); try { if (pthread_equal(backend_pid, pthread_self())) { backend_count++; } else { backend_count = 1; backend_pid = pthread_self(); } // lb = NULL; lua = NULL; dnspacket = NULL; dnssec = false; reload(); } catch(LUAException &e) { L< 0) soadata.ttl = soadata.default_ttl; if (soadata.ttl == 0) { lua_pop(lua, 1 ); return false; } if (!getValueFromTable(lua, "nameserver", soadata.nameserver)) { soadata.nameserver = arg()["default-soa-name"]; if (soadata.nameserver.empty()) { L< #include using namespace std; #include "lua_functions.hh" /* virtual void reload(); virtual void rediscover(string* status=0); */ void LUABackend::get_lua_function(lua_State *lua, const char *name, int *function) { *function = 0; string f = "f_"; f.append(name); string arg = ""; if (!::arg().isEmpty(f)) arg = getArg(f); lua_getglobal(lua, arg == "" ? name : arg.c_str()); if (!lua_isnil(lua, -1)) { lua_pushvalue(lua, -1); *function = luaL_ref(lua, LUA_REGISTRYINDEX); } } void LUABackend::reload() { backend_name.clear(); // backend_name = "[LUABackend: " + uitoa(backend_pid) + " (" + uitoa(backend_count) +")] "; backend_name = "[LUABackend: (" + uitoa(backend_count) +")] "; if (lua) lua_close(lua); logging = ::arg().mustDo("query-logging") || mustDo("logging-query"); #if LUA_VERSION_MAJOR == 5 && LUA_VERSION_MINOR > 1 lua = luaL_newstate(); #else lua = lua_open(); #endif if (lua != NULL) { lua_atpanic(lua, my_lua_panic); string filename = getArg("filename"); //"powerdns-luabackend.lua"; if (luaL_loadfile (lua, filename.c_str()) != 0) { stringstream e; e << backend_name << "Error loading the file '" << filename << "' : " << lua_tostring(lua,-1) << endl; lua_pop(lua, 1); throw LUAException (e.str()); } else { lua_pushlightuserdata(lua, (void*)this); lua_setfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); register_lua_functions(lua); if(lua_pcall(lua, 0, 0, 0)) { stringstream e; e << backend_name << "Error running the file '" << filename << "' : " << lua_tostring(lua,-1) << endl; lua_pop(lua, 1); throw LUAException (e.str()); } else { get_lua_function(lua, "exec_error", &f_lua_exec_error); //minimal functions.... get_lua_function(lua, "list", &f_lua_list); get_lua_function(lua, "lookup", &f_lua_lookup); get_lua_function(lua, "get", &f_lua_get); get_lua_function(lua, "getsoa", &f_lua_getsoa); if (f_lua_list == 0 || f_lua_lookup == 0 || f_lua_get == 0 || f_lua_getsoa == 0) { throw LUAException (backend_name + "MINIMAL BACKEND: Missing required function(s)!"); } //master functions.... get_lua_function(lua, "getupdatedmasters", &f_lua_getupdatedmasters); get_lua_function(lua, "setnotifed", &f_lua_setnotifed); //slave functions.... get_lua_function(lua, "getdomaininfo", &f_lua_getdomaininfo); get_lua_function(lua, "ismaster", &f_lua_ismaster); get_lua_function(lua, "getunfreshslaveinfos", &f_lua_getunfreshslaveinfos); get_lua_function(lua, "setfresh", &f_lua_setfresh); get_lua_function(lua, "starttransaction", &f_lua_starttransaction); get_lua_function(lua, "committransaction", &f_lua_committransaction); get_lua_function(lua, "aborttransaction", &f_lua_aborttransaction); get_lua_function(lua, "feedrecord", &f_lua_feedrecord); //supermaster functions.... get_lua_function(lua, "supermasterbackend", &f_lua_supermasterbackend); get_lua_function(lua, "createslavedomain", &f_lua_createslavedomain); //rediscover get_lua_function(lua, "rediscover", &f_lua_rediscover); //dnssec get_lua_function(lua, "alsonotifies", &f_lua_alsonotifies); get_lua_function(lua, "getdomainmetadata", &f_lua_getdomainmetadata); get_lua_function(lua, "setdomainmetadata", &f_lua_setdomainmetadata); get_lua_function(lua, "getdomainkeys", &f_lua_getdomainkeys); get_lua_function(lua, "removedomainkey", &f_lua_removedomainkey); get_lua_function(lua, "activatedomainkey", &f_lua_activatedomainkey); get_lua_function(lua, "deactivatedomainkey", &f_lua_deactivatedomainkey); get_lua_function(lua, "updatedomainkey", &f_lua_updatedomainkey); get_lua_function(lua, "adddomainkey", &f_lua_adddomainkey); get_lua_function(lua, "gettsigkey", &f_lua_gettsigkey); get_lua_function(lua, "getbeforeandafternamesabsolute", &f_lua_getbeforeandafternamesabsolute); get_lua_function(lua, "updatednssecorderandauthabsolute", &f_lua_updatednssecorderandauthabsolute); get_lua_function(lua, "updatednssecorderandauth", &f_lua_updatednssecorderandauth); // not needed... } } } else { //a big kaboom here! throw LUAException (backend_name + "LUA OPEN FAILED!"); } } void LUABackend::rediscover(string* status) { if (f_lua_rediscover == 0) return; if (logging) L << Logger::Info << backend_name << "(rediscover) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_rediscover); if(lua_pcall(lua, 0, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } size_t returnedwhat = lua_type(lua, -1); if (returnedwhat != LUA_TSTRING) { lua_pop(lua, 1 ); return; } string s = lua_tostring(lua, -1); lua_pop(lua, 1 ); *status = s; if (logging) L << Logger::Info << backend_name << "(rediscover) END" << endl; return; } pdns-3.3/modules/luabackend/private.cc0000644000014601777760000000604012145162536021312 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" string LUABackend::my_getArg(string a) { return getArg(a); } bool LUABackend::my_mustDo(string a) { return mustDo(a); } bool LUABackend::domaininfo_from_table(DomainInfo *di) { di->backend = NULL; if (!getValueFromTable(lua, "id", di->id)) return false; if (!getValueFromTable(lua, "zone", di->zone)) return false; if (!getValueFromTable(lua, "serial", di->serial)) return false; getValueFromTable(lua, "notified_serial", di->notified_serial); getValueFromTable(lua, "last_check", di->last_check); di->kind = DomainInfo::Native; string kind; if (getValueFromTable(lua, "kind", kind)) { if (kind == "MASTER") di->kind = DomainInfo::Master; else if (kind == "SLAVE") di->kind = DomainInfo::Slave; } lua_pushstring(lua, "masters"); lua_gettable(lua, -2); if(!lua_isnil(lua, -1)) { lua_pushnil(lua); const char *value; while (lua_next(lua, -2)) { value = lua_tostring(lua, -1); lua_pop(lua,1); di->masters.push_back(value); } } lua_pop(lua, 1); di->backend = this; return true; } void LUABackend::domains_from_table(vector* domains, const char *f_name) { lua_pushnil(lua); size_t returnedwhat; while (lua_next(lua, -2)) { returnedwhat = lua_type(lua, -1); if (returnedwhat == LUA_TTABLE) { DomainInfo di; if (domaininfo_from_table(&di)) domains->push_back(di); } lua_pop(lua,1); } } void LUABackend::dnsrr_to_table(lua_State *lua, const DNSResourceRecord *rr) { lua_newtable(lua); lua_pushliteral(lua, "qtype"); lua_pushstring(lua, rr->qtype.getName().c_str()); lua_settable(lua, -3); lua_pushliteral(lua, "qclass"); lua_pushnumber(lua, rr->qclass); lua_settable(lua, -3); lua_pushliteral(lua, "priority"); lua_pushnumber(lua, rr->priority); lua_settable(lua, -3); lua_pushliteral(lua, "ttl"); lua_pushnumber(lua, rr->ttl); lua_settable(lua, -3); lua_pushliteral(lua, "auth"); lua_pushboolean(lua, rr->auth); lua_settable(lua, -3); lua_pushliteral(lua, "content"); lua_pushstring(lua, rr->content.c_str()); lua_settable(lua, -3); } pdns-3.3/modules/luabackend/OBJECTFILES0000644000014601777760000000014112136555572021007 0ustar00jenkinsnogroup00000000000000luabackend.o minimal.o reload.o lua_functions.o master.o private.o slave.o supermaster.o dnssec.opdns-3.3/modules/luabackend/Makefile.in0000644000014601777760000005116612165464027021411 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/luabackend DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libluabackend_la_LIBADD = am_libluabackend_la_OBJECTS = luabackend.lo minimal.lo reload.lo \ lua_functions.lo master.lo private.lo slave.lo supermaster.lo \ dnssec.lo libluabackend_la_OBJECTS = $(am_libluabackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libluabackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libluabackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libluabackend_la_SOURCES) DIST_SOURCES = $(libluabackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I/usr/include/lua5.1 @THREADFLAGS@ #AM_CPPFLAGS=-I/usr/local/include/luajit-2.0 -DUSE_LUAJIT @THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libluabackend.la libluabackend_la_SOURCES = luabackend.cc luabackend.hh minimal.cc reload.cc lua_functions.cc master.cc private.cc slave.cc supermaster.cc dnssec.cc \ lua_functions.hh libluabackend_la_LDFLAGS = -module -avoid-version -llua5.1 all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/luabackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/luabackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libluabackend.la: $(libluabackend_la_OBJECTS) $(libluabackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libluabackend_la_LINK) -rpath $(libdir) $(libluabackend_la_OBJECTS) $(libluabackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnssec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lua_functions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luabackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/master.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/private.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reload.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/supermaster.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES #-lluajit-5.1 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/luabackend/master.cc0000644000014601777760000000432212136555572021142 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" /* virtual void getUpdatedMasters(vector* domains); virtual void setNotifed(int id, u_int32_t serial); */ void LUABackend::getUpdatedMasters(vector* domains) { if (f_lua_getupdatedmasters == 0) return; if (logging) L << Logger::Info << backend_name << "(getUpdatedMasters) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getupdatedmasters); if(lua_pcall(lua, 0, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } size_t returnedwhat = lua_type(lua, -1); if (returnedwhat != LUA_TTABLE) { lua_pop(lua, 1 ); return; } domains_from_table(domains, "getUpdatedMasters"); if (logging) L << Logger::Info << backend_name << "(getUpdatedMasters) END" << endl; } void LUABackend::setNotifed(int id, u_int32_t serial) { if (f_lua_setnotifed == 0) return; if (logging) L << Logger::Info << backend_name << "(setNotifed) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setnotifed); lua_pushnumber(lua, id); lua_pushnumber(lua, serial); if(lua_pcall(lua, 2, 0, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } if (logging) L << Logger::Info << backend_name << "(setNotifed) END" << endl; } pdns-3.3/modules/luabackend/luabackend.cc0000644000014601777760000000265412136555572021746 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" /* SECOND PART */ class LUAFactory : public BackendFactory { public: LUAFactory() : BackendFactory("lua") {} void declareArguments(const string &suffix="") { declare(suffix,"filename","Filename of the script for lua backend","powerdns-luabackend.lua"); declare(suffix,"logging-query","Logging of the LUA Backend","no"); } DNSBackend *make(const string &suffix="") { return new LUABackend(suffix); } }; /* THIRD PART */ class LUALoader { public: LUALoader() { BackendMakers().report(new LUAFactory); L<> DiG 9.7.3 <<>> any www.test.com @127.0.0.1 -p5300 +multiline ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1001 ;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;www.test.com. IN ANY ;; ANSWER SECTION: www.test.com. 120 IN CNAME host.test.com. host.test.com. 120 IN A 10.11.12.13 host.test.com. 120 IN AAAA 1:2:3:4:5:6:7:8 ;; Query time: 1 msec ;; SERVER: 127.0.0.1#5300(127.0.0.1) ;; WHEN: Thu Jun 2 22:19:56 2011 ;; MSG SIZE rcvd: 93 ============================= OPTIONS IN THE CONFIGURE FILE ============================= The default values is: lua-filename = powerdns-luabackend.lua lua-logging-query = no You can also override all the default functionsnames for the luafunctions if you want. The prefix is lua-f_=mynewfunction. For example: lua-f_lookup = mynewfunction will call the function 'mynewfunction' for the lookup-routine. If you want your own configuration parameters you can have that too. Just call the function getarg("my_parameter") and it will return the value of 'lua-my_parameter'. For boolean you use the function mustdo("my_parameter"). ============================== YOUR OWN ERROR FUNCTION IN LUA ============================== You can have an error function in Lua when Lua gives back a error. First make your error function then you put this in pdns.conf: lua-f_exec_error = ====== DNSSEC ====== You can have full dnssec support in our Lua application. You should note the following regarding this: You don't have to implement the function 'updateDNSSECOrderAndAuth' since the default code will work correctly for you via the backend itself. The functions activateDomainKey and deactivateDomainKey can be implemented via a new function called updateDomainKey, which has three parameters (the other two has only two parameters) where the third is a boolean which is true or false depending on which function that was called from the beginning. ======================= INFORMATION FOR LOGGING ======================= If you have the parameter 'query-logging' or 'lua-logging-query' set to true/yes/on, then you will see what is happening in each function when PowerDNS calls them. This can, hopefully, help you with some debugging if you run into some kind of trouble with your Lua application. =============== ASKING QUESTION =============== You can send question about this backend to >dev/null first and if you don't get any answer from that you can try to send them to me at fredan-pdns@fredan.org Fredrik Danerklint.pdns-3.3/modules/luabackend/supermaster.cc0000644000014601777760000000704212136555572022223 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" /* //! determine if ip is a supermaster or a domain virtual bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db) //! called by PowerDNS to create a slave record for a superMaster virtual bool createSlaveDomain(const string &ip, const string &domain, const string &account) */ bool LUABackend::superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db) { if (f_lua_supermasterbackend == 0) return false; if (logging) L << Logger::Info << backend_name << "(superMasterBackend) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_supermasterbackend); lua_pushstring(lua, ip.c_str()); lua_pushstring(lua, domain.c_str()); lua_newtable(lua); int c = 0; for(vector::const_iterator i=nsset.begin();i!=nsset.end();++i) { c++; lua_pushnumber(lua, c); DNSResourceRecord rr; rr.qtype = i->qtype; rr.qclass = i->qclass; rr.priority = i->priority; rr.ttl = i->ttl; rr.auth = i->auth; rr.content = i->content; dnsrr_to_table(lua, &rr); lua_settable(lua, -3); } if(lua_pcall(lua, 3, 2, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); string a = ""; returnedwhat = lua_type(lua, -1); if (returnedwhat == LUA_TSTRING) a = lua_tostring(lua, -1); lua_pop(lua, 1); if (ok) { *account = a; *db = this; } if (logging) L << Logger::Info << backend_name << "(superMasterBackend) END" << endl; return ok; } bool LUABackend::createSlaveDomain(const string &ip, const string &domain, const string &account) { if (f_lua_createslavedomain == 0) return false; if (logging) L << Logger::Info << backend_name << "(createSlaveDomain) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_createslavedomain); lua_pushstring(lua, ip.c_str()); lua_pushstring(lua, domain.c_str()); lua_pushstring(lua, account.c_str()); if(lua_pcall(lua, 3, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(createSlaveDomain) END" << endl; return ok; } pdns-3.3/modules/luabackend/dnssec.cc0000644000014601777760000004136312136555572021134 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" /* virtual bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth) virtual bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys) virtual bool removeDomainKey(const string& name, unsigned int id) virtual int addDomainKey(const string& name, const KeyData& key) virtual bool activateDomainKey(const string& name, unsigned int id) virtual bool deactivateDomainKey(const string& name, unsigned int id) virtual bool getTSIGKey(const string& name, string* algorithm, string* content) { return false; } virtual bool setDomainMetadata(const string& name, const std::string& kind, std::vector& meta) virtual bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) virtual void alsoNotifies(const string &domain, set *ips) */ bool LUABackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth) { if(f_lua_updatednssecorderandauth == 0) { if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuth) domain_id: '" << domain_id << "' zonename: '" << zonename << "' qname: '" << qname << "' auth: '" << auth << "'" << endl; string ins=toLower(labelReverse(makeRelative(qname, zonename))); return this->updateDNSSECOrderAndAuthAbsolute(domain_id, qname, ins, auth); } if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuth) BEGIN domain_id: '" << domain_id << "' zonename: '" << zonename << "' qname: '" << qname << "' auth: '" << auth << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauth); lua_pushnumber(lua, domain_id); lua_pushstring(lua, zonename.c_str()); lua_pushstring(lua, qname.c_str()); lua_pushboolean(lua, auth); if(lua_pcall(lua, 4, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuth) END" << endl; return ok; } bool LUABackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) { if(f_lua_updatednssecorderandauthabsolute == 0) return false; if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuthAbsolute) BEGIN domain_id: '" << domain_id << "' qname: '" << qname << "' ordername: '" << ordername << "' auth: '" << auth << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauthabsolute); lua_pushnumber(lua, domain_id); lua_pushstring(lua, qname.c_str()); lua_pushstring(lua, ordername.c_str()); lua_pushboolean(lua, auth); if(lua_pcall(lua, 4, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuthAbsolute) END" << endl; return ok; } bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { if(f_lua_getbeforeandafternamesabsolute == 0) return false; unhashed.clear(); before.clear(); after.clear(); if(logging) L << Logger::Info << backend_name << "(getBeforeAndAfterNamesAbsolute) BEGIN id: '" << id << "' qname: '" << qname << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauthabsolute); lua_pushnumber(lua, id); lua_pushstring(lua, qname.c_str()); if(lua_pcall(lua, 2, 3, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = returnedwhat == LUA_TSTRING; if (!ok) { if(logging) L << Logger::Info << backend_name << "(getBeforeAndAfterNamesAbsolute) ERROR!" << endl; return false; } //will this be correct since we are poping one at the time? unhashed = lua_tostring(lua, -1); lua_pop(lua, 1); returnedwhat = lua_type(lua, -1); ok = (returnedwhat == LUA_TSTRING) && ok; before = lua_tostring(lua, -1); lua_pop(lua, 1); returnedwhat = lua_type(lua, -1); ok = (returnedwhat == LUA_TSTRING) && ok; after = lua_tostring(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(getBeforeAndAfterNamesAbsolute) END unhashed: '" << unhashed << "' before: '" << before << "' after: '" << after << "' " << endl; return ok; } bool LUABackend::updateDomainKey(const string& name, unsigned int &id, bool toowhat ) { if(f_lua_updatedomainkey == 0) return false; if(logging) L << Logger::Info << backend_name << "(updateDomainKey) BEGIN name: '" << name << "' id: '" << id << "' toowhat: '" << toowhat << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatedomainkey); lua_pushstring(lua, name.c_str()); lua_pushnumber(lua, id); lua_pushboolean(lua, toowhat); if(lua_pcall(lua, 3, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(updateDomainKey) END" << endl; return ok; } bool LUABackend::activateDomainKey(const string& name, unsigned int id) { if(f_lua_activatedomainkey == 0) return updateDomainKey(name, id, true); if(logging) L << Logger::Info << backend_name << "(activateDomainKey) BEGIN name: '" << name << "' id: '" << id << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_activatedomainkey); lua_pushstring(lua, name.c_str()); lua_pushnumber(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(activateDomainKey) END" << endl; return ok; } bool LUABackend::deactivateDomainKey(const string& name, unsigned int id) { if(f_lua_deactivatedomainkey == 0) return updateDomainKey(name, id, false); if(logging) L << Logger::Info << backend_name << "(deactivateDomainKey) BEGIN name: '" << name << "' id: '" << id << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_deactivatedomainkey); lua_pushstring(lua, name.c_str()); lua_pushnumber(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(deactivateDomainKey) END" << endl; return ok; } bool LUABackend::removeDomainKey(const string& name, unsigned int id) { if(f_lua_removedomainkey == 0) return false; if(logging) L << Logger::Info << backend_name << "(removeDomainKey) BEGIN name: '" << name << "' id: '" << id << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_removedomainkey); lua_pushstring(lua, name.c_str()); lua_pushnumber(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(removeDomainKey) END" << endl; return ok; } int LUABackend::addDomainKey(const string& name, const KeyData& key) { // there is no logging function in pdnssec when running this routine? //key = id, flags, active, content if(f_lua_adddomainkey == 0) return -1; if(logging) //L << Logger::Info << backend_name << "(addDomainKey) BEGIN name: '" << name << "' id: '" << id << endl; cerr << backend_name << "(addDomainKey) BEGIN name: '" << name << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_adddomainkey); lua_pushstring(lua, name.c_str()); lua_newtable(lua); lua_pushliteral(lua, "flags"); lua_pushnumber(lua, key.flags); lua_settable(lua, -3); lua_pushliteral(lua, "active"); lua_pushboolean(lua, key.active); lua_settable(lua, -3); lua_pushliteral(lua, "content"); lua_pushstring(lua, key.content.c_str()); lua_settable(lua, -3); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return -1; } size_t returnedwhat = lua_type(lua, -1); int ok = -1; if (returnedwhat == LUA_TNUMBER) ok = lua_tonumber(lua, -1); lua_pop(lua, 1); if(logging) cerr << backend_name << "(addDomainKey) END" << endl; return ok; } bool LUABackend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { //what is kind used for? if(f_lua_getdomainkeys == 0) return false; if(logging) L << Logger::Info << backend_name << "(getDomainKeys) BEGIN name: '" << name << "' kind: '" << kind << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomainkeys); lua_pushstring(lua, name.c_str()); lua_pushnumber(lua, kind); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); if (returnedwhat != LUA_TTABLE) { lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(getDomainKeys) ERROR!" << endl; return false; } lua_pushnil(lua); int key; int j = 0; while (lua_next(lua, -2)) { returnedwhat = lua_type(lua, -1); if (returnedwhat == LUA_TTABLE) { KeyData kd; bool i,f,a,c = false; i = getValueFromTable(lua, "id", kd.id); f = getValueFromTable(lua, "flags", kd.flags); a = getValueFromTable(lua, "active", kd.active); c = getValueFromTable(lua, "content", kd.content); if (i && f && a && c) { j++; keys.push_back(kd); } } lua_pop(lua,1); key = lua_tonumber(lua, -1); } if(logging) L << Logger::Info << backend_name << "(getDomainKeys) END" << endl; return j > 0; } bool LUABackend::getTSIGKey(const string& name, string* algorithm, string* content) { if(f_lua_gettsigkey == 0) return false; if(logging) L << Logger::Info << backend_name << "(getTSIGKey) BEGIN name: '" << name << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_gettsigkey); lua_pushstring(lua, name.c_str()); if(lua_pcall(lua, 1, 2, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } if ( (lua_type(lua, -1) != LUA_TSTRING) && (lua_type(lua, -2) != LUA_TSTRING) ) { lua_pop(lua, 2); if(logging) L << Logger::Info << backend_name << "(getTSIGKey) ERROR" << endl; return false; } string a,c = ""; a = lua_tostring(lua, -1); lua_pop(lua, 1); c = lua_tostring(lua, -1); lua_pop(lua, 1); *algorithm = a; *content = c; if(logging) L << Logger::Info << backend_name << "(getTSIGKey) END" << endl; return true; } bool LUABackend::setDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { if(f_lua_setdomainmetadata == 0) return false; if(logging) L << Logger::Info << backend_name << "(setDomainMetadata) BEGIN name: '" << name << "' kind: '" << kind << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setdomainmetadata); lua_pushstring(lua, name.c_str()); lua_pushstring(lua, kind.c_str()); lua_newtable(lua); std::vector::iterator i; int c = 0; for(i = meta.begin(); ic_str()); lua_settable(lua, -3); } if(lua_pcall(lua, 3, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if(logging) L << Logger::Info << backend_name << "(setDomainMetadata) END" << endl; return ok; } bool LUABackend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { if(f_lua_getdomainmetadata == 0) return false; if(logging) L << Logger::Info << backend_name << "(getDomainMetadata) BEGIN name: '" << name << "' kind: '" << kind << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomainmetadata); lua_pushstring(lua, name.c_str()); lua_pushstring(lua, kind.c_str()); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } lua_pushnil(lua); int key; int j = 0; size_t returnedwhat; while (lua_next(lua, -2)) { returnedwhat = lua_type(lua, -1); if (returnedwhat == LUA_TSTRING) { j++; meta.push_back(lua_tostring(lua, -1)); } lua_pop(lua,1); key = lua_tonumber(lua, -1); } if(logging) L << Logger::Info << backend_name << "(getDomainMetadata) END" << endl; return j > 0; } void LUABackend::alsoNotifies(const string &domain, set *ips) { if(f_lua_alsonotifies == 0) return; if(logging) L << Logger::Info << backend_name << "(alsonotifies) BEGIN domain: '" << domain << "'" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_alsonotifies); lua_pushstring(lua, domain.c_str()); if(lua_pcall(lua, 1, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } lua_pushnil(lua); int key; size_t returnedwhat; while (lua_next(lua, -2)) { returnedwhat = lua_type(lua, -1); if (returnedwhat == LUA_TSTRING) { ips->insert(lua_tostring(lua, -1)); } lua_pop(lua,1); key = lua_tonumber(lua, -1); } if(logging) L << Logger::Info << backend_name << "(alsoNotifies) END" << endl; return; } pdns-3.3/modules/luabackend/slave.cc0000644000014601777760000001613612136555572020767 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" /* virtual bool startTransaction(const string &qname, int id); virtual bool commitTransaction(); virtual bool abortTransaction(); virtual bool feedRecord(const DNSResourceRecord &rr); virtual bool getDomainInfo(const string &domain, DomainInfo &di); virtual bool isMaster(const string &name, const string &ip); virtual void getUnfreshSlaveInfos(vector* domains); virtual void setFresh(int id); */ bool LUABackend::startTransaction(const string &qname, int id) { if (f_lua_starttransaction == 0) return false; if (logging) L << Logger::Info << backend_name << "(startTransaction) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_starttransaction); lua_pushstring(lua, qname.c_str()); lua_pushnumber(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(startTransaction) END" << endl; return ok; } bool LUABackend::commitTransaction() { if (f_lua_committransaction == 0) return false; if (logging) L << Logger::Info << backend_name << "(commitTransaction) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_committransaction); if(lua_pcall(lua, 0, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(commitTransaction) END" << endl; return ok; } bool LUABackend::abortTransaction() { if (f_lua_aborttransaction == 0) return false; if (logging) L << Logger::Info << backend_name << "(abortTransaction) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_aborttransaction); if(lua_pcall(lua, 0, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(abortTransaction) END" << endl; return ok; } bool LUABackend::feedRecord(const DNSResourceRecord &rr) { if (f_lua_feedrecord == 0) return false; if (logging) L << Logger::Info << backend_name << "(feedRecord) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_feedrecord); dnsrr_to_table(lua, &rr); if(lua_pcall(lua, 1, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(feedRecord) END" << endl; return ok; } void LUABackend::setFresh(int id) { if (f_lua_setfresh == 0) return; if (logging) L << Logger::Info << backend_name << "(setFresh) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setfresh); lua_pushnumber(lua, id); if(lua_pcall(lua, 1, 0, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } if (logging) L << Logger::Info << backend_name << "(setFresh) END" << endl; } void LUABackend::getUnfreshSlaveInfos(vector* domains) { if (f_lua_getunfreshslaveinfos == 0) return; if (logging) L << Logger::Info << backend_name << "(getUnfreshSlaveInfos) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getunfreshslaveinfos); if(lua_pcall(lua, 0, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return; } size_t returnedwhat = lua_type(lua, -1); if (returnedwhat != LUA_TTABLE) { lua_pop(lua, 1 ); return; } domains_from_table(domains, "getUnfreshSlaveInfos"); if (logging) L << Logger::Info << backend_name << "(getUnfreshSlaveInfos) END" << endl; } bool LUABackend::isMaster(const string &domain, const string &ip) { if (f_lua_ismaster == 0) return false; if (logging) L << Logger::Error << backend_name << "(isMaster) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_ismaster); lua_pushstring(lua, domain.c_str()); lua_pushstring(lua, ip.c_str()); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); bool ok = false; if (returnedwhat == LUA_TBOOLEAN) ok = lua_toboolean(lua, -1); lua_pop(lua, 1); if (logging) L << Logger::Info << backend_name << "(isMaster) END" << endl; return ok; } bool LUABackend::getDomainInfo(const string &domain, DomainInfo &di) { if (f_lua_getdomaininfo == 0) return false; if (logging) L << Logger::Info << backend_name << "(getDomainInfo) BEGIN" << endl; lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomaininfo); lua_pushstring(lua, domain.c_str()); if(lua_pcall(lua, 1, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); lua_pop(lua, 1); throw runtime_error(e); return false; } size_t returnedwhat = lua_type(lua, -1); if (returnedwhat != LUA_TTABLE) { lua_pop(lua, 1 ); return false; } if (logging) L << Logger::Info << backend_name << "(getDomainInfo) END" << endl; return domaininfo_from_table(&di); } pdns-3.3/modules/luabackend/Makefile.am0000644000014601777760000000066012140444471021363 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=-I/usr/include/lua5.1 @THREADFLAGS@ #AM_CPPFLAGS=-I/usr/local/include/luajit-2.0 -DUSE_LUAJIT @THREADFLAGS@ EXTRA_DIST=OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libluabackend.la libluabackend_la_SOURCES=luabackend.cc luabackend.hh minimal.cc reload.cc lua_functions.cc master.cc private.cc slave.cc supermaster.cc dnssec.cc \ lua_functions.hh libluabackend_la_LDFLAGS=-module -avoid-version -llua5.1 #-lluajit-5.1 pdns-3.3/modules/luabackend/lua_functions.cc0000644000014601777760000001640012136555572022520 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2011 Fredrik Danerklint This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define LUABACKEND_EXTERN_F_HH #include "luabackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "pdns/dnspacket.hh" #include #include using namespace std; const luaL_Reg lualibs[] = { {"", luaopen_base}, {LUA_LOADLIBNAME, luaopen_package}, {LUA_TABLIBNAME, luaopen_table}, {LUA_IOLIBNAME, luaopen_io}, {LUA_OSLIBNAME, luaopen_os}, {LUA_STRLIBNAME, luaopen_string}, {LUA_MATHLIBNAME, luaopen_math}, {LUA_DBLIBNAME, luaopen_debug}, // {LUA_COLIBNAME, luaopen_coroutine}, #ifdef USE_LUAJIT {"bit", luaopen_bit}, {"jit", luaopen_jit}, #endif {NULL, NULL} }; int my_lua_panic (lua_State *lua) { lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1); assert(lua == lb->lua); stringstream e; e << lb->backend_name << "LUA PANIC! '" << lua_tostring(lua,-1) << "'" << endl; throw LUAException (e.str()); return 0; } int l_arg_get (lua_State *lua) { int i = lua_gettop(lua); if (i < 1) return 0; lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1); string a = lua_tostring(lua, 1); if (::arg().isEmpty(a)) lua_pushnil(lua); else lua_pushstring(lua, lb->my_getArg(a).c_str()); return 1; } int l_arg_mustdo (lua_State *lua) { int i = lua_gettop(lua); if (i < 1) return 0; lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1); string a = lua_tostring(lua, 1); if (::arg().isEmpty(a)) lua_pushnil(lua); else lua_pushboolean(lua, lb->my_mustDo(a)); return 1; } int l_dnspacket (lua_State *lua) { lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1); if (lb->dnspacket == NULL) { lua_pushnil(lua); return 1; } lua_pushstring(lua, lb->dnspacket->getRemote().c_str()); lua_pushnumber(lua, lb->dnspacket->getRemotePort()); lua_pushstring(lua, lb->dnspacket->getLocal().c_str()); return 3; } int l_logger (lua_State *lua) { // assert(lua == lb->lua); lua_getfield(lua, LUA_REGISTRYINDEX, "__LUABACKEND"); LUABackend* lb = (LUABackend*)lua_touserdata(lua, -1); int i = lua_gettop(lua); if (i < 1) return 0; int log_level = 0; stringstream s; int j; const char *ss; log_level = lua_tointeger(lua, 1); string space = ""; for(j=2; j<=i; j++) { ss = lua_tostring(lua, j); s << space << ss; space = " "; } L.log(lb->backend_name + s.str(), (Logger::Urgency) log_level); return 0; } void register_lua_functions(lua_State *lua) { lua_gc(lua, LUA_GCSTOP, 0); // stop collector during initialization const luaL_Reg *lib = lualibs; for (; lib->func; lib++) { lua_pushcfunction(lua, lib->func); lua_pushstring(lua, lib->name); lua_call(lua, 1, 0); } lua_gc(lua, LUA_GCRESTART, 0); lua_pushinteger(lua, Logger::All); lua_setglobal(lua, "log_all"); lua_pushinteger(lua, Logger::NTLog); lua_setglobal(lua, "log_ntlog"); lua_pushinteger(lua, Logger::Alert); lua_setglobal(lua, "log_alert"); lua_pushinteger(lua, Logger::Critical); lua_setglobal(lua, "log_critical"); lua_pushinteger(lua, Logger::Error); lua_setglobal(lua, "log_error"); lua_pushinteger(lua, Logger::Warning); lua_setglobal(lua, "log_warning"); lua_pushinteger(lua, Logger::Notice); lua_setglobal(lua, "log_notice"); lua_pushinteger(lua, Logger::Info); lua_setglobal(lua, "log_info"); lua_pushinteger(lua, Logger::Debug); lua_setglobal(lua, "log_debug"); lua_pushinteger(lua, Logger::None); lua_setglobal(lua, "log_none"); lua_pushcfunction(lua, l_dnspacket); lua_setglobal(lua, "dnspacket"); lua_pushcfunction(lua, l_logger); lua_setglobal(lua, "logger"); lua_pushcfunction(lua, l_arg_get); lua_setglobal(lua, "getarg"); lua_pushcfunction(lua, l_arg_mustdo); lua_setglobal(lua, "mustdo"); lua_newtable(lua); for(vector::const_iterator iter = QType::names.begin(); iter != QType::names.end(); ++iter) { lua_pushnumber(lua, iter->second); lua_setfield(lua, -2, iter->first.c_str()); } lua_pushnumber(lua, 3); lua_setfield(lua, -2, "NXDOMAIN"); lua_setglobal(lua, "QTypes"); } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, string& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = lua_tostring(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, uint32_t key, string& value) { lua_pushnumber(lua, key); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = lua_tostring(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, time_t& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = (time_t)lua_tonumber(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint32_t& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = (uint32_t)lua_tonumber(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint16_t& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = (uint16_t)lua_tonumber(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, int& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = (int)lua_tonumber(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, bool& value) { lua_pushstring(lua, key.c_str()); lua_gettable(lua, -2); bool ret = false; if(!lua_isnil(lua, -1)) { value = lua_toboolean(lua, -1); ret = true; } lua_pop(lua, 1); return ret; } pdns-3.3/modules/ldapbackend/0000755000014601777760000000000012165464054017472 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/ldapbackend/OBJECTLIBS0000644000014601777760000000002012136555572021031 0ustar00jenkinsnogroup00000000000000-lldap_r -llber pdns-3.3/modules/ldapbackend/ldapbackend.cc0000644000014601777760000004445012151657051022234 0ustar00jenkinsnogroup00000000000000#include "ldapbackend.hh" unsigned int ldap_host_index = 0; LdapBackend::LdapBackend( const string &suffix ) { string hoststr; unsigned int i, idx; vector hosts; try { m_msgid = 0; m_qname = ""; m_pldap = NULL; m_qlog = arg().mustDo( "query-logging" ); m_default_ttl = arg().asNum( "default-ttl" ); m_myname = "[LdapBackend]"; setArgPrefix( "ldap" + suffix ); m_getdn = false; m_list_fcnt = &LdapBackend::list_simple; m_lookup_fcnt = &LdapBackend::lookup_simple; m_prepare_fcnt = &LdapBackend::prepare_simple; if( getArg( "method" ) == "tree" ) { m_lookup_fcnt = &LdapBackend::lookup_tree; } if( getArg( "method" ) == "strict" || mustDo( "disable-ptrrecord" ) ) { m_list_fcnt = &LdapBackend::list_strict; m_lookup_fcnt = &LdapBackend::lookup_strict; m_prepare_fcnt = &LdapBackend::prepare_strict; } stringtok( hosts, getArg( "host" ), ", " ); idx = ldap_host_index++ % hosts.size(); hoststr = hosts[idx]; for( i = 1; i < hosts.size(); i++ ) { hoststr += " " + hosts[ ( idx + i ) % hosts.size() ]; } L << Logger::Info << m_myname << " LDAP servers = " << hoststr << endl; m_pldap = new PowerLDAP( hoststr.c_str(), LDAP_PORT, mustDo( "starttls" ) ); m_pldap->setOption( LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS ); m_pldap->bind( getArg( "binddn" ), getArg( "secret" ), LDAP_AUTH_SIMPLE, getArgAsNum( "timeout" ) ); L << Logger::Notice << m_myname << " Ldap connection succeeded" << endl; return; } catch( LDAPTimeout < ) { L << Logger::Error << m_myname << " Ldap connection to server failed because of timeout" << endl; } catch( LDAPException &le ) { L << Logger::Error << m_myname << " Ldap connection to server failed: " << le.what() << endl; } catch( std::exception &e ) { L << Logger::Error << m_myname << " Caught STL exception: " << e.what() << endl; } if( m_pldap != NULL ) { delete( m_pldap ); } throw( AhuException( "Unable to connect to ldap server" ) ); } LdapBackend::~LdapBackend() { if( m_pldap != NULL ) { delete( m_pldap ); } L << Logger::Notice << m_myname << " Ldap connection closed" << endl; } bool LdapBackend::list( const string& target, int domain_id ) { try { m_qname = target; m_axfrqlen = target.length(); m_adomain = m_adomains.end(); // skip loops in get() first time return (this->*m_list_fcnt)( target, domain_id ); } catch( LDAPTimeout < ) { L << Logger::Warning << m_myname << " Unable to get zone " + target + " from LDAP directory: " << lt.what() << endl; throw( DBException( "LDAP server timeout" ) ); } catch( LDAPException &le ) { L << Logger::Error << m_myname << " Unable to get zone " + target + " from LDAP directory: " << le.what() << endl; throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server } catch( std::exception &e ) { L << Logger::Error << m_myname << " Caught STL exception for target " << target << ": " << e.what() << endl; throw( DBException( "STL exception" ) ); } return false; } inline bool LdapBackend::list_simple( const string& target, int domain_id ) { string dn; string filter; string qesc; dn = getArg( "basedn" ); qesc = toLower( m_pldap->escape( target ) ); // search for SOARecord of target filter = strbind( ":target:", "&(associatedDomain=" + qesc + ")(sOARecord=*)", getArg( "filter-axfr" ) ); m_msgid = m_pldap->search( dn, LDAP_SCOPE_SUBTREE, filter, (const char**) ldap_attrany ); m_pldap->getSearchEntry( m_msgid, m_result, true ); if( m_result.count( "dn" ) && !m_result["dn"].empty() ) { if( !mustDo( "basedn-axfr-override" ) ) { dn = m_result["dn"][0]; } m_result.erase( "dn" ); } prepare(); filter = strbind( ":target:", "associatedDomain=*." + qesc, getArg( "filter-axfr" ) ); DLOG( L << Logger::Debug << m_myname << " Search = basedn: " << dn << ", filter: " << filter << endl ); m_msgid = m_pldap->search( dn, LDAP_SCOPE_SUBTREE, filter, (const char**) ldap_attrany ); return true; } inline bool LdapBackend::list_strict( const string& target, int domain_id ) { if( (target.size() > 13 && target.substr( target.size() - 13, 13 ) == ".in-addr.arpa") || (target.size() > 9 && target.substr( target.size() - 9, 9 ) == ".ip6.arpa") ) { L << Logger::Warning << m_myname << " Request for reverse zone AXFR, but this is not supported in strict mode" << endl; return false; // AXFR isn't supported in strict mode. Use simple mode and additional PTR records } return list_simple( target, domain_id ); } void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) { try { m_axfrqlen = 0; m_qname = qname; m_adomain = m_adomains.end(); // skip loops in get() first time if( m_qlog ) { L.log( "Query: '" + qname + "|" + qtype.getName() + "'", Logger::Error ); } (this->*m_lookup_fcnt)( qtype, qname, dnspkt, zoneid ); } catch( LDAPTimeout < ) { L << Logger::Warning << m_myname << " Unable to search LDAP directory: " << lt.what() << endl; throw( DBException( "LDAP server timeout" ) ); } catch( LDAPException &le ) { L << Logger::Error << m_myname << " Unable to search LDAP directory: " << le.what() << endl; throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server } catch( std::exception &e ) { L << Logger::Error << m_myname << " Caught STL exception for qname " << qname << ": " << e.what() << endl; throw( DBException( "STL exception" ) ); } } void LdapBackend::lookup_simple( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) { string filter, attr, qesc; const char** attributes = ldap_attrany + 1; // skip associatedDomain const char* attronly[] = { NULL, "dNSTTL", "modifyTimestamp", NULL }; qesc = toLower( m_pldap->escape( qname ) ); filter = "associatedDomain=" + qesc; if( qtype.getCode() != QType::ANY ) { attr = qtype.getName() + "Record"; filter = "&(" + filter + ")(" + attr + "=*)"; attronly[0] = attr.c_str(); attributes = attronly; } filter = strbind( ":target:", filter, getArg( "filter-lookup" ) ); DLOG( L << Logger::Debug << m_myname << " Search = basedn: " << getArg( "basedn" ) << ", filter: " << filter << ", qtype: " << qtype.getName() << endl ); m_msgid = m_pldap->search( getArg( "basedn" ), LDAP_SCOPE_SUBTREE, filter, attributes ); } void LdapBackend::lookup_strict( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) { int len; vector parts; string filter, attr, qesc; const char** attributes = ldap_attrany + 1; // skip associatedDomain const char* attronly[] = { NULL, "dNSTTL", "modifyTimestamp", NULL }; qesc = toLower( m_pldap->escape( qname ) ); stringtok( parts, qesc, "." ); len = qesc.length(); if( parts.size() == 6 && len > 13 && qesc.substr( len - 13, 13 ) == ".in-addr.arpa" ) // IPv4 reverse lookups { filter = "aRecord=" + ptr2ip4( parts ); attronly[0] = "associatedDomain"; attributes = attronly; } else if( parts.size() == 34 && len > 9 && ( qesc.substr( len - 9, 9 ) == ".ip6.arpa" ) ) // IPv6 reverse lookups { filter = "aAAARecord=" + ptr2ip6( parts ); attronly[0] = "associatedDomain"; attributes = attronly; } else // IPv4 and IPv6 lookups { filter = "associatedDomain=" + qesc; if( qtype.getCode() != QType::ANY ) { attr = qtype.getName() + "Record"; filter = "&(" + filter + ")(" + attr + "=*)"; attronly[0] = attr.c_str(); attributes = attronly; } } filter = strbind( ":target:", filter, getArg( "filter-lookup" ) ); DLOG( L << Logger::Debug << m_myname << " Search = basedn: " << getArg( "basedn" ) << ", filter: " << filter << ", qtype: " << qtype.getName() << endl ); m_msgid = m_pldap->search( getArg( "basedn" ), LDAP_SCOPE_SUBTREE, filter, attributes ); } void LdapBackend::lookup_tree( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) { string filter, attr, qesc, dn; const char** attributes = ldap_attrany + 1; // skip associatedDomain const char* attronly[] = { NULL, "dNSTTL", "modifyTimestamp", NULL }; vector::reverse_iterator i; vector parts; qesc = toLower( m_pldap->escape( qname ) ); filter = "associatedDomain=" + qesc; if( qtype.getCode() != QType::ANY ) { attr = qtype.getName() + "Record"; filter = "&(" + filter + ")(" + attr + "=*)"; attronly[0] = attr.c_str(); attributes = attronly; } filter = strbind( ":target:", filter, getArg( "filter-lookup" ) ); stringtok( parts, toLower( qname ), "." ); for( i = parts.rbegin(); i != parts.rend(); i++ ) { dn = "dc=" + *i + "," + dn; } DLOG( L << Logger::Debug << m_myname << " Search = basedn: " << dn + getArg( "basedn" ) << ", filter: " << filter << ", qtype: " << qtype.getName() << endl ); m_msgid = m_pldap->search( dn + getArg( "basedn" ), LDAP_SCOPE_BASE, filter, attributes ); } inline bool LdapBackend::prepare() { m_adomains.clear(); m_ttl = m_default_ttl; m_last_modified = 0; if( m_result.count( "dNSTTL" ) && !m_result["dNSTTL"].empty() ) { char* endptr; m_ttl = (uint32_t) strtol( m_result["dNSTTL"][0].c_str(), &endptr, 10 ); if( *endptr != '\0' ) { L << Logger::Warning << m_myname << " Invalid time to life for " << m_qname << ": " << m_result["dNSTTL"][0] << endl; m_ttl = m_default_ttl; } m_result.erase( "dNSTTL" ); } if( m_result.count( "modifyTimestamp" ) && !m_result["modifyTimestamp"].empty() ) { if( ( m_last_modified = str2tstamp( m_result["modifyTimestamp"][0] ) ) == 0 ) { L << Logger::Warning << m_myname << " Invalid modifyTimestamp for " << m_qname << ": " << m_result["modifyTimestamp"][0] << endl; } m_result.erase( "modifyTimestamp" ); } if( !(this->*m_prepare_fcnt)() ) { return false; } m_adomain = m_adomains.begin(); m_attribute = m_result.begin(); m_value = m_attribute->second.begin(); return true; } inline bool LdapBackend::prepare_simple() { if( !m_axfrqlen ) // request was a normal lookup() { m_adomains.push_back( m_qname ); } else // request was a list() for AXFR { if( m_result.count( "associatedDomain" ) ) { vector::iterator i; for( i = m_result["associatedDomain"].begin(); i != m_result["associatedDomain"].end(); i++ ) { if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname ) { m_adomains.push_back( *i ); } } m_result.erase( "associatedDomain" ); } } return true; } inline bool LdapBackend::prepare_strict() { if( !m_axfrqlen ) // request was a normal lookup() { m_adomains.push_back( m_qname ); if( m_result.count( "associatedDomain" ) ) { m_result["PTRRecord"] = m_result["associatedDomain"]; m_result.erase( "associatedDomain" ); } } else // request was a list() for AXFR { if( m_result.count( "associatedDomain" ) ) { vector::iterator i; for( i = m_result["associatedDomain"].begin(); i != m_result["associatedDomain"].end(); i++ ) { if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname ) { m_adomains.push_back( *i ); } } m_result.erase( "associatedDomain" ); } } return true; } bool LdapBackend::get( DNSResourceRecord &rr ) { QType qt; vector parts; string attrname, content, qstr; try { do { while( m_adomain != m_adomains.end() ) { while( m_attribute != m_result.end() ) { attrname = m_attribute->first; qstr = attrname.substr( 0, attrname.length() - 6 ); // extract qtype string from ldap attribute name qt = const_cast(toUpper( qstr ).c_str()); while( m_value != m_attribute->second.end() ) { content = *m_value; rr.qtype = qt; rr.qname = *m_adomain; rr.priority = 0; rr.ttl = m_ttl; rr.last_modified = m_last_modified; if( qt.getCode() == QType::MX || qt.getCode() == QType::SRV ) // Priority, e.g. 10 smtp.example.com { char* endptr; string::size_type first = content.find_first_of( " " ); if( first == string::npos ) { L << Logger::Warning << m_myname << " Invalid " << attrname << " without priority for " << m_qname << ": " << content << endl; m_value++; continue; } rr.priority = (uint16_t) strtoul( (content.substr( 0, first )).c_str(), &endptr, 10 ); if( *endptr != '\0' ) { L << Logger::Warning << m_myname << " Invalid " << attrname << " without priority for " << m_qname << ": " << content << endl; m_value++; continue; } content = content.substr( first + 1, content.length() - first - 1 ); } rr.content = content; m_value++; DLOG( L << Logger::Debug << m_myname << " Record = qname: " << rr.qname << ", qtype: " << (rr.qtype).getName() << ", priority: " << rr.priority << ", ttl: " << rr.ttl << ", content: " << rr.content << endl ); return true; } m_attribute++; m_value = m_attribute->second.begin(); } m_adomain++; m_attribute = m_result.begin(); m_value = m_attribute->second.begin(); } } while( m_pldap->getSearchEntry( m_msgid, m_result, m_getdn ) && prepare() ); } catch( LDAPTimeout < ) { L << Logger::Warning << m_myname << " Search failed: " << lt.what() << endl; throw( DBException( "LDAP server timeout" ) ); } catch( LDAPException &le ) { L << Logger::Error << m_myname << " Search failed: " << le.what() << endl; throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server } catch( std::exception &e ) { L << Logger::Error << m_myname << " Caught STL exception for " << m_qname << ": " << e.what() << endl; throw( DBException( "STL exception" ) ); } return false; } bool LdapBackend::getDomainInfo( const string& domain, DomainInfo& di ) { string filter; SOAData sd; const char* attronly[] = { "sOARecord", NULL }; // search for SOARecord of domain filter = "(&(associatedDomain=" + toLower( m_pldap->escape( domain ) ) + ")(SOARecord=*))"; m_msgid = m_pldap->search( getArg( "basedn" ), LDAP_SCOPE_SUBTREE, filter, attronly ); m_pldap->getSearchEntry( m_msgid, m_result ); if( m_result.count( "sOARecord" ) && !m_result["sOARecord"].empty() ) { sd.serial = 0; fillSOAData( m_result["sOARecord"][0], sd ); di.id = 0; di.serial = sd.serial; di.zone = domain; di.last_check = 0; di.backend = this; di.kind = DomainInfo::Master; return true; } return false; } class LdapFactory : public BackendFactory { public: LdapFactory() : BackendFactory( "ldap" ) {} void declareArguments( const string &suffix="" ) { declare( suffix, "host", "One or more LDAP server with ports or LDAP URIs (separated by spaces)","ldap://127.0.0.1:389/" ); declare( suffix, "starttls", "Use TLS to encrypt connection (unused for LDAP URIs)", "no" ); declare( suffix, "basedn", "Search root in ldap tree (must be set)","" ); declare( suffix, "basedn-axfr-override", "Override base dn for AXFR subtree search", "no" ); declare( suffix, "binddn", "User dn for non anonymous binds","" ); declare( suffix, "secret", "User password for non anonymous binds", "" ); declare( suffix, "timeout", "Seconds before connecting to server fails", "5" ); declare( suffix, "method", "How to search entries (simple, strict or tree)", "simple" ); declare( suffix, "filter-axfr", "LDAP filter for limiting AXFR results", "(:target:)" ); declare( suffix, "filter-lookup", "LDAP filter for limiting IP or name lookups", "(:target:)" ); declare( suffix, "disable-ptrrecord", "Deprecated, use ldap-method=strict instead", "no" ); } DNSBackend* make( const string &suffix="" ) { return new LdapBackend( suffix ); } }; class LdapLoader { LdapFactory factory; public: LdapLoader() { BackendMakers().report( &factory ); L << Logger::Info << " [LdapBackend] This is the ldap module version "VERSION" ("__DATE__", "__TIME__") reporting" << endl; } }; static LdapLoader ldaploader; pdns-3.3/modules/ldapbackend/OBJECTFILES0000644000014601777760000000003212136555572021145 0ustar00jenkinsnogroup00000000000000ldapbackend.o powerldap.o pdns-3.3/modules/ldapbackend/utils.hh0000644000014601777760000000541612136555572021165 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include #include #ifndef LDAPBACKEND_UTILS_HH #define LDAPBACKEND_UTILS_HH using std::string; using std::vector; inline string ptr2ip4( vector& parts ) { string ip; parts.pop_back(); parts.pop_back(); ip = parts.back(); parts.pop_back(); while( !parts.empty() ) { ip += "." + parts.back(); parts.pop_back(); } return ip; } inline string ptr2ip6( vector& parts ) { int i = 0; string ip; parts.pop_back(); parts.pop_back(); while( i < 3 && parts.size() > 1 && parts.back() == "0" ) { parts.pop_back(); i++; } while( i++ < 4 && !parts.empty() ) { ip += parts.back(); parts.pop_back(); } while( !parts.empty() ) { i = 0; ip += ":"; while( i < 3 && parts.size() > 1 && parts.back() == "0" ) { parts.pop_back(); i++; } while( i++ < 4 && !parts.empty() ) { ip += parts.back(); parts.pop_back(); } } return ip; } inline string ip2ptr4( const string& ip ) { string ptr; vector parts; stringtok( parts, ip, "." ); while( !parts.empty() ) { ptr += parts.back() + "."; parts.pop_back(); } return ptr + "in-addr.arpa"; } inline string ip2ptr6( const string& ip ) { string ptr, part, defstr; vector parts; stringtok( parts, ip, ":" ); while( !parts.empty() ) { defstr = "0.0.0.0."; part = parts.back(); while( part.length() < 4 ) { part = "0" + part; } defstr[0] = part[3]; defstr[2] = part[2]; defstr[4] = part[1]; defstr[6] = part[0]; ptr += defstr; parts.pop_back(); } return ptr + "ip6.arpa"; } inline string strbind( const string& search, const string& replace, string subject ) { size_t pos = 0; while( ( pos = subject.find( search, pos ) ) != string::npos ) { subject.replace( pos, search.size(), replace ); pos += replace.size(); } return subject; } /* * Convert a LDAP time string to a time_t. Return 0 if unable to convert */ inline time_t str2tstamp( const string& str ) { char* tmp; struct tm tm; tmp = strptime( str.c_str(), "%Y%m%d%H%M%SZ", &tm ); if( tmp != NULL && *tmp == 0 ) { return Utility::timegm( &tm ); } return 0; } #endif pdns-3.3/modules/ldapbackend/Makefile.in0000644000014601777760000004763512165464027021556 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/ldapbackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libldapbackend_la_DEPENDENCIES = am_libldapbackend_la_OBJECTS = ldapbackend.lo powerldap.lo libldapbackend_la_OBJECTS = $(am_libldapbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libldapbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libldapbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libldapbackend_la_SOURCES) DIST_SOURCES = $(libldapbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libldapbackend.la libldapbackend_la_SOURCES = ldapbackend.cc ldapbackend.hh powerldap.hh powerldap.cc utils.hh libldapbackend_la_LDFLAGS = -module -avoid-version libldapbackend_la_LIBADD = -l@LIBLDAP@ all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/ldapbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/ldapbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libldapbackend.la: $(libldapbackend_la_OBJECTS) $(libldapbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libldapbackend_la_LINK) -rpath $(libdir) $(libldapbackend_la_OBJECTS) $(libldapbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldapbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/powerldap.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/ldapbackend/powerldap.cc0000644000014601777760000001563712136555572022016 0ustar00jenkinsnogroup00000000000000#include "powerldap.hh" #include #include PowerLDAP::PowerLDAP( const string& hosts, uint16_t port, bool tls ) { d_ld = 0; d_hosts = hosts; d_port = port; d_tls = tls; ensureConnect(); } void PowerLDAP::ensureConnect() { int err; if(d_ld) { ldap_unbind_ext( d_ld, NULL, NULL ); } #ifdef HAVE_LDAP_INITIALIZE if( ( err = ldap_initialize( &d_ld, d_hosts.c_str() ) ) != LDAP_SUCCESS ) { string ldapuris; vector uris; stringtok( uris, d_hosts ); for( size_t i = 0; i < uris.size(); i++ ) { ldapuris += " ldap://" + uris[i]; } if( ( err = ldap_initialize( &d_ld, ldapuris.c_str() ) ) != LDAP_SUCCESS ) { throw LDAPException( "Error initializing LDAP connection to '" + ldapuris + ": " + getError( err ) ); } } #else if( ( d_ld = ldap_init( d_hosts.c_str(), d_port ) ) == NULL ) { throw LDAPException( "Error initializing LDAP connection to '" + d_hosts + "': " + string( strerror( errno ) ) ); } #endif int protocol = LDAP_VERSION3; if( ldap_set_option( d_ld, LDAP_OPT_PROTOCOL_VERSION, &protocol ) != LDAP_OPT_SUCCESS ) { protocol = LDAP_VERSION2; if( ldap_set_option( d_ld, LDAP_OPT_PROTOCOL_VERSION, &protocol ) != LDAP_OPT_SUCCESS ) { ldap_unbind_ext( d_ld, NULL, NULL ); throw LDAPException( "Couldn't set protocol version to LDAPv3 or LDAPv2" ); } } if( d_tls && ( err = ldap_start_tls_s( d_ld, NULL, NULL ) ) != LDAP_SUCCESS ) { ldap_unbind_ext( d_ld, NULL, NULL ); throw LDAPException( "Couldn't perform STARTTLS: " + getError( err ) ); } } PowerLDAP::~PowerLDAP() { ldap_unbind_ext( d_ld, NULL, NULL ); } void PowerLDAP::setOption( int option, int value ) { if( ldap_set_option( d_ld, option, (void*) &value ) != LDAP_OPT_SUCCESS ) { throw( LDAPException( "Unable to set option" ) ); } } void PowerLDAP::getOption( int option, int *value ) { if( ldap_get_option( d_ld, option, (void*) value ) != LDAP_OPT_SUCCESS ) { throw( LDAPException( "Unable to get option" ) ); } } void PowerLDAP::bind( const string& ldapbinddn, const string& ldapsecret, int method, int timeout ) { int msgid; #ifdef HAVE_LDAP_SASL_BIND int rc; struct berval passwd; passwd.bv_val = (char *)ldapsecret.c_str(); passwd.bv_len = strlen( passwd.bv_val ); if( ( rc = ldap_sasl_bind( d_ld, ldapbinddn.c_str(), LDAP_SASL_SIMPLE, &passwd, NULL, NULL, &msgid ) ) != LDAP_SUCCESS ) { throw LDAPException( "Failed to bind to LDAP server: " + getError( rc ) ); } #else if( ( msgid = ldap_bind( d_ld, ldapbinddn.c_str(), ldapsecret.c_str(), method ) ) == -1 ) { throw LDAPException( "Failed to bind to LDAP server: " + getError( msgid ) ); } #endif waitResult( msgid, timeout, NULL ); } /** * Deprecated, use PowerLDAP::bind() instead */ void PowerLDAP::simpleBind( const string& ldapbinddn, const string& ldapsecret ) { this->bind( ldapbinddn, ldapsecret, LDAP_AUTH_SIMPLE, 30 ); } int PowerLDAP::search( const string& base, int scope, const string& filter, const char** attr ) { int msgid, rc; if( ( rc = ldap_search_ext( d_ld, base.c_str(), scope, filter.c_str(), const_cast (attr), 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &msgid ) ) != LDAP_SUCCESS ) { throw LDAPException( "Starting LDAP search: " + getError( rc ) ); } return msgid; } /** * Function waits for a result, returns its type and optionally stores the result. * If the result is returned, the caller is responsible for freeing it with * ldap_msgfree! */ int PowerLDAP::waitResult( int msgid, int timeout, LDAPMessage** result ) { struct timeval tv; LDAPMessage* res; tv.tv_sec = timeout; tv.tv_usec = 0; int rc; rc = ldap_result( d_ld, msgid, LDAP_MSG_ONE, &tv, &res ); switch( rc ) { case -1: ensureConnect(); throw LDAPException( "Error waiting for LDAP result: " + getError() ); case 0: throw LDAPTimeout(); } if( result == NULL ) { ldap_msgfree( res ); return rc; } *result = res; return rc; } bool PowerLDAP::getSearchEntry( int msgid, sentry_t& entry, bool dn, int timeout ) { int i; char* attr; BerElement* ber; struct berval** berval; vector values; LDAPMessage* result; LDAPMessage* object; if( ( i = waitResult( msgid, timeout, &result ) ) == LDAP_RES_SEARCH_RESULT ) { ldap_msgfree( result ); return false; } if( i != LDAP_RES_SEARCH_ENTRY ) { ldap_msgfree( result ); throw LDAPException( "Search returned an unexpected result" ); } if( ( object = ldap_first_entry( d_ld, result ) ) == NULL ) { ldap_msgfree( result ); throw LDAPException( "Couldn't get first result entry: " + getError() ); } entry.clear(); if( dn ) { attr = ldap_get_dn( d_ld, object ); values.push_back( string( attr ) ); ldap_memfree( attr ); entry["dn"] = values; } if( ( attr = ldap_first_attribute( d_ld, object, &ber ) ) != NULL ) { do { if( ( berval = ldap_get_values_len( d_ld, object, attr ) ) != NULL ) { values.clear(); for( i = 0; i < ldap_count_values_len( berval ); i++ ) { values.push_back( berval[i]->bv_val ); // use berval[i]->bv_len for non string values? } entry[attr] = values; ldap_value_free_len( berval ); } ldap_memfree( attr ); } while( ( attr = ldap_next_attribute( d_ld, object, ber ) ) != NULL ); ber_free( ber, 0 ); } ldap_msgfree( result ); return true; } void PowerLDAP::getSearchResults( int msgid, sresult_t& result, bool dn, int timeout ) { sentry_t entry; result.clear(); while( getSearchEntry( msgid, entry, dn, timeout ) ) { result.push_back( entry ); } } const string PowerLDAP::getError( int rc ) { if( rc == -1 ) { getOption( LDAP_OPT_ERROR_NUMBER, &rc ); } return string( ldap_err2string( rc ) );; } const string PowerLDAP::escape( const string& str ) { string a; string::const_iterator i; for( i = str.begin(); i != str.end(); i++ ) { if( *i == '*' || *i == '\\' ) { a += '\\'; } a += *i; } return a; } pdns-3.3/modules/ldapbackend/ldapbackend.hh0000644000014601777760000000731412136555572022254 0ustar00jenkinsnogroup00000000000000/* * PowerDNS LDAP Backend * Copyright (C) 2003-2007 Norbert Sendetzky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "powerldap.hh" #include "utils.hh" #ifdef HAVE_CONFIG_H #include #endif #ifndef LDAPBACKEND_HH #define LDAPBACKEND_HH using std::string; using std::vector; /* * Known DNS RR types * Types which aren't active are currently not supported by PDNS */ static const char* ldap_attrany[] = { "associatedDomain", "dNSTTL", "aRecord", "nSRecord", "cNAMERecord", "sOARecord", "pTRRecord", "hInfoRecord", "mXRecord", "tXTRecord", "rPRecord", "aFSDBRecord", // "SigRecord", "KeyRecord", // "gPosRecord", "aAAARecord", "lOCRecord", "sRVRecord", "nAPTRRecord", "kXRecord", "certRecord", // "a6Record", // "dNameRecord", // "aPLRecord", "dSRecord", "sSHFPRecord", "iPSecKeyRecord", "rRSIGRecord", "nSECRecord", "dNSKeyRecord", "dHCIDRecord", "sPFRecord", "modifyTimestamp", NULL }; class LdapBackend : public DNSBackend { bool m_getdn; bool m_qlog; int m_msgid; uint32_t m_ttl; uint32_t m_default_ttl; unsigned int m_axfrqlen; time_t m_last_modified; string m_myname; string m_qname; PowerLDAP* m_pldap; PowerLDAP::sentry_t m_result; PowerLDAP::sentry_t::iterator m_attribute; vector::iterator m_value, m_adomain; vector m_adomains; bool (LdapBackend::*m_list_fcnt)( const string&, int ); void (LdapBackend::*m_lookup_fcnt)( const QType&, const string&, DNSPacket*, int ); bool (LdapBackend::*m_prepare_fcnt)(); bool list_simple( const string& target, int domain_id ); bool list_strict( const string& target, int domain_id ); void lookup_simple( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); void lookup_strict( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); void lookup_tree( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); bool prepare(); bool prepare_simple(); bool prepare_strict(); bool getDomainInfo( const string& domain, DomainInfo& di ); public: LdapBackend( const string &suffix="" ); ~LdapBackend(); bool list( const string& target, int domain_id ); void lookup( const QType& qtype, const string& qdomain, DNSPacket* p = 0, int zoneid = -1 ); bool get( DNSResourceRecord& rr ); }; #endif /* LDAPBACKEND_HH */ pdns-3.3/modules/ldapbackend/Makefile.am0000644000014601777760000000043112136555572021530 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libldapbackend.la libldapbackend_la_SOURCES = ldapbackend.cc ldapbackend.hh powerldap.hh powerldap.cc utils.hh libldapbackend_la_LDFLAGS =-module -avoid-version libldapbackend_la_LIBADD =-l@LIBLDAP@ pdns-3.3/modules/ldapbackend/powerldap.hh0000644000014601777760000000502112136555572022012 0ustar00jenkinsnogroup00000000000000/* * PowerDNS LDAP Connector * By PowerDNS.COM BV * By Norbert Sendetzky (2003-2007) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #ifdef HAVE_CONFIG_H #include #endif #ifndef POWERLDAP_HH #define POWERLDAP_HH using std::map; using std::string; using std::vector; class LDAPException : public std::runtime_error { public: explicit LDAPException( const string &str ) : std::runtime_error( str ) {} }; class LDAPTimeout : public LDAPException { public: explicit LDAPTimeout() : LDAPException( "Timeout" ) {} }; class PowerLDAP { LDAP* d_ld; string d_hosts; int d_port; bool d_tls; const string getError( int rc = -1 ); int waitResult( int msgid = LDAP_RES_ANY, int timeout = 0, LDAPMessage** result = NULL ); void ensureConnect(); public: typedef map > sentry_t; typedef vector sresult_t; PowerLDAP( const string& hosts = "ldap://127.0.0.1/", uint16_t port = LDAP_PORT, bool tls = false ); ~PowerLDAP(); void getOption( int option, int* value ); void setOption( int option, int value ); void bind( const string& ldapbinddn = "", const string& ldapsecret = "", int method = LDAP_AUTH_SIMPLE, int timeout = 5 ); void simpleBind( const string& ldapbinddn = "", const string& ldapsecret = "" ); int search( const string& base, int scope, const string& filter, const char** attr = 0 ); bool getSearchEntry( int msgid, sentry_t& entry, bool dn = false, int timeout = 5 ); void getSearchResults( int msgid, sresult_t& result, bool dn = false, int timeout = 5 ); static const string escape( const string& tobe ); }; #endif pdns-3.3/modules/remotebackend/0000755000014601777760000000000012165464054020045 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/remotebackend/pipeconnector.cc0000644000014601777760000000430712136555572023234 0ustar00jenkinsnogroup00000000000000#include "remotebackend.hh" PipeConnector::PipeConnector(std::map options) { if (options.count("command") == 0) { L<command = options.find("command")->second; this->options = options; this->coproc = NULL; launch(); } PipeConnector::~PipeConnector(){ if (this->coproc != NULL) delete coproc; } void PipeConnector::launch() { if (coproc != NULL) return; rapidjson::Value val; rapidjson::Document init,res; int timeout=2000; if (options.find("timeout") != options.end()) { timeout = boost::lexical_cast(options.find("timeout")->second); } coproc = new CoProcess(this->command, timeout); init.SetObject(); val = "initialize"; init.AddMember("method",val, init.GetAllocator()); val.SetObject(); init.AddMember("parameters", val, init.GetAllocator()); for(std::map::iterator i = options.begin(); i != options.end(); i++) { val = i->second.c_str(); init["parameters"].AddMember(i->first.c_str(), val, init.GetAllocator()); } this->send(init); if (this->recv(res)==false) { L<send(data); return 1; } catch(AhuException &ae) { delete coproc; coproc=NULL; throw; } } int PipeConnector::recv_message(rapidjson::Document &output) { rapidjson::GenericReader , rapidjson::MemoryPoolAllocator<> > r; std::string tmp; std::string s_output; launch(); try { while(1) { coproc->receive(tmp); s_output.append(tmp); rapidjson::StringStream ss(s_output.c_str()); output.ParseStream<0>(ss); if (output.HasParseError() == false) return s_output.size(); } } catch(AhuException &ae) { L< #include #include #include #include #include #include #include #include #include #include "pdns/json.hh" #include "pdns/statbag.hh" #include "pdns/packetcache.hh" StatBag S; PacketCache PC; ArgvMap &arg() { static ArgvMap arg; return arg; }; class RemoteLoader { public: RemoteLoader(); }; DNSBackend *be; #ifdef REMOTEBACKEND_HTTP #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE unit #include #include #include #include struct RemotebackendSetup { RemotebackendSetup() { be = 0; try { // setup minimum arguments ::arg().set("module-dir")=""; new RemoteLoader(); BackendMakers().launch("remote"); // then get us a instance of it ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; } catch (AhuException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } ~RemotebackendSetup() { } }; BOOST_GLOBAL_FIXTURE( RemotebackendSetup ); #else #include int main(void) { std::cout << "No HTTP support in remotebackend - skipping test" << std::endl; return 0; } #endif pdns-3.3/modules/remotebackend/OBJECTLIBS0000644000014601777760000000000012136555572021402 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/remotebackend/remotebackend.cc0000644000014601777760000010241512165250627023161 0ustar00jenkinsnogroup00000000000000#include "remotebackend.hh" #include static const char *kBackendId = "[RemoteBackend]"; /** * Forwarder for value. This is just in case * we need to do some treatment to the value before * sending it downwards. */ bool Connector::send(rapidjson::Document &value) { return send_message(value); } /** * Helper for handling receiving of data. * Basically what happens here is that we check * that the receiving happened ok, and extract * result. Logging is performed here, too. */ bool Connector::recv(rapidjson::Document &value) { if (recv_message(value)>0) { bool rv = true; // check for error if (!value.HasMember("result")) { return false; } if (!value["result"].IsObject() && getBool(value["result"]) == false) { rv = false; } if (value.HasMember("log")) { rapidjson::Value& messages = value["log"]; if (messages.IsArray()) { // log em all for (rapidjson::Value::ValueIterator iter = messages.Begin(); iter != messages.End(); ++iter) L<d_result = NULL; this->d_dnssec = mustDo("dnssec"); this->d_index = -1; this->d_trxid = 0; } RemoteBackend::~RemoteBackend() { if (connector != NULL) { delete connector; } } /** * Builds connector based on options * Currently supports unix,pipe and http */ int RemoteBackend::build(const std::string &connstr) { std::vector parts; std::string type; std::string opts; std::map options; // connstr is of format "type:options" size_t pos; pos = connstr.find_first_of(":"); if (pos == std::string::npos) throw AhuException("Invalid connection string: malformed"); type = connstr.substr(0, pos); opts = connstr.substr(pos+1); // tokenize the string on comma stringtok(parts, opts, ","); // find out some options and parse them while we're at it BOOST_FOREACH(std::string opt, parts) { std::string key,val; // make sure there is something else than air in the option... if (opt.find_first_not_of(" ") == std::string::npos) continue; // split it on '='. if not found, we treat it as "yes" pos = opt.find_first_of("="); if (pos == std::string::npos) { key = opt; val = "yes"; } else { key = opt.substr(0,pos); val = opt.substr(pos+1); } options[key] = val; } // connectors know what they are doing if (type == "unix") { this->connector = new UnixsocketConnector(options); } else if (type == "http") { #ifdef REMOTEBACKEND_HTTP this->connector = new HTTPConnector(options); #else throw AhuException("Invalid connection string: http connector support not enabled. Recompile with --enable-remotebackend-http"); #endif } else if (type == "pipe") { this->connector = new PipeConnector(options); } else { throw AhuException("Invalid connection string: unknown connector"); } return -1; } /** * The functions here are just remote json stubs that send and receive the method call * data is mainly left alone, some defaults are assumed. */ void RemoteBackend::lookup(const QType &qtype, const std::string &qdomain, DNSPacket *pkt_p, int zoneId) { rapidjson::Document query; rapidjson::Value parameters; if (d_index != -1) throw AhuException("Attempt to lookup while one running"); query.SetObject(); JSON_ADD_MEMBER(query, "method", "lookup", query.GetAllocator()) parameters.SetObject(); JSON_ADD_MEMBER(parameters, "qtype", qtype.getName().c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "qname", qdomain.c_str(), query.GetAllocator()); string localIP="0.0.0.0"; string remoteIP="0.0.0.0"; string realRemote="0.0.0.0/0"; if (pkt_p) { localIP=pkt_p->getLocal(); realRemote = pkt_p->getRealRemote().toString(); remoteIP = pkt_p->getRemote(); } JSON_ADD_MEMBER(parameters, "remote", remoteIP.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "local", localIP.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "real-remote", realRemote.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "zone-id", zoneId, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); d_result = new rapidjson::Document(); if (connector->send(query) == false || connector->recv(*d_result) == false) { delete d_result; return; } // OK. we have result parameters in result if ((*d_result)["result"].IsArray() == false) { delete d_result; return; } d_index = 0; } bool RemoteBackend::list(const std::string &target, int domain_id) { rapidjson::Document query; rapidjson::Value parameters; if (d_index != -1) throw AhuException("Attempt to lookup while one running"); query.SetObject(); JSON_ADD_MEMBER(query, "method", "list", query.GetAllocator()); query["method"] = "list"; parameters.SetObject(); JSON_ADD_MEMBER(parameters, "zonename", target.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "domain-id", domain_id, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); d_result = new rapidjson::Document(); if (connector->send(query) == false || connector->recv(*d_result) == false) { delete d_result; return false; } if ((*d_result)["result"].IsArray() == false) { delete d_result; return false; } d_index = 0; return true; } bool RemoteBackend::get(DNSResourceRecord &rr) { if (d_index == -1) return false; rapidjson::Value value; value = ""; rr.qtype = getString(JSON_GET((*d_result)["result"][d_index], "qtype", value)); rr.qname = getString(JSON_GET((*d_result)["result"][d_index], "qname", value)); rr.qclass = QClass::IN; rr.content = getString(JSON_GET((*d_result)["result"][d_index], "content",value)); value = -1; rr.ttl = getInt(JSON_GET((*d_result)["result"][d_index], "ttl",value)); rr.domain_id = getInt(JSON_GET((*d_result)["result"][d_index],"domain_id",value)); rr.priority = getInt(JSON_GET((*d_result)["result"][d_index],"priority",value)); value = 1; if (d_dnssec) rr.auth = getInt(JSON_GET((*d_result)["result"][d_index],"auth", value)); else rr.auth = 1; value = 0; rr.scopeMask = getInt(JSON_GET((*d_result)["result"][d_index],"scopeMask", value)); d_index++; // id index is out of bounds, we know the results end here. if (d_index == static_cast((*d_result)["result"].Size())) { delete d_result; d_result = NULL; d_index = -1; } return true; } bool RemoteBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "getBeforeAndAfterNamesAbsolute", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "id", id, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "qname", qname.c_str(), query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; unhashed = getString(answer["result"]["unhashed"]); before = getString(answer["result"]["before"]); after = getString(answer["result"]["after"]); return true; } bool RemoteBackend::getDomainMetadata(const std::string& name, const std::string& kind, std::vector& meta) { rapidjson::Document query,answer; rapidjson::Value parameters; query.SetObject(); JSON_ADD_MEMBER(query, "method", "getDomainMetadata", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "kind", kind.c_str(), query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false) return false; meta.clear(); // not mandatory to implement if (connector->recv(answer) == false) return true; if (answer["result"].IsArray()) { for(rapidjson::Value::ValueIterator iter = answer["result"].Begin(); iter != answer["result"].End(); iter++) { meta.push_back(getString(*iter)); } } else if (answer["result"].IsString()) { meta.push_back(answer["result"].GetString()); } return true; } bool RemoteBackend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { rapidjson::Document query,answer; rapidjson::Value parameters,val; query.SetObject(); JSON_ADD_MEMBER(query, "method", "setDomainMetadata", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "kind", kind.c_str(), query.GetAllocator()); val.SetArray(); BOOST_FOREACH(std::string value, meta) { val.PushBack(value.c_str(), query.GetAllocator()); } parameters.AddMember("value", val, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return getBool(answer["result"]); } bool RemoteBackend::getDomainKeys(const std::string& name, unsigned int kind, std::vector& keys) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "getDomainKeys", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "kind", kind, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; keys.clear(); for(rapidjson::Value::ValueIterator iter = answer["result"].Begin(); iter != answer["result"].End(); iter++) { DNSBackend::KeyData key; key.id = getUInt((*iter)["id"]); key.flags = getUInt((*iter)["flags"]); key.active = getBool((*iter)["active"]); key.content = getString((*iter)["content"]); keys.push_back(key); } return true; } bool RemoteBackend::removeDomainKey(const string& name, unsigned int id) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "removeDomainKey", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "id", id, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } int RemoteBackend::addDomainKey(const string& name, const KeyData& key) { rapidjson::Document query,answer; rapidjson::Value parameters,jkey; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "addDomainKey", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); jkey.SetObject(); JSON_ADD_MEMBER(jkey, "flags", key.flags, query.GetAllocator()); JSON_ADD_MEMBER(jkey, "active", key.active, query.GetAllocator()); JSON_ADD_MEMBER(jkey, "content", key.content.c_str(), query.GetAllocator()); parameters.AddMember("key", jkey, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return getInt(answer["result"]); } bool RemoteBackend::activateDomainKey(const string& name, unsigned int id) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "activateDomainKey", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "id", id, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::deactivateDomainKey(const string& name, unsigned int id) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "deactivateDomainKey", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "id", id, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::doesDNSSEC() { return d_dnssec; } bool RemoteBackend::getTSIGKey(const std::string& name, std::string* algorithm, std::string* content) { rapidjson::Document query,answer; rapidjson::Value parameters; // no point doing dnssec if it's not supported if (d_dnssec == false) return false; query.SetObject(); JSON_ADD_MEMBER(query, "method", "getTSIGKey", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", name.c_str(), query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; if (algorithm != NULL) algorithm->assign(getString(answer["result"]["algorithm"])); if (content != NULL) content->assign(getString(answer["result"]["content"])); return true; } bool RemoteBackend::getDomainInfo(const string &domain, DomainInfo &di) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value value; std::string kind; query.SetObject(); JSON_ADD_MEMBER(query, "method", "getDomainInfo", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "name", domain.c_str(), query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; // make sure we got zone & kind if (!answer["result"].HasMember("zone")) { L<send(query) == false || connector->recv(answer) == false) { L<&nsset, string *account, DNSBackend **ddb) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value rrset; query.SetObject(); JSON_ADD_MEMBER(query, "method", "superMasterBackend", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "ip", ip.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "domain", domain.c_str(), query.GetAllocator()); rrset.SetArray(); rrset.Reserve(nsset.size(), query.GetAllocator()); for(rapidjson::SizeType i = 0; i < nsset.size(); i++) { rapidjson::Value rr; rr.SetObject(); JSON_ADD_MEMBER(rr, "qtype", nsset[i].qtype.getName().c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "qname", nsset[i].qname.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rr, "content", nsset[i].content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "ttl", nsset[i].ttl, query.GetAllocator()); JSON_ADD_MEMBER(rr, "priority", nsset[i].priority, query.GetAllocator()); JSON_ADD_MEMBER(rr, "auth", nsset[i].auth, query.GetAllocator()); rrset.PushBack(rr, query.GetAllocator()); } parameters.AddMember("nsset", rrset, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); *ddb = 0; if (connector->send(query) == false || connector->recv(answer) == false) return false; // we are the backend *ddb = this; // we allow simple true as well... if (answer["result"].IsObject() && answer["result"].HasMember("account")) *account = getString(answer["result"]["account"]); return true; } bool RemoteBackend::createSlaveDomain(const string &ip, const string &domain, const string &account) { rapidjson::Document query,answer; rapidjson::Value parameters; query.SetObject(); JSON_ADD_MEMBER(query, "method", "createSlaveDomain", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "ip", ip.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "domain", domain.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "account", account.c_str(), query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QType& qtype, const vector& rrset) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value rj_rrset; query.SetObject(); JSON_ADD_MEMBER(query, "method", "replaceRRSet", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "domain_id", domain_id, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "qname", qname.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "qtype", qtype.getName().c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); rj_rrset.SetArray(); rj_rrset.Reserve(rrset.size(), query.GetAllocator()); for(rapidjson::SizeType i = 0; i < rrset.size(); i++) { rapidjson::Value rr; rr.SetObject(); JSON_ADD_MEMBER(rr, "qtype", rrset[i].qtype.getName().c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "qname", rrset[i].qname.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rr, "content", rrset[i].content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "ttl", rrset[i].ttl, query.GetAllocator()); JSON_ADD_MEMBER(rr, "priority", rrset[i].priority, query.GetAllocator()); JSON_ADD_MEMBER(rr, "auth", rrset[i].auth, query.GetAllocator()); rj_rrset.PushBack(rr, query.GetAllocator()); } parameters.AddMember("rrset", rj_rrset, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::feedRecord(const DNSResourceRecord &rr, string *ordername) { rapidjson::Document query,answer; rapidjson::Value parameters,rj_rr; query.SetObject(); JSON_ADD_MEMBER(query, "method", "feedRecord", query.GetAllocator()); parameters.SetObject(); rj_rr.SetObject(); JSON_ADD_MEMBER(rj_rr, "qtype", rr.qtype.getName().c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "qname", rr.qname.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "content", rr.content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "ttl", rr.ttl, query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "priority", rr.priority, query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "auth", rr.auth, query.GetAllocator()); parameters.AddMember("rr", rj_rr, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); if (ordername) { JSON_ADD_MEMBER(parameters, "ordername", ordername->c_str(), query.GetAllocator()); } query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; // XXX FIXME this API should not return 'true' I think -ahu } bool RemoteBackend::feedEnts(int domain_id, set& nonterm) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value nts; query.SetObject(); JSON_ADD_MEMBER(query, "method", "feedEnts", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "domain_id", domain_id, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); nts.SetArray(); BOOST_FOREACH(const string &t, nonterm) { nts.PushBack(t.c_str(), query.GetAllocator()); } parameters.AddMember("nonterm", nts, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::feedEnts3(int domain_id, const string &domain, set &nonterm, unsigned int times, const string &salt, bool narrow) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value nts; query.SetObject(); JSON_ADD_MEMBER(query, "method", "feedEnts3", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "domain_id", domain_id, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "domain", domain.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "times", times, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "salt", salt.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "narrow", narrow, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); nts.SetArray(); BOOST_FOREACH(const string &t, nonterm) { nts.PushBack(t.c_str(), query.GetAllocator()); } parameters.AddMember("nonterm", nts, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::startTransaction(const string &domain, int domain_id) { rapidjson::Document query,answer; rapidjson::Value parameters; this->d_trxid = time((time_t*)NULL); query.SetObject(); JSON_ADD_MEMBER(query, "method", "startTransaction", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "domain", domain.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(parameters, "domain_id", domain_id, query.GetAllocator()); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) { d_trxid = -1; return false; } return true; } bool RemoteBackend::commitTransaction() { rapidjson::Document query,answer; rapidjson::Value parameters; query.SetObject(); JSON_ADD_MEMBER(query, "method", "abortTransaction", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); d_trxid = -1; if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::abortTransaction() { rapidjson::Document query,answer; rapidjson::Value parameters; query.SetObject(); JSON_ADD_MEMBER(query, "method", "commitTransaction", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "trxid", d_trxid, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); d_trxid = -1; if (connector->send(query) == false || connector->recv(answer) == false) return false; return true; } bool RemoteBackend::calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial) { rapidjson::Document query,answer; rapidjson::Value parameters; rapidjson::Value soadata; query.SetObject(); JSON_ADD_MEMBER(query, "method", "calculateSOASerial", query.GetAllocator()); parameters.SetObject(); JSON_ADD_MEMBER(parameters, "domain", domain.c_str(), query.GetAllocator()); soadata.SetObject(); JSON_ADD_MEMBER(soadata, "qname", sd.qname.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(soadata, "nameserver", sd.nameserver.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(soadata, "hostmaster", sd.hostmaster.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(soadata, "ttl", sd.ttl, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "serial", sd.serial, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "refresh", sd.refresh, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "retry", sd.retry, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "expire", sd.expire, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "default_ttl", sd.default_ttl, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "domain_id", sd.domain_id, query.GetAllocator()); JSON_ADD_MEMBER(soadata, "scopeMask", sd.scopeMask, query.GetAllocator()); parameters.AddMember("sd", soadata, query.GetAllocator()); query.AddMember("parameters", parameters, query.GetAllocator()); if (connector->send(query) == false || connector->recv(answer) == false) return false; serial = getInt64(answer["result"]); return true; } // some rapidjson helpers bool RemoteBackend::getBool(rapidjson::Value &value) { if (value.IsNull()) return false; if (value.IsBool()) return value.GetBool(); if (value.IsInt()) return value.GetInt() != 0; // 0 = false, non-zero true if (value.IsDouble()) return value.GetDouble() != 0; // 0 = false, non-zero true if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); if (boost::iequals(tmp, "1") || boost::iequals(tmp, "true")) return true; if (boost::iequals(tmp, "0") || boost::iequals(tmp, "false")) return false; } std::cerr << value.GetType() << endl; throw new AhuException("Cannot convert rapidjson value into boolean"); } bool Connector::getBool(rapidjson::Value &value) { if (value.IsNull()) return false; if (value.IsBool()) return value.GetBool(); if (value.IsInt()) return value.GetInt() != 0; // 0 = false, non-zero true if (value.IsDouble()) return value.GetDouble() != 0; // 0 = false, non-zero true if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); if (boost::iequals(tmp, "1") || boost::iequals(tmp, "true")) return true; if (boost::iequals(tmp, "0") || boost::iequals(tmp, "false")) return false; } // this is specific for Connector! return true; } std::string Connector::getString(rapidjson::Value &value) { if (value.IsString()) return value.GetString(); if (value.IsBool()) return (value.GetBool() ? "true" : "false"); if (value.IsInt64()) return boost::lexical_cast(value.GetInt64()); if (value.IsInt()) return boost::lexical_cast(value.GetInt()); if (value.IsDouble()) return boost::lexical_cast(value.GetDouble()); return "(unpresentable value)"; // cannot convert into presentation format } int RemoteBackend::getInt(rapidjson::Value &value) { if (value.IsInt()) return value.GetInt(); if (value.IsBool()) return (value.GetBool() ? 1 : 0); if (value.IsUint()) return static_cast(value.GetUint()); if (value.IsDouble()) return static_cast(value.GetDouble()); if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } throw new AhuException("Cannot convert rapidjson value into integer"); } unsigned int RemoteBackend::getUInt(rapidjson::Value &value) { if (value.IsUint()) return value.GetUint(); if (value.IsBool()) return (value.GetBool() ? 1 : 0); if (value.IsInt()) return static_cast(value.GetInt()); if (value.IsDouble()) return static_cast(value.GetDouble()); if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } throw new AhuException("Cannot convert rapidjson value into integer"); } int64_t RemoteBackend::getInt64(rapidjson::Value &value) { if (value.IsInt64()) return value.GetInt64(); if (value.IsBool()) return (value.GetBool() ? 1 : 0); if (value.IsInt()) return value.GetInt(); if (value.IsDouble()) return static_cast(value.GetDouble()); if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } throw new AhuException("Cannot convert rapidjson value into integer"); } std::string RemoteBackend::getString(rapidjson::Value &value) { if (value.IsString()) return value.GetString(); if (value.IsBool()) return (value.GetBool() ? "true" : "false"); if (value.IsInt64()) return boost::lexical_cast(value.GetInt64()); if (value.IsInt()) return boost::lexical_cast(value.GetInt()); if (value.IsDouble()) return boost::lexical_cast(value.GetDouble()); throw new AhuException("Cannot convert rapidjson value into std::string"); } double RemoteBackend::getDouble(rapidjson::Value &value) { if (value.IsDouble()) return value.GetDouble(); if (value.IsBool()) return (value.GetBool() ? 1.0L : 0.0L); if (value.IsInt64()) return static_cast(value.GetInt64()); if (value.IsInt()) return static_cast(value.GetInt()); if (value.IsString()) { // accepts 0, 1, false, true std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } throw new AhuException("Cannot convert rapidjson value into double"); } DNSBackend *RemoteBackend::maker() { try { return new RemoteBackend(); } catch(...) { L< #include #include #include #ifndef UNIX_PATH_MAX #define UNIX_PATH_MAX 108 #endif UnixsocketConnector::UnixsocketConnector(std::map options) { if (options.count("path") == 0) { L<timeout = 2000; if (options.find("timeout") != options.end()) { this->timeout = boost::lexical_cast(options.find("timeout")->second); } this->path = options.find("path")->second; this->options = options; this->connected = false; } UnixsocketConnector::~UnixsocketConnector() { if (this->connected) { L<write(data); if (rv == -1) return -1; return rv; } int UnixsocketConnector::recv_message(rapidjson::Document &output) { int rv,nread; std::string s_output; rapidjson::GenericReader , rapidjson::MemoryPoolAllocator<> > r; struct timeval t0,t; nread = 0; gettimeofday(&t0, NULL); memcpy(&t,&t0,sizeof(t0)); s_output = ""; while((t.tv_sec - t0.tv_sec)*1000 + (t.tv_usec - t0.tv_usec)/1000 < this->timeout) { std::string temp; temp.clear(); rv = this->read(temp); if (rv == -1) return -1; if (rv>0) { nread += rv; s_output.append(temp); rapidjson::StringStream ss(s_output.c_str()); output.ParseStream<0>(ss); if (output.HasParseError() == false) return s_output.size(); } gettimeofday(&t, NULL); } return -1; } ssize_t UnixsocketConnector::read(std::string &data) { ssize_t nread; char buf[1500] = {0}; reconnect(); if (!connected) return -1; nread = ::read(this->fd, buf, sizeof buf); // just try again later... if (nread==-1 && errno == EAGAIN) return 0; if (nread==-1) { connected = false; close(fd); return -1; } data.append(buf, nread); return nread; } ssize_t UnixsocketConnector::write(const std::string &data) { ssize_t nwrite, nbuf; size_t pos; char buf[1500]; reconnect(); if (!connected) return -1; pos = 0; nwrite = 0; while(pos < data.size()) { nbuf = data.copy(buf, sizeof buf, pos); // copy data and write nwrite = ::write(fd, buf, nbuf); pos = pos + sizeof(buf); if (nwrite == -1) { connected = false; close(fd); return -1; } } return nwrite; } void UnixsocketConnector::reconnect() { struct sockaddr_un sock; rapidjson::Document init,res; rapidjson::Value val; if (connected) return; // no point reconnecting if connected... connected = true; L<(&sock), sizeof sock)==-1 && (errno == EINPROGRESS)) { waitForData(fd, 0, 500); } if (errno != EISCONN && errno != 0) { L<::iterator i = options.begin(); i != options.end(); i++) { val = i->second.c_str(); init["parameters"].AddMember(i->first.c_str(), val, init.GetAllocator()); } this->send_message(init); if (this->recv_message(res) == false) { L<connected = false; } } pdns-3.3/modules/remotebackend/OBJECTFILES0000644000014601777760000000010012136555572021514 0ustar00jenkinsnogroup00000000000000remotebackend.o unixconnector.o httpconnector.o pipeconnector.o pdns-3.3/modules/remotebackend/remotebackend.hh0000644000014601777760000001312012164346626023171 0ustar00jenkinsnogroup00000000000000#ifndef REMOTEBACKEND_REMOTEBACKEND_HH #include #include #include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include #include #include #include "../pipebackend/coprocess.hh" #include "pdns/json.hh" #ifdef REMOTEBACKEND_HTTP #include #endif #define JSON_GET(obj,val,def) (obj.HasMember(val)?obj["" val ""]:def) #define JSON_ADD_MEMBER(obj, name, val, alloc) { rapidjson::Value __xval; __xval = val; obj.AddMember(name, __xval, alloc); } class Connector { public: virtual ~Connector() {}; bool send(rapidjson::Document &value); bool recv(rapidjson::Document &value); virtual int send_message(const rapidjson::Document &input) = 0; virtual int recv_message(rapidjson::Document &output) = 0; protected: bool getBool(rapidjson::Value &value); std::string getString(rapidjson::Value &value); }; // fwd declarations class UnixsocketConnector: public Connector { public: UnixsocketConnector(std::map options); virtual ~UnixsocketConnector(); virtual int send_message(const rapidjson::Document &input); virtual int recv_message(rapidjson::Document &output); private: ssize_t read(std::string &data); ssize_t write(const std::string &data); void reconnect(); std::map options; int fd; std::string path; bool connected; int timeout; }; #ifdef REMOTEBACKEND_HTTP class HTTPConnector: public Connector { public: HTTPConnector(std::map options); ~HTTPConnector(); virtual int send_message(const rapidjson::Document &input); virtual int recv_message(rapidjson::Document &output); friend size_t httpconnector_write_data(void*, size_t, size_t, void *value); private: std::string d_url; std::string d_url_suffix; CURL *d_c; std::string d_data; int timeout; bool d_post; bool d_post_json; std::string d_capath; std::string d_cafile; bool json2string(const rapidjson::Value &input, std::string &output); void restful_requestbuilder(const std::string &method, const rapidjson::Value ¶meters, struct curl_slist **slist); void post_requestbuilder(const rapidjson::Document &input, struct curl_slist **slist); void addUrlComponent(const rapidjson::Value ¶meters, const char *element, std::stringstream& ss); }; #endif class PipeConnector: public Connector { public: PipeConnector(std::map options); ~PipeConnector(); virtual int send_message(const rapidjson::Document &input); virtual int recv_message(rapidjson::Document &output); private: void launch(); CoProcess *coproc; std::string command; std::map options; }; class RemoteBackend : public DNSBackend { public: RemoteBackend(const std::string &suffix=""); ~RemoteBackend(); void lookup(const QType &qtype, const std::string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1); bool get(DNSResourceRecord &rr); bool list(const std::string &target, int domain_id); virtual bool getDomainMetadata(const std::string& name, const std::string& kind, std::vector& meta); virtual bool getDomainKeys(const std::string& name, unsigned int kind, std::vector& keys); virtual bool getTSIGKey(const std::string& name, std::string* algorithm, std::string* content); virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); virtual bool setDomainMetadata(const string& name, const string& kind, const std::vector >& meta); virtual bool removeDomainKey(const string& name, unsigned int id); virtual int addDomainKey(const string& name, const KeyData& key); virtual bool activateDomainKey(const string& name, unsigned int id); virtual bool deactivateDomainKey(const string& name, unsigned int id); virtual bool getDomainInfo(const string&, DomainInfo&); virtual void setNotified(uint32_t id, uint32_t serial); virtual bool doesDNSSEC(); virtual bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **ddb); virtual bool createSlaveDomain(const string &ip, const string &domain, const string &account); virtual bool replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector& rrset); virtual bool feedRecord(const DNSResourceRecord &r, string *ordername); virtual bool feedEnts(int domain_id, set& nonterm); virtual bool feedEnts3(int domain_id, const string &domain, set &nonterm, unsigned int times, const string &salt, bool narrow); virtual bool startTransaction(const string &domain, int domain_id); virtual bool commitTransaction(); virtual bool abortTransaction(); virtual bool calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial); static DNSBackend *maker(); private: int build(const std::string &connstr); Connector *connector; bool d_dnssec; rapidjson::Document *d_result; int d_index; int64_t d_trxid; bool getBool(rapidjson::Value &value); int getInt(rapidjson::Value &value); unsigned int getUInt(rapidjson::Value &value); int64_t getInt64(rapidjson::Value &value); std::string getString(rapidjson::Value &value); double getDouble(rapidjson::Value &value); }; #endif pdns-3.3/modules/remotebackend/Makefile.in0000644000014601777760000031430412165464027022117 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ EXTRA_PROGRAMS = test_remotebackend_pipe$(EXEEXT) \ test_remotebackend_http$(EXEEXT) \ test_remotebackend_post$(EXEEXT) \ test_remotebackend_json$(EXEEXT) TESTS = test_remotebackend_pipe$(EXEEXT) \ test_remotebackend_http$(EXEEXT) \ test_remotebackend_post$(EXEEXT) \ test_remotebackend_json$(EXEEXT) subdir = modules/remotebackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libremotebackend_la_LIBADD = am_libremotebackend_la_OBJECTS = remotebackend.lo unixconnector.lo \ httpconnector.lo pipeconnector.lo libremotebackend_la_OBJECTS = $(am_libremotebackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libremotebackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libremotebackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ libtestremotebackend_la_LIBADD = am_libtestremotebackend_la_OBJECTS = \ libtestremotebackend_la-dnsbackend.lo \ libtestremotebackend_la-ueberbackend.lo \ libtestremotebackend_la-nameserver.lo \ libtestremotebackend_la-misc.lo \ libtestremotebackend_la-unix_utility.lo \ libtestremotebackend_la-logger.lo \ libtestremotebackend_la-statbag.lo \ libtestremotebackend_la-arguments.lo \ libtestremotebackend_la-qtype.lo \ libtestremotebackend_la-dnspacket.lo \ libtestremotebackend_la-dnswriter.lo \ libtestremotebackend_la-base64.lo \ libtestremotebackend_la-base32.lo \ libtestremotebackend_la-dnsrecords.lo \ libtestremotebackend_la-dnslabeltext.lo \ libtestremotebackend_la-dnsparser.lo \ libtestremotebackend_la-rcpgenerator.lo \ libtestremotebackend_la-ednssubnet.lo \ libtestremotebackend_la-nsecrecords.lo \ libtestremotebackend_la-sillyrecords.lo \ libtestremotebackend_la-dnssecinfra.lo \ libtestremotebackend_la-dns_random.lo \ libtestremotebackend_la-packetcache.lo \ libtestremotebackend_la-dns.lo libtestremotebackend_la-json.lo \ libtestremotebackend_la-aescrypt.lo \ libtestremotebackend_la-aeskey.lo \ libtestremotebackend_la-aes_modes.lo \ libtestremotebackend_la-aestab.lo \ libtestremotebackend_la-coprocess.lo \ libtestremotebackend_la-remotebackend.lo \ libtestremotebackend_la-unixconnector.lo \ libtestremotebackend_la-httpconnector.lo \ libtestremotebackend_la-pipeconnector.lo libtestremotebackend_la_OBJECTS = \ $(am_libtestremotebackend_la_OBJECTS) libtestremotebackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_remotebackend_http_OBJECTS = \ test_remotebackend_http-test-remotebackend.$(OBJEXT) \ test_remotebackend_http-test-remotebackend-http.$(OBJEXT) test_remotebackend_http_OBJECTS = \ $(am_test_remotebackend_http_OBJECTS) am__DEPENDENCIES_1 = test_remotebackend_http_DEPENDENCIES = libtestremotebackend.la \ $(am__DEPENDENCIES_1) \ ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_remotebackend_http_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_remotebackend_json_OBJECTS = \ test_remotebackend_json-test-remotebackend.$(OBJEXT) \ test_remotebackend_json-test-remotebackend-json.$(OBJEXT) test_remotebackend_json_OBJECTS = \ $(am_test_remotebackend_json_OBJECTS) test_remotebackend_json_DEPENDENCIES = libtestremotebackend.la \ $(am__DEPENDENCIES_1) \ ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_remotebackend_json_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_remotebackend_pipe_OBJECTS = \ test_remotebackend_pipe-test-remotebackend.$(OBJEXT) \ test_remotebackend_pipe-test-remotebackend-pipe.$(OBJEXT) test_remotebackend_pipe_OBJECTS = \ $(am_test_remotebackend_pipe_OBJECTS) test_remotebackend_pipe_DEPENDENCIES = libtestremotebackend.la \ $(am__DEPENDENCIES_1) \ ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_remotebackend_pipe_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_remotebackend_post_OBJECTS = \ test_remotebackend_post-test-remotebackend.$(OBJEXT) \ test_remotebackend_post-test-remotebackend-post.$(OBJEXT) test_remotebackend_post_OBJECTS = \ $(am_test_remotebackend_post_OBJECTS) test_remotebackend_post_DEPENDENCIES = libtestremotebackend.la \ $(am__DEPENDENCIES_1) \ ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_remotebackend_post_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libremotebackend_la_SOURCES) \ $(libtestremotebackend_la_SOURCES) \ $(test_remotebackend_http_SOURCES) \ $(test_remotebackend_json_SOURCES) \ $(test_remotebackend_pipe_SOURCES) \ $(test_remotebackend_post_SOURCES) DIST_SOURCES = $(libremotebackend_la_SOURCES) \ $(libtestremotebackend_la_SOURCES) \ $(test_remotebackend_http_SOURCES) \ $(test_remotebackend_json_SOURCES) \ $(test_remotebackend_pipe_SOURCES) \ $(test_remotebackend_post_SOURCES) ETAGS = etags CTAGS = ctags am__tty_colors = \ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ $(BOOST_CPPFLAGS) $(LIBCURL_CFLAGS) -I../../pdns/ext/rapidjson/include #if !ALLSTATIC #install-exec-local: # install .lib/libremotebackend.so.0.0.0 @libdir@ #endif EXTRA_DIST = OBJECTFILES OBJECTLIBS EXTRA_LTLIBRARIES = libtestremotebackend.la lib_LTLIBRARIES = libremotebackend.la libremotebackend_la_SOURCES = remotebackend.hh remotebackend.cc unixconnector.cc httpconnector.cc pipeconnector.cc libremotebackend_la_LDFLAGS = -module -avoid-version libremotebackend_la_LIBS = $(LIBCURL_LIBS) TESTS_ENVIRONMENT = env BOOST_TEST_LOG_LEVEL=message REMOTEBACKEND_HTTP=$(REMOTEBACKEND_HTTP) ./testrunner.sh BUILT_SOURCES = ../../pdns/dnslabeltext.cc libtestremotebackend_la_SOURCES = ../../pdns/dnsbackend.hh ../../pdns/dnsbackend.cc ../../pdns/ueberbackend.hh ../../pdns/ueberbackend.cc \ ../../pdns/nameserver.cc ../../pdns/misc.cc ../../pdns/arguments.hh \ ../../pdns/unix_utility.cc ../../pdns/logger.cc ../../pdns/statbag.cc ../../pdns/arguments.hh ../../pdns/arguments.cc ../../pdns/qtype.cc ../../pdns/dnspacket.cc \ ../../pdns/dnswriter.cc ../../pdns/base64.cc ../../pdns/base32.cc ../../pdns/dnsrecords.cc ../../pdns/dnslabeltext.cc ../../pdns/dnsparser.cc \ ../../pdns/rcpgenerator.cc ../../pdns/ednssubnet.cc ../../pdns/nsecrecords.cc ../../pdns/sillyrecords.cc ../../pdns/dnssecinfra.cc \ ../../pdns/aes/dns_random.cc ../../pdns/packetcache.hh ../../pdns/packetcache.cc \ ../../pdns/aes/aescpp.h ../../pdns/dns.hh ../../pdns/dns.cc ../../pdns/json.hh ../../pdns/json.cc \ ../../pdns/aes/aescrypt.c ../../pdns/aes/aes.h ../../pdns/aes/aeskey.c ../../pdns/aes/aes_modes.c ../../pdns/aes/aesopt.h \ ../../pdns/aes/aestab.c ../../pdns/aes/aestab.h ../../pdns/aes/brg_endian.h ../../pdns/aes/brg_types.h ../pipebackend/coprocess.cc \ remotebackend.hh remotebackend.cc unixconnector.cc httpconnector.cc pipeconnector.cc libtestremotebackend_la_CFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns libtestremotebackend_la_CXXFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_SOURCES = test-remotebackend.cc test-remotebackend-pipe.cc test_remotebackend_http_SOURCES = test-remotebackend.cc test-remotebackend-http.cc ../../config.h test_remotebackend_post_SOURCES = test-remotebackend.cc test-remotebackend-post.cc ../../config.h test_remotebackend_json_SOURCES = test-remotebackend.cc test-remotebackend-json.cc ../../config.h test_remotebackend_pipe_CFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_CXXFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_LDADD = libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_http_CFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_http_CXXFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_http_LDADD = libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_post_CFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_post_CXXFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_post_LDADD = libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_json_CFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_json_CXXFLAGS = $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_json_LDADD = libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/remotebackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/remotebackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libremotebackend.la: $(libremotebackend_la_OBJECTS) $(libremotebackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libremotebackend_la_LINK) -rpath $(libdir) $(libremotebackend_la_OBJECTS) $(libremotebackend_la_LIBADD) $(LIBS) libtestremotebackend.la: $(libtestremotebackend_la_OBJECTS) $(libtestremotebackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libtestremotebackend_la_LINK) $(libtestremotebackend_la_OBJECTS) $(libtestremotebackend_la_LIBADD) $(LIBS) test_remotebackend_http$(EXEEXT): $(test_remotebackend_http_OBJECTS) $(test_remotebackend_http_DEPENDENCIES) @rm -f test_remotebackend_http$(EXEEXT) $(AM_V_CXXLD)$(test_remotebackend_http_LINK) $(test_remotebackend_http_OBJECTS) $(test_remotebackend_http_LDADD) $(LIBS) test_remotebackend_json$(EXEEXT): $(test_remotebackend_json_OBJECTS) $(test_remotebackend_json_DEPENDENCIES) @rm -f test_remotebackend_json$(EXEEXT) $(AM_V_CXXLD)$(test_remotebackend_json_LINK) $(test_remotebackend_json_OBJECTS) $(test_remotebackend_json_LDADD) $(LIBS) test_remotebackend_pipe$(EXEEXT): $(test_remotebackend_pipe_OBJECTS) $(test_remotebackend_pipe_DEPENDENCIES) @rm -f test_remotebackend_pipe$(EXEEXT) $(AM_V_CXXLD)$(test_remotebackend_pipe_LINK) $(test_remotebackend_pipe_OBJECTS) $(test_remotebackend_pipe_LDADD) $(LIBS) test_remotebackend_post$(EXEEXT): $(test_remotebackend_post_OBJECTS) $(test_remotebackend_post_DEPENDENCIES) @rm -f test_remotebackend_post$(EXEEXT) $(AM_V_CXXLD)$(test_remotebackend_post_LINK) $(test_remotebackend_post_OBJECTS) $(test_remotebackend_post_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httpconnector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-aes_modes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-aescrypt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-aeskey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-aestab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-arguments.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-base32.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-base64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-coprocess.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dns.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dns_random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnsbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnslabeltext.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnspacket.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnsparser.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnsrecords.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnssecinfra.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-dnswriter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-ednssubnet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-httpconnector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-json.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-logger.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-nameserver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-nsecrecords.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-packetcache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-pipeconnector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-qtype.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-rcpgenerator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-remotebackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-sillyrecords.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-statbag.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-ueberbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-unix_utility.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtestremotebackend_la-unixconnector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipeconnector.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remotebackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_http-test-remotebackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_json-test-remotebackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_remotebackend_post-test-remotebackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unixconnector.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< libtestremotebackend_la-aescrypt.lo: ../../pdns/aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -MT libtestremotebackend_la-aescrypt.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-aescrypt.Tpo -c -o libtestremotebackend_la-aescrypt.lo `test -f '../../pdns/aes/aescrypt.c' || echo '$(srcdir)/'`../../pdns/aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-aescrypt.Tpo $(DEPDIR)/libtestremotebackend_la-aescrypt.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../pdns/aes/aescrypt.c' object='libtestremotebackend_la-aescrypt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -c -o libtestremotebackend_la-aescrypt.lo `test -f '../../pdns/aes/aescrypt.c' || echo '$(srcdir)/'`../../pdns/aes/aescrypt.c libtestremotebackend_la-aeskey.lo: ../../pdns/aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -MT libtestremotebackend_la-aeskey.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-aeskey.Tpo -c -o libtestremotebackend_la-aeskey.lo `test -f '../../pdns/aes/aeskey.c' || echo '$(srcdir)/'`../../pdns/aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-aeskey.Tpo $(DEPDIR)/libtestremotebackend_la-aeskey.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../pdns/aes/aeskey.c' object='libtestremotebackend_la-aeskey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -c -o libtestremotebackend_la-aeskey.lo `test -f '../../pdns/aes/aeskey.c' || echo '$(srcdir)/'`../../pdns/aes/aeskey.c libtestremotebackend_la-aes_modes.lo: ../../pdns/aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -MT libtestremotebackend_la-aes_modes.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-aes_modes.Tpo -c -o libtestremotebackend_la-aes_modes.lo `test -f '../../pdns/aes/aes_modes.c' || echo '$(srcdir)/'`../../pdns/aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-aes_modes.Tpo $(DEPDIR)/libtestremotebackend_la-aes_modes.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../pdns/aes/aes_modes.c' object='libtestremotebackend_la-aes_modes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -c -o libtestremotebackend_la-aes_modes.lo `test -f '../../pdns/aes/aes_modes.c' || echo '$(srcdir)/'`../../pdns/aes/aes_modes.c libtestremotebackend_la-aestab.lo: ../../pdns/aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -MT libtestremotebackend_la-aestab.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-aestab.Tpo -c -o libtestremotebackend_la-aestab.lo `test -f '../../pdns/aes/aestab.c' || echo '$(srcdir)/'`../../pdns/aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-aestab.Tpo $(DEPDIR)/libtestremotebackend_la-aestab.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../pdns/aes/aestab.c' object='libtestremotebackend_la-aestab.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CFLAGS) $(CFLAGS) -c -o libtestremotebackend_la-aestab.lo `test -f '../../pdns/aes/aestab.c' || echo '$(srcdir)/'`../../pdns/aes/aestab.c .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< libtestremotebackend_la-dnsbackend.lo: ../../pdns/dnsbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnsbackend.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnsbackend.Tpo -c -o libtestremotebackend_la-dnsbackend.lo `test -f '../../pdns/dnsbackend.cc' || echo '$(srcdir)/'`../../pdns/dnsbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnsbackend.Tpo $(DEPDIR)/libtestremotebackend_la-dnsbackend.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnsbackend.cc' object='libtestremotebackend_la-dnsbackend.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnsbackend.lo `test -f '../../pdns/dnsbackend.cc' || echo '$(srcdir)/'`../../pdns/dnsbackend.cc libtestremotebackend_la-ueberbackend.lo: ../../pdns/ueberbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-ueberbackend.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-ueberbackend.Tpo -c -o libtestremotebackend_la-ueberbackend.lo `test -f '../../pdns/ueberbackend.cc' || echo '$(srcdir)/'`../../pdns/ueberbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-ueberbackend.Tpo $(DEPDIR)/libtestremotebackend_la-ueberbackend.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/ueberbackend.cc' object='libtestremotebackend_la-ueberbackend.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-ueberbackend.lo `test -f '../../pdns/ueberbackend.cc' || echo '$(srcdir)/'`../../pdns/ueberbackend.cc libtestremotebackend_la-nameserver.lo: ../../pdns/nameserver.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-nameserver.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-nameserver.Tpo -c -o libtestremotebackend_la-nameserver.lo `test -f '../../pdns/nameserver.cc' || echo '$(srcdir)/'`../../pdns/nameserver.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-nameserver.Tpo $(DEPDIR)/libtestremotebackend_la-nameserver.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/nameserver.cc' object='libtestremotebackend_la-nameserver.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-nameserver.lo `test -f '../../pdns/nameserver.cc' || echo '$(srcdir)/'`../../pdns/nameserver.cc libtestremotebackend_la-misc.lo: ../../pdns/misc.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-misc.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-misc.Tpo -c -o libtestremotebackend_la-misc.lo `test -f '../../pdns/misc.cc' || echo '$(srcdir)/'`../../pdns/misc.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-misc.Tpo $(DEPDIR)/libtestremotebackend_la-misc.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/misc.cc' object='libtestremotebackend_la-misc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-misc.lo `test -f '../../pdns/misc.cc' || echo '$(srcdir)/'`../../pdns/misc.cc libtestremotebackend_la-unix_utility.lo: ../../pdns/unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-unix_utility.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-unix_utility.Tpo -c -o libtestremotebackend_la-unix_utility.lo `test -f '../../pdns/unix_utility.cc' || echo '$(srcdir)/'`../../pdns/unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-unix_utility.Tpo $(DEPDIR)/libtestremotebackend_la-unix_utility.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/unix_utility.cc' object='libtestremotebackend_la-unix_utility.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-unix_utility.lo `test -f '../../pdns/unix_utility.cc' || echo '$(srcdir)/'`../../pdns/unix_utility.cc libtestremotebackend_la-logger.lo: ../../pdns/logger.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-logger.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-logger.Tpo -c -o libtestremotebackend_la-logger.lo `test -f '../../pdns/logger.cc' || echo '$(srcdir)/'`../../pdns/logger.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-logger.Tpo $(DEPDIR)/libtestremotebackend_la-logger.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/logger.cc' object='libtestremotebackend_la-logger.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-logger.lo `test -f '../../pdns/logger.cc' || echo '$(srcdir)/'`../../pdns/logger.cc libtestremotebackend_la-statbag.lo: ../../pdns/statbag.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-statbag.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-statbag.Tpo -c -o libtestremotebackend_la-statbag.lo `test -f '../../pdns/statbag.cc' || echo '$(srcdir)/'`../../pdns/statbag.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-statbag.Tpo $(DEPDIR)/libtestremotebackend_la-statbag.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/statbag.cc' object='libtestremotebackend_la-statbag.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-statbag.lo `test -f '../../pdns/statbag.cc' || echo '$(srcdir)/'`../../pdns/statbag.cc libtestremotebackend_la-arguments.lo: ../../pdns/arguments.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-arguments.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-arguments.Tpo -c -o libtestremotebackend_la-arguments.lo `test -f '../../pdns/arguments.cc' || echo '$(srcdir)/'`../../pdns/arguments.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-arguments.Tpo $(DEPDIR)/libtestremotebackend_la-arguments.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/arguments.cc' object='libtestremotebackend_la-arguments.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-arguments.lo `test -f '../../pdns/arguments.cc' || echo '$(srcdir)/'`../../pdns/arguments.cc libtestremotebackend_la-qtype.lo: ../../pdns/qtype.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-qtype.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-qtype.Tpo -c -o libtestremotebackend_la-qtype.lo `test -f '../../pdns/qtype.cc' || echo '$(srcdir)/'`../../pdns/qtype.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-qtype.Tpo $(DEPDIR)/libtestremotebackend_la-qtype.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/qtype.cc' object='libtestremotebackend_la-qtype.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-qtype.lo `test -f '../../pdns/qtype.cc' || echo '$(srcdir)/'`../../pdns/qtype.cc libtestremotebackend_la-dnspacket.lo: ../../pdns/dnspacket.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnspacket.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnspacket.Tpo -c -o libtestremotebackend_la-dnspacket.lo `test -f '../../pdns/dnspacket.cc' || echo '$(srcdir)/'`../../pdns/dnspacket.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnspacket.Tpo $(DEPDIR)/libtestremotebackend_la-dnspacket.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnspacket.cc' object='libtestremotebackend_la-dnspacket.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnspacket.lo `test -f '../../pdns/dnspacket.cc' || echo '$(srcdir)/'`../../pdns/dnspacket.cc libtestremotebackend_la-dnswriter.lo: ../../pdns/dnswriter.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnswriter.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnswriter.Tpo -c -o libtestremotebackend_la-dnswriter.lo `test -f '../../pdns/dnswriter.cc' || echo '$(srcdir)/'`../../pdns/dnswriter.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnswriter.Tpo $(DEPDIR)/libtestremotebackend_la-dnswriter.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnswriter.cc' object='libtestremotebackend_la-dnswriter.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnswriter.lo `test -f '../../pdns/dnswriter.cc' || echo '$(srcdir)/'`../../pdns/dnswriter.cc libtestremotebackend_la-base64.lo: ../../pdns/base64.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-base64.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-base64.Tpo -c -o libtestremotebackend_la-base64.lo `test -f '../../pdns/base64.cc' || echo '$(srcdir)/'`../../pdns/base64.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-base64.Tpo $(DEPDIR)/libtestremotebackend_la-base64.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/base64.cc' object='libtestremotebackend_la-base64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-base64.lo `test -f '../../pdns/base64.cc' || echo '$(srcdir)/'`../../pdns/base64.cc libtestremotebackend_la-base32.lo: ../../pdns/base32.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-base32.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-base32.Tpo -c -o libtestremotebackend_la-base32.lo `test -f '../../pdns/base32.cc' || echo '$(srcdir)/'`../../pdns/base32.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-base32.Tpo $(DEPDIR)/libtestremotebackend_la-base32.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/base32.cc' object='libtestremotebackend_la-base32.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-base32.lo `test -f '../../pdns/base32.cc' || echo '$(srcdir)/'`../../pdns/base32.cc libtestremotebackend_la-dnsrecords.lo: ../../pdns/dnsrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnsrecords.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnsrecords.Tpo -c -o libtestremotebackend_la-dnsrecords.lo `test -f '../../pdns/dnsrecords.cc' || echo '$(srcdir)/'`../../pdns/dnsrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnsrecords.Tpo $(DEPDIR)/libtestremotebackend_la-dnsrecords.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnsrecords.cc' object='libtestremotebackend_la-dnsrecords.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnsrecords.lo `test -f '../../pdns/dnsrecords.cc' || echo '$(srcdir)/'`../../pdns/dnsrecords.cc libtestremotebackend_la-dnslabeltext.lo: ../../pdns/dnslabeltext.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnslabeltext.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnslabeltext.Tpo -c -o libtestremotebackend_la-dnslabeltext.lo `test -f '../../pdns/dnslabeltext.cc' || echo '$(srcdir)/'`../../pdns/dnslabeltext.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnslabeltext.Tpo $(DEPDIR)/libtestremotebackend_la-dnslabeltext.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnslabeltext.cc' object='libtestremotebackend_la-dnslabeltext.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnslabeltext.lo `test -f '../../pdns/dnslabeltext.cc' || echo '$(srcdir)/'`../../pdns/dnslabeltext.cc libtestremotebackend_la-dnsparser.lo: ../../pdns/dnsparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnsparser.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnsparser.Tpo -c -o libtestremotebackend_la-dnsparser.lo `test -f '../../pdns/dnsparser.cc' || echo '$(srcdir)/'`../../pdns/dnsparser.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnsparser.Tpo $(DEPDIR)/libtestremotebackend_la-dnsparser.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnsparser.cc' object='libtestremotebackend_la-dnsparser.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnsparser.lo `test -f '../../pdns/dnsparser.cc' || echo '$(srcdir)/'`../../pdns/dnsparser.cc libtestremotebackend_la-rcpgenerator.lo: ../../pdns/rcpgenerator.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-rcpgenerator.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-rcpgenerator.Tpo -c -o libtestremotebackend_la-rcpgenerator.lo `test -f '../../pdns/rcpgenerator.cc' || echo '$(srcdir)/'`../../pdns/rcpgenerator.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-rcpgenerator.Tpo $(DEPDIR)/libtestremotebackend_la-rcpgenerator.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/rcpgenerator.cc' object='libtestremotebackend_la-rcpgenerator.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-rcpgenerator.lo `test -f '../../pdns/rcpgenerator.cc' || echo '$(srcdir)/'`../../pdns/rcpgenerator.cc libtestremotebackend_la-ednssubnet.lo: ../../pdns/ednssubnet.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-ednssubnet.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-ednssubnet.Tpo -c -o libtestremotebackend_la-ednssubnet.lo `test -f '../../pdns/ednssubnet.cc' || echo '$(srcdir)/'`../../pdns/ednssubnet.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-ednssubnet.Tpo $(DEPDIR)/libtestremotebackend_la-ednssubnet.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/ednssubnet.cc' object='libtestremotebackend_la-ednssubnet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-ednssubnet.lo `test -f '../../pdns/ednssubnet.cc' || echo '$(srcdir)/'`../../pdns/ednssubnet.cc libtestremotebackend_la-nsecrecords.lo: ../../pdns/nsecrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-nsecrecords.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-nsecrecords.Tpo -c -o libtestremotebackend_la-nsecrecords.lo `test -f '../../pdns/nsecrecords.cc' || echo '$(srcdir)/'`../../pdns/nsecrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-nsecrecords.Tpo $(DEPDIR)/libtestremotebackend_la-nsecrecords.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/nsecrecords.cc' object='libtestremotebackend_la-nsecrecords.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-nsecrecords.lo `test -f '../../pdns/nsecrecords.cc' || echo '$(srcdir)/'`../../pdns/nsecrecords.cc libtestremotebackend_la-sillyrecords.lo: ../../pdns/sillyrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-sillyrecords.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-sillyrecords.Tpo -c -o libtestremotebackend_la-sillyrecords.lo `test -f '../../pdns/sillyrecords.cc' || echo '$(srcdir)/'`../../pdns/sillyrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-sillyrecords.Tpo $(DEPDIR)/libtestremotebackend_la-sillyrecords.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/sillyrecords.cc' object='libtestremotebackend_la-sillyrecords.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-sillyrecords.lo `test -f '../../pdns/sillyrecords.cc' || echo '$(srcdir)/'`../../pdns/sillyrecords.cc libtestremotebackend_la-dnssecinfra.lo: ../../pdns/dnssecinfra.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dnssecinfra.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dnssecinfra.Tpo -c -o libtestremotebackend_la-dnssecinfra.lo `test -f '../../pdns/dnssecinfra.cc' || echo '$(srcdir)/'`../../pdns/dnssecinfra.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dnssecinfra.Tpo $(DEPDIR)/libtestremotebackend_la-dnssecinfra.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dnssecinfra.cc' object='libtestremotebackend_la-dnssecinfra.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dnssecinfra.lo `test -f '../../pdns/dnssecinfra.cc' || echo '$(srcdir)/'`../../pdns/dnssecinfra.cc libtestremotebackend_la-dns_random.lo: ../../pdns/aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dns_random.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dns_random.Tpo -c -o libtestremotebackend_la-dns_random.lo `test -f '../../pdns/aes/dns_random.cc' || echo '$(srcdir)/'`../../pdns/aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dns_random.Tpo $(DEPDIR)/libtestremotebackend_la-dns_random.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/aes/dns_random.cc' object='libtestremotebackend_la-dns_random.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dns_random.lo `test -f '../../pdns/aes/dns_random.cc' || echo '$(srcdir)/'`../../pdns/aes/dns_random.cc libtestremotebackend_la-packetcache.lo: ../../pdns/packetcache.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-packetcache.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-packetcache.Tpo -c -o libtestremotebackend_la-packetcache.lo `test -f '../../pdns/packetcache.cc' || echo '$(srcdir)/'`../../pdns/packetcache.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-packetcache.Tpo $(DEPDIR)/libtestremotebackend_la-packetcache.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/packetcache.cc' object='libtestremotebackend_la-packetcache.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-packetcache.lo `test -f '../../pdns/packetcache.cc' || echo '$(srcdir)/'`../../pdns/packetcache.cc libtestremotebackend_la-dns.lo: ../../pdns/dns.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-dns.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-dns.Tpo -c -o libtestremotebackend_la-dns.lo `test -f '../../pdns/dns.cc' || echo '$(srcdir)/'`../../pdns/dns.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-dns.Tpo $(DEPDIR)/libtestremotebackend_la-dns.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/dns.cc' object='libtestremotebackend_la-dns.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-dns.lo `test -f '../../pdns/dns.cc' || echo '$(srcdir)/'`../../pdns/dns.cc libtestremotebackend_la-json.lo: ../../pdns/json.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-json.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-json.Tpo -c -o libtestremotebackend_la-json.lo `test -f '../../pdns/json.cc' || echo '$(srcdir)/'`../../pdns/json.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-json.Tpo $(DEPDIR)/libtestremotebackend_la-json.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../pdns/json.cc' object='libtestremotebackend_la-json.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-json.lo `test -f '../../pdns/json.cc' || echo '$(srcdir)/'`../../pdns/json.cc libtestremotebackend_la-coprocess.lo: ../pipebackend/coprocess.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-coprocess.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-coprocess.Tpo -c -o libtestremotebackend_la-coprocess.lo `test -f '../pipebackend/coprocess.cc' || echo '$(srcdir)/'`../pipebackend/coprocess.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-coprocess.Tpo $(DEPDIR)/libtestremotebackend_la-coprocess.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../pipebackend/coprocess.cc' object='libtestremotebackend_la-coprocess.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-coprocess.lo `test -f '../pipebackend/coprocess.cc' || echo '$(srcdir)/'`../pipebackend/coprocess.cc libtestremotebackend_la-remotebackend.lo: remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-remotebackend.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-remotebackend.Tpo -c -o libtestremotebackend_la-remotebackend.lo `test -f 'remotebackend.cc' || echo '$(srcdir)/'`remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-remotebackend.Tpo $(DEPDIR)/libtestremotebackend_la-remotebackend.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='remotebackend.cc' object='libtestremotebackend_la-remotebackend.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-remotebackend.lo `test -f 'remotebackend.cc' || echo '$(srcdir)/'`remotebackend.cc libtestremotebackend_la-unixconnector.lo: unixconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-unixconnector.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-unixconnector.Tpo -c -o libtestremotebackend_la-unixconnector.lo `test -f 'unixconnector.cc' || echo '$(srcdir)/'`unixconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-unixconnector.Tpo $(DEPDIR)/libtestremotebackend_la-unixconnector.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='unixconnector.cc' object='libtestremotebackend_la-unixconnector.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-unixconnector.lo `test -f 'unixconnector.cc' || echo '$(srcdir)/'`unixconnector.cc libtestremotebackend_la-httpconnector.lo: httpconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-httpconnector.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-httpconnector.Tpo -c -o libtestremotebackend_la-httpconnector.lo `test -f 'httpconnector.cc' || echo '$(srcdir)/'`httpconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-httpconnector.Tpo $(DEPDIR)/libtestremotebackend_la-httpconnector.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='httpconnector.cc' object='libtestremotebackend_la-httpconnector.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-httpconnector.lo `test -f 'httpconnector.cc' || echo '$(srcdir)/'`httpconnector.cc libtestremotebackend_la-pipeconnector.lo: pipeconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -MT libtestremotebackend_la-pipeconnector.lo -MD -MP -MF $(DEPDIR)/libtestremotebackend_la-pipeconnector.Tpo -c -o libtestremotebackend_la-pipeconnector.lo `test -f 'pipeconnector.cc' || echo '$(srcdir)/'`pipeconnector.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtestremotebackend_la-pipeconnector.Tpo $(DEPDIR)/libtestremotebackend_la-pipeconnector.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='pipeconnector.cc' object='libtestremotebackend_la-pipeconnector.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtestremotebackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libtestremotebackend_la-pipeconnector.lo `test -f 'pipeconnector.cc' || echo '$(srcdir)/'`pipeconnector.cc test_remotebackend_http-test-remotebackend.o: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_http-test-remotebackend.o -MD -MP -MF $(DEPDIR)/test_remotebackend_http-test-remotebackend.Tpo -c -o test_remotebackend_http-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_http-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_http-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_http-test-remotebackend.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_http-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc test_remotebackend_http-test-remotebackend.obj: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_http-test-remotebackend.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_http-test-remotebackend.Tpo -c -o test_remotebackend_http-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_http-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_http-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_http-test-remotebackend.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_http-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` test_remotebackend_http-test-remotebackend-http.o: test-remotebackend-http.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_http-test-remotebackend-http.o -MD -MP -MF $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Tpo -c -o test_remotebackend_http-test-remotebackend-http.o `test -f 'test-remotebackend-http.cc' || echo '$(srcdir)/'`test-remotebackend-http.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Tpo $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-http.cc' object='test_remotebackend_http-test-remotebackend-http.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_http-test-remotebackend-http.o `test -f 'test-remotebackend-http.cc' || echo '$(srcdir)/'`test-remotebackend-http.cc test_remotebackend_http-test-remotebackend-http.obj: test-remotebackend-http.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_http-test-remotebackend-http.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Tpo -c -o test_remotebackend_http-test-remotebackend-http.obj `if test -f 'test-remotebackend-http.cc'; then $(CYGPATH_W) 'test-remotebackend-http.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-http.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Tpo $(DEPDIR)/test_remotebackend_http-test-remotebackend-http.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-http.cc' object='test_remotebackend_http-test-remotebackend-http.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_http_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_http-test-remotebackend-http.obj `if test -f 'test-remotebackend-http.cc'; then $(CYGPATH_W) 'test-remotebackend-http.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-http.cc'; fi` test_remotebackend_json-test-remotebackend.o: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_json-test-remotebackend.o -MD -MP -MF $(DEPDIR)/test_remotebackend_json-test-remotebackend.Tpo -c -o test_remotebackend_json-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_json-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_json-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_json-test-remotebackend.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_json-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc test_remotebackend_json-test-remotebackend.obj: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_json-test-remotebackend.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_json-test-remotebackend.Tpo -c -o test_remotebackend_json-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_json-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_json-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_json-test-remotebackend.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_json-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` test_remotebackend_json-test-remotebackend-json.o: test-remotebackend-json.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_json-test-remotebackend-json.o -MD -MP -MF $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Tpo -c -o test_remotebackend_json-test-remotebackend-json.o `test -f 'test-remotebackend-json.cc' || echo '$(srcdir)/'`test-remotebackend-json.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Tpo $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-json.cc' object='test_remotebackend_json-test-remotebackend-json.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_json-test-remotebackend-json.o `test -f 'test-remotebackend-json.cc' || echo '$(srcdir)/'`test-remotebackend-json.cc test_remotebackend_json-test-remotebackend-json.obj: test-remotebackend-json.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_json-test-remotebackend-json.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Tpo -c -o test_remotebackend_json-test-remotebackend-json.obj `if test -f 'test-remotebackend-json.cc'; then $(CYGPATH_W) 'test-remotebackend-json.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-json.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Tpo $(DEPDIR)/test_remotebackend_json-test-remotebackend-json.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-json.cc' object='test_remotebackend_json-test-remotebackend-json.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_json_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_json-test-remotebackend-json.obj `if test -f 'test-remotebackend-json.cc'; then $(CYGPATH_W) 'test-remotebackend-json.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-json.cc'; fi` test_remotebackend_pipe-test-remotebackend.o: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_pipe-test-remotebackend.o -MD -MP -MF $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Tpo -c -o test_remotebackend_pipe-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_pipe-test-remotebackend.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_pipe-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc test_remotebackend_pipe-test-remotebackend.obj: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_pipe-test-remotebackend.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Tpo -c -o test_remotebackend_pipe-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_pipe-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_pipe-test-remotebackend.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_pipe-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` test_remotebackend_pipe-test-remotebackend-pipe.o: test-remotebackend-pipe.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_pipe-test-remotebackend-pipe.o -MD -MP -MF $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Tpo -c -o test_remotebackend_pipe-test-remotebackend-pipe.o `test -f 'test-remotebackend-pipe.cc' || echo '$(srcdir)/'`test-remotebackend-pipe.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Tpo $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-pipe.cc' object='test_remotebackend_pipe-test-remotebackend-pipe.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_pipe-test-remotebackend-pipe.o `test -f 'test-remotebackend-pipe.cc' || echo '$(srcdir)/'`test-remotebackend-pipe.cc test_remotebackend_pipe-test-remotebackend-pipe.obj: test-remotebackend-pipe.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_pipe-test-remotebackend-pipe.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Tpo -c -o test_remotebackend_pipe-test-remotebackend-pipe.obj `if test -f 'test-remotebackend-pipe.cc'; then $(CYGPATH_W) 'test-remotebackend-pipe.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-pipe.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Tpo $(DEPDIR)/test_remotebackend_pipe-test-remotebackend-pipe.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-pipe.cc' object='test_remotebackend_pipe-test-remotebackend-pipe.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_pipe_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_pipe-test-remotebackend-pipe.obj `if test -f 'test-remotebackend-pipe.cc'; then $(CYGPATH_W) 'test-remotebackend-pipe.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-pipe.cc'; fi` test_remotebackend_post-test-remotebackend.o: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_post-test-remotebackend.o -MD -MP -MF $(DEPDIR)/test_remotebackend_post-test-remotebackend.Tpo -c -o test_remotebackend_post-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_post-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_post-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_post-test-remotebackend.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_post-test-remotebackend.o `test -f 'test-remotebackend.cc' || echo '$(srcdir)/'`test-remotebackend.cc test_remotebackend_post-test-remotebackend.obj: test-remotebackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_post-test-remotebackend.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_post-test-remotebackend.Tpo -c -o test_remotebackend_post-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_post-test-remotebackend.Tpo $(DEPDIR)/test_remotebackend_post-test-remotebackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend.cc' object='test_remotebackend_post-test-remotebackend.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_post-test-remotebackend.obj `if test -f 'test-remotebackend.cc'; then $(CYGPATH_W) 'test-remotebackend.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend.cc'; fi` test_remotebackend_post-test-remotebackend-post.o: test-remotebackend-post.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_post-test-remotebackend-post.o -MD -MP -MF $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Tpo -c -o test_remotebackend_post-test-remotebackend-post.o `test -f 'test-remotebackend-post.cc' || echo '$(srcdir)/'`test-remotebackend-post.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Tpo $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-post.cc' object='test_remotebackend_post-test-remotebackend-post.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_post-test-remotebackend-post.o `test -f 'test-remotebackend-post.cc' || echo '$(srcdir)/'`test-remotebackend-post.cc test_remotebackend_post-test-remotebackend-post.obj: test-remotebackend-post.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -MT test_remotebackend_post-test-remotebackend-post.obj -MD -MP -MF $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Tpo -c -o test_remotebackend_post-test-remotebackend-post.obj `if test -f 'test-remotebackend-post.cc'; then $(CYGPATH_W) 'test-remotebackend-post.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-post.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Tpo $(DEPDIR)/test_remotebackend_post-test-remotebackend-post.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='test-remotebackend-post.cc' object='test_remotebackend_post-test-remotebackend-post.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_remotebackend_post_CXXFLAGS) $(CXXFLAGS) -c -o test_remotebackend_post-test-remotebackend-post.obj `if test -f 'test-remotebackend-post.cc'; then $(CYGPATH_W) 'test-remotebackend-post.cc'; else $(CYGPATH_W) '$(srcdir)/test-remotebackend-post.cc'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: all check check-am install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ clean-generic clean-libLTLIBRARIES clean-libtool ctags \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES ../../pdns/dnslabeltext.cc: ../../pdns/dnslabeltext.rl make -C ../../pdns dnslabeltext.cc # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/remotebackend/test-remotebackend.cc0000644000014601777760000001740112154344061024130 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include #include #include #include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include #include #include #include "pdns/json.hh" #include "pdns/statbag.hh" #include "pdns/packetcache.hh" #include "test-remotebackend-keys.hh" extern DNSBackend *be; BOOST_AUTO_TEST_SUITE(test_remotebackend_so) BOOST_AUTO_TEST_CASE(test_method_lookup) { BOOST_TEST_MESSAGE("Testing lookup method"); DNSResourceRecord rr; be->lookup(QType(QType::SOA), "unit.test"); // then try to get() BOOST_CHECK(be->get(rr)); // and this should be TRUE. // then we check rr contains what we expect BOOST_CHECK_EQUAL(rr.qname, "unit.test"); BOOST_CHECK_MESSAGE(rr.qtype == QType::SOA, "returned qtype was not SOA"); BOOST_CHECK_EQUAL(rr.content, "ns.unit.test hostmaster.unit.test 1 2 3 4 5 6"); BOOST_CHECK_EQUAL(rr.ttl, 300); } BOOST_AUTO_TEST_CASE(test_method_list) { int record_count = 0; DNSResourceRecord rr; BOOST_TEST_MESSAGE("Testing list method"); be->list("unit.test", -1); while(be->get(rr)) record_count++; BOOST_CHECK_EQUAL(record_count, 5); // number of records our test domain has } BOOST_AUTO_TEST_CASE(test_method_doesDNSSEC) { BOOST_TEST_MESSAGE("Testing doesDNSSEC method"); BOOST_CHECK(be->doesDNSSEC()); // should be true } BOOST_AUTO_TEST_CASE(test_method_setDomainMetadata) { std::vector meta; meta.push_back("VALUE"); BOOST_TEST_MESSAGE("Testing setDomainMetadata method"); BOOST_CHECK(be->setDomainMetadata("unit.test","TEST", meta)); } BOOST_AUTO_TEST_CASE(test_method_getDomainMetadata) { std::vector meta; BOOST_TEST_MESSAGE("Testing getDomainMetadata method"); be->getDomainMetadata("unit.test","TEST", meta); BOOST_CHECK_EQUAL(meta.size(), 1); // in case we got more than one value, which would be unexpected // but not fatal if (meta.size() > 0) BOOST_CHECK_EQUAL(meta[0], "VALUE"); } BOOST_AUTO_TEST_CASE(test_method_addDomainKey) { BOOST_TEST_MESSAGE("Testing addDomainKey method"); BOOST_CHECK_EQUAL(be->addDomainKey("unit.test",k1), 1); BOOST_CHECK_EQUAL(be->addDomainKey("unit.test",k2), 2); } BOOST_AUTO_TEST_CASE(test_method_getDomainKeys) { std::vector keys; BOOST_TEST_MESSAGE("Testing getDomainKeys method"); // we expect to get two keys be->getDomainKeys("unit.test",0,keys); BOOST_CHECK_EQUAL(keys.size(), 2); // in case we got more than 2 keys, which would be unexpected // but not fatal if (keys.size() > 1) { // check that we have two keys BOOST_FOREACH(DNSBackend::KeyData &kd, keys) { BOOST_CHECK(kd.id > 0); BOOST_CHECK(kd.flags == 256 || kd.flags == 257); BOOST_CHECK(kd.active == true); BOOST_CHECK(kd.content.size() > 500); } } } BOOST_AUTO_TEST_CASE(test_method_deactivateDomainKey) { BOOST_TEST_MESSAGE("Testing deactivateDomainKey method"); BOOST_CHECK(be->deactivateDomainKey("unit.test",1)); } BOOST_AUTO_TEST_CASE(test_method_activateDomainKey) { BOOST_TEST_MESSAGE("Testing activateDomainKey method"); BOOST_CHECK(be->activateDomainKey("unit.test",1)); } BOOST_AUTO_TEST_CASE(test_method_removeDomainKey) { BOOST_CHECK(be->removeDomainKey("unit.test",2)); BOOST_CHECK(be->removeDomainKey("unit.test",1)); } BOOST_AUTO_TEST_CASE(test_method_getBeforeAndAfterNamesAbsolute) { std::string unhashed,before,after; BOOST_TEST_MESSAGE("Testing getBeforeAndAfterNamesAbsolute method"); be->getBeforeAndAfterNamesAbsolute(-1, "middle.unit.test", unhashed, before, after); BOOST_CHECK_EQUAL(unhashed, "middle"); BOOST_CHECK_EQUAL(before, "begin"); BOOST_CHECK_EQUAL(after, "stop"); } BOOST_AUTO_TEST_CASE(test_method_getTSIGKey) { std::string algorithm, content; BOOST_TEST_MESSAGE("Testing getTSIGKey method"); be->getTSIGKey("unit.test",&algorithm,&content); BOOST_CHECK_EQUAL(algorithm, "NULL"); BOOST_CHECK_EQUAL(content, "NULL"); } BOOST_AUTO_TEST_CASE(test_method_setNotified) { BOOST_TEST_MESSAGE("Testing setNotified method"); be->setNotified(1, 2); BOOST_CHECK(true); // we check this on next step } BOOST_AUTO_TEST_CASE(test_method_getDomainInfo) { DomainInfo di; BOOST_TEST_MESSAGE("Testing getDomainInfo method"); be->getDomainInfo("unit.test", di); BOOST_CHECK_EQUAL(di.zone, "unit.test"); BOOST_CHECK_EQUAL(di.serial, 2); BOOST_CHECK_EQUAL(di.notified_serial, 2); BOOST_CHECK_EQUAL(di.kind, DomainInfo::Native); BOOST_CHECK_EQUAL(di.backend, be); } BOOST_AUTO_TEST_CASE(test_method_superMasterBackend) { DNSResourceRecord rr; std::vector nsset; DNSBackend *dbd; BOOST_TEST_MESSAGE("Testing superMasterBackend method"); rr.qname = "example.com"; rr.qtype = QType::NS; rr.qclass = QClass::IN; rr.ttl = 300; rr.content = "ns1.example.com"; nsset.push_back(rr); rr.qname = "example.com"; rr.qtype = QType::NS; rr.qclass = QClass::IN; rr.ttl = 300; rr.content = "ns2.example.com"; nsset.push_back(rr); BOOST_CHECK(be->superMasterBackend("10.0.0.1", "example.com", nsset, NULL, &dbd)); // let's see what we got BOOST_CHECK_EQUAL(dbd, be); } BOOST_AUTO_TEST_CASE(test_method_createSlaveDomain) { BOOST_TEST_MESSAGE("Testing createSlaveDomain method"); BOOST_CHECK(be->createSlaveDomain("10.0.0.1", "pirate.unit.test", "")); } BOOST_AUTO_TEST_CASE(test_method_feedRecord) { DNSResourceRecord rr; BOOST_TEST_MESSAGE("Testing feedRecord method"); be->startTransaction("example.com",2); rr.qname = "example.com"; rr.qtype = QType::SOA; rr.qclass = QClass::IN; rr.ttl = 300; rr.content = "ns1.example.com hostmaster.example.com 2013013441 7200 3600 1209600 300"; BOOST_CHECK(be->feedRecord(rr, NULL)); rr.qname = "replace.example.com"; rr.qtype = QType::A; rr.qclass = QClass::IN; rr.ttl = 300; rr.content = "127.0.0.1"; BOOST_CHECK(be->feedRecord(rr, NULL)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_replaceRRSet) { be->startTransaction("example.com",2); DNSResourceRecord rr; std::vector rrset; BOOST_TEST_MESSAGE("Testing replaceRRSet method"); rr.qname = "replace.example.com"; rr.qtype = QType::A; rr.qclass = QClass::IN; rr.ttl = 300; rr.content = "1.1.1.1"; rrset.push_back(rr); BOOST_CHECK(be->replaceRRSet(2, "replace.example.com", QType(QType::A), rrset)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_feedEnts) { BOOST_TEST_MESSAGE("Testing feedEnts method"); be->startTransaction("example.com",2); set nonterm = boost::assign::list_of("_udp")("_sip._udp"); BOOST_CHECK(be->feedEnts(2, nonterm)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_feedEnts3) { BOOST_TEST_MESSAGE("Testing feedEnts3 method"); be->startTransaction("example.com",2); set nonterm = boost::assign::list_of("_udp")("_sip._udp"); BOOST_CHECK(be->feedEnts3(2, "example.com", nonterm, 1, "\xaa\xbb\xcc\xdd", 0)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_abortTransaction) { BOOST_TEST_MESSAGE("Testing abortTransaction method"); be->startTransaction("example.com",2); BOOST_CHECK(be->abortTransaction()); } BOOST_AUTO_TEST_CASE(test_method_calculateSOASerial) { SOAData sd; time_t serial; be->getSOA("unit.test",sd); BOOST_CHECK(be->calculateSOASerial("unit.test",sd,serial)); BOOST_CHECK_EQUAL(serial, 2013060300); } BOOST_AUTO_TEST_SUITE_END(); pdns-3.3/modules/remotebackend/TODO0000644000014601777760000000041712136555572020543 0ustar00jenkinsnogroup00000000000000- detect jsoncpp and libcurl in configure - move coprocess from pipebackend to core so remotebackend can run without pipebackend - make ruby scripts compatible with 1.8 - Improve error handling and reply validation - Code coverage - move calls that change things to POST pdns-3.3/modules/remotebackend/test-remotebackend-pipe.cc0000644000014601777760000000307012154344061025060 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE unit #include #include #include #include #include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include "pdns/dnsrecords.hh" #include #include #include #include "pdns/json.hh" #include "pdns/statbag.hh" #include "pdns/packetcache.hh" StatBag S; PacketCache PC; ArgvMap &arg() { static ArgvMap arg; return arg; }; class RemoteLoader { public: RemoteLoader(); }; DNSBackend *be; struct RemotebackendSetup { RemotebackendSetup() { be = 0; try { // setup minimum arguments ::arg().set("module-dir")=""; new RemoteLoader(); BackendMakers().launch("remote"); // then get us a instance of it ::arg().set("remote-connection-string")="pipe:command=unittest_pipe.rb"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; // load few record types to help out SOARecordContent::report(); NSRecordContent::report(); ARecordContent::report(); } catch (AhuException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } ~RemotebackendSetup() { } }; BOOST_GLOBAL_FIXTURE( RemotebackendSetup ); pdns-3.3/modules/remotebackend/Makefile.am0000644000014601777760000001124712154344061022077 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ $(BOOST_CPPFLAGS) $(LIBCURL_CFLAGS) -I../../pdns/ext/rapidjson/include #if !ALLSTATIC #install-exec-local: # install .lib/libremotebackend.so.0.0.0 @libdir@ #endif EXTRA_DIST=OBJECTFILES OBJECTLIBS EXTRA_PROGRAMS=test_remotebackend_pipe test_remotebackend_http test_remotebackend_post test_remotebackend_json EXTRA_LTLIBRARIES=libtestremotebackend.la lib_LTLIBRARIES = libremotebackend.la libremotebackend_la_SOURCES=remotebackend.hh remotebackend.cc unixconnector.cc httpconnector.cc pipeconnector.cc libremotebackend_la_LDFLAGS=-module -avoid-version libremotebackend_la_LIBS=$(LIBCURL_LIBS) TESTS_ENVIRONMENT = env BOOST_TEST_LOG_LEVEL=message REMOTEBACKEND_HTTP=$(REMOTEBACKEND_HTTP) ./testrunner.sh TESTS=test_remotebackend_pipe test_remotebackend_http test_remotebackend_post test_remotebackend_json BUILT_SOURCES=../../pdns/dnslabeltext.cc ../../pdns/dnslabeltext.cc: ../../pdns/dnslabeltext.rl make -C ../../pdns dnslabeltext.cc libtestremotebackend_la_SOURCES=../../pdns/dnsbackend.hh ../../pdns/dnsbackend.cc ../../pdns/ueberbackend.hh ../../pdns/ueberbackend.cc \ ../../pdns/nameserver.cc ../../pdns/misc.cc ../../pdns/arguments.hh \ ../../pdns/unix_utility.cc ../../pdns/logger.cc ../../pdns/statbag.cc ../../pdns/arguments.hh ../../pdns/arguments.cc ../../pdns/qtype.cc ../../pdns/dnspacket.cc \ ../../pdns/dnswriter.cc ../../pdns/base64.cc ../../pdns/base32.cc ../../pdns/dnsrecords.cc ../../pdns/dnslabeltext.cc ../../pdns/dnsparser.cc \ ../../pdns/rcpgenerator.cc ../../pdns/ednssubnet.cc ../../pdns/nsecrecords.cc ../../pdns/sillyrecords.cc ../../pdns/dnssecinfra.cc \ ../../pdns/aes/dns_random.cc ../../pdns/packetcache.hh ../../pdns/packetcache.cc \ ../../pdns/aes/aescpp.h ../../pdns/dns.hh ../../pdns/dns.cc ../../pdns/json.hh ../../pdns/json.cc \ ../../pdns/aes/aescrypt.c ../../pdns/aes/aes.h ../../pdns/aes/aeskey.c ../../pdns/aes/aes_modes.c ../../pdns/aes/aesopt.h \ ../../pdns/aes/aestab.c ../../pdns/aes/aestab.h ../../pdns/aes/brg_endian.h ../../pdns/aes/brg_types.h ../pipebackend/coprocess.cc \ remotebackend.hh remotebackend.cc unixconnector.cc httpconnector.cc pipeconnector.cc libtestremotebackend_la_CFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns libtestremotebackend_la_CXXFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_SOURCES=test-remotebackend.cc test-remotebackend-pipe.cc test_remotebackend_http_SOURCES=test-remotebackend.cc test-remotebackend-http.cc ../../config.h test_remotebackend_post_SOURCES=test-remotebackend.cc test-remotebackend-post.cc ../../config.h test_remotebackend_json_SOURCES=test-remotebackend.cc test-remotebackend-json.cc ../../config.h test_remotebackend_pipe_CFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_CXXFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_pipe_LDADD=libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_http_CFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_http_CXXFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_http_LDADD=libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_post_CFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_post_CXXFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_post_LDADD=libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) test_remotebackend_json_CFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_json_CXXFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) -g -O0 -I../../pdns test_remotebackend_json_LDADD=libtestremotebackend.la @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) ../../pdns/ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_SERIALIZATION_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS) @LIBDL@ $(LIBCURL_LIBS) pdns-3.3/modules/remotebackend/httpconnector.cc0000644000014601777760000003637612154344061023256 0ustar00jenkinsnogroup00000000000000#include "remotebackend.hh" #include #include #include #include #include #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #ifdef REMOTEBACKEND_HTTP #include #endif #ifndef UNIX_PATH_MAX #define UNIX_PATH_MAX 108 #endif #ifdef REMOTEBACKEND_HTTP HTTPConnector::HTTPConnector(std::map options) { this->d_url = options.find("url")->second; if (options.find("url-suffix") != options.end()) { this->d_url_suffix = options.find("url-suffix")->second; } else { this->d_url_suffix = ""; } this->timeout = 2; this->d_post = false; this->d_post_json = false; if (options.find("timeout") != options.end()) { this->timeout = boost::lexical_cast(options.find("timeout")->second)/1000; } if (options.find("post") != options.end()) { std::string val = options.find("post")->second; if (val == "yes" || val == "true" || val == "on" || val == "1") { this->d_post = true; } } if (options.find("post_json") != options.end()) { std::string val = options.find("post_json")->second; if (val == "yes" || val == "true" || val == "on" || val == "1") { this->d_post_json = true; } } if (options.find("capath") != options.end()) this->d_capath = options.find("capath")->second; if (options.find("cafile") != options.end()) this->d_cafile = options.find("cafile")->second; } HTTPConnector::~HTTPConnector() { this->d_c = NULL; } // friend method for writing data into our buffer size_t httpconnector_write_data(void *buffer, size_t size, size_t nmemb, void *userp) { HTTPConnector *tc = reinterpret_cast(userp); std::string tmp(reinterpret_cast(buffer), size*nmemb); tc->d_data += tmp; return nmemb; } // converts json value into string bool HTTPConnector::json2string(const rapidjson::Value &input, std::string &output) { if (input.IsString()) output = input.GetString(); else if (input.IsNull()) output = ""; else if (input.IsUint64()) output = lexical_cast(input.GetUint64()); else if (input.IsInt64()) output = lexical_cast(input.GetInt64()); else if (input.IsUint()) output = lexical_cast(input.GetUint()); else if (input.IsInt()) output = lexical_cast(input.GetInt()); else return false; return true; } void HTTPConnector::addUrlComponent(const rapidjson::Value ¶meters, const char *element, std::stringstream& ss) { rapidjson::Value nullval; std::string sparam; nullval.SetNull(); const rapidjson::Value& param = (parameters.HasMember(element)?parameters[element]:nullval); if (param.IsNull() == false) { json2string(param, sparam); ss << "/" << sparam; } } template std::string buildMemberListArgs(std::string prefix, const T* value, CURL* curlContext) { std::stringstream stream; for (rapidjson::Value::ConstMemberIterator itr = value->MemberBegin(); itr != value->MemberEnd(); itr++) { stream << prefix << "[" << itr->name.GetString() << "]="; if (itr->value.IsUint64()) { stream << itr->value.GetUint64(); } else if (itr->value.IsInt64()) { stream << itr->value.GetInt64(); } else if (itr->value.IsUint()) { stream << itr->value.GetUint(); } else if (itr->value.IsInt()) { stream << itr->value.GetInt(); } else if (itr->value.IsBool()) { stream << (itr->value.GetBool() ? 1 : 0); } else if (itr->value.IsString()) { char *tmpstr = curl_easy_escape(curlContext, itr->value.GetString(), 0); stream << tmpstr; curl_free(tmpstr); } stream << "&"; } return stream.str(); } // builds our request (near-restful) void HTTPConnector::restful_requestbuilder(const std::string &method, const rapidjson::Value ¶meters, struct curl_slist **slist) { std::stringstream ss; std::string sparam; char *tmpstr; // special names are qname, name, zonename, kind, others go to headers ss << d_url; ss << "/" << method; // add the url components, if found, in following order. // id must be first due to the fact that the qname/name can be empty addUrlComponent(parameters, "id", ss); addUrlComponent(parameters, "domain_id", ss); addUrlComponent(parameters, "zonename", ss); addUrlComponent(parameters, "qname", ss); addUrlComponent(parameters, "name", ss); addUrlComponent(parameters, "kind", ss); addUrlComponent(parameters, "qtype", ss); (*slist) = NULL; // set the correct type of request based on method if (method == "activateDomainKey" || method == "deactivateDomainKey") { // create an empty post curl_easy_setopt(d_c, CURLOPT_POST, 1); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, 0); } else if (method == "addDomainKey") { // create post with keydata char *postfields; int nsize; const rapidjson::Value& param = parameters["key"]; tmpstr = curl_easy_escape(d_c, param["content"].GetString(), 0); nsize = 35 + strlen(tmpstr); postfields = new char[nsize]; nsize = snprintf(postfields, nsize, "flags=%u&active=%d&content=%s", param["flags"].GetUint(), (param["active"].GetBool() ? 1 : 0), tmpstr); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, nsize); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, postfields); curl_free(tmpstr); delete postfields; } else if (method == "superMasterBackend") { std::stringstream ss2; addUrlComponent(parameters, "ip", ss); addUrlComponent(parameters, "domain", ss); // then we need to serialize rrset payload into POST size_t index = 0; for(rapidjson::Value::ConstValueIterator itr = parameters["nsset"].Begin(); itr != parameters["nsset"].End(); itr++) { index++; ss2 << buildMemberListArgs("nsset[" + boost::lexical_cast(index) + "]", itr, d_c); } // then give it to curl std::string out = ss2.str(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "createSlaveDomain") { addUrlComponent(parameters, "ip", ss); addUrlComponent(parameters, "domain", ss); if (parameters.HasMember("account")) { std::string out = parameters["account"].GetString(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else { curl_easy_setopt(d_c, CURLOPT_POST, 1); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, 0); } } else if (method == "replaceRRSet") { std::stringstream ss2; size_t index = 0; for(rapidjson::Value::ConstValueIterator itr = parameters["rrset"].Begin(); itr != parameters["rrset"].End(); itr++) { index++; ss2 << buildMemberListArgs("rrset[" + boost::lexical_cast(index) + "]", itr, d_c); } // then give it to curl std::string out = ss2.str(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "feedRecord") { std::string out = buildMemberListArgs("rr", ¶meters["rr"], d_c); addUrlComponent(parameters, "trxid", ss); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "feedEnts") { std::stringstream ss2; addUrlComponent(parameters, "trxid", ss); for(rapidjson::Value::ConstValueIterator itr = parameters["nonterm"].Begin(); itr != parameters["nonterm"].End(); itr++) { tmpstr = curl_easy_escape(d_c, itr->GetString(), 0); ss2 << "nonterm[]=" << tmpstr << "&"; curl_free(tmpstr); } std::string out = ss2.str(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "feedEnts3") { std::stringstream ss2; addUrlComponent(parameters, "domain", ss); addUrlComponent(parameters, "trxid", ss); ss2 << "times=" << parameters["times"].GetInt() << "&salt=" << parameters["salt"].GetString() << "&narrow=" << (parameters["narrow"].GetBool() ? 1 : 0) << "&"; for(rapidjson::Value::ConstValueIterator itr = parameters["nonterm"].Begin(); itr != parameters["nonterm"].End(); itr++) { tmpstr = curl_easy_escape(d_c, itr->GetString(), 0); ss2 << "nonterm[]=" << tmpstr << "&"; curl_free(tmpstr); } std::string out = ss2.str(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "startTransaction") { addUrlComponent(parameters, "domain", ss); addUrlComponent(parameters, "trxid", ss); curl_easy_setopt(d_c, CURLOPT_POST, 1); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, 0); } else if (method == "commitTransaction" || method == "abortTransaction") { addUrlComponent(parameters, "trxid", ss); curl_easy_setopt(d_c, CURLOPT_POST, 1); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, 0); } else if (method == "calculateSOASerial") { addUrlComponent(parameters, "domain", ss); std::string out = buildMemberListArgs("sd", ¶meters["sd"], d_c); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); } else if (method == "setDomainMetadata") { // copy all metadata values into post std::stringstream ss2; const rapidjson::Value& param = parameters["value"]; curl_easy_setopt(d_c, CURLOPT_POST, 1); // this one has values too if (param.IsArray()) { for(rapidjson::Value::ConstValueIterator i = param.Begin(); i != param.End(); i++) { ss2 << "value[]=" << i->GetString() << "&"; } } sparam = ss2.str(); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, sparam.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, sparam.c_str()); } else if (method == "removeDomainKey") { // this one is delete curl_easy_setopt(d_c, CURLOPT_CUSTOMREQUEST, "DELETE"); } else if (method == "setNotified") { tmpstr = (char*)malloc(128); snprintf(tmpstr, 128, "serial=%u", parameters["serial"].GetInt()); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, strlen(tmpstr)); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, tmpstr); free(tmpstr); } else { // perform normal get curl_easy_setopt(d_c, CURLOPT_HTTPGET, 1); } // put everything else into headers for (rapidjson::Value::ConstMemberIterator iter = parameters.MemberBegin(); iter != parameters.MemberEnd(); ++iter) { char header[1024]; const char *member = iter->name.GetString(); // these are not put into headers for obvious reasons if (!strncmp(member,"zonename",8) || !strncmp(member,"qname",5) || !strncmp(member,"name",4) || !strncmp(member,"kind",4) || !strncmp(member,"qtype",5) || !strncmp(member,"id",2) || !strncmp(member,"key",3)) continue; if (json2string(parameters[member], sparam)) { snprintf(header, sizeof header, "X-RemoteBackend-%s: %s", iter->name.GetString(), sparam.c_str()); (*slist) = curl_slist_append((*slist), header); } }; // finally add suffix and store url ss << d_url_suffix; curl_easy_setopt(d_c, CURLOPT_URL, ss.str().c_str()); // store headers into request curl_easy_setopt(d_c, CURLOPT_HTTPHEADER, *slist); } void HTTPConnector::post_requestbuilder(const rapidjson::Document &input, struct curl_slist **slist) { if (this->d_post_json) { // simple case, POST JSON into url. nothing fancy. std::string out = makeStringFromDocument(input); (*slist) = curl_slist_append((*slist), "Content-Type: text/javascript; charset=utf-8"); curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, out.size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, out.c_str()); curl_easy_setopt(d_c, CURLOPT_URL, d_url.c_str()); curl_easy_setopt(d_c, CURLOPT_HTTPHEADER, *slist); } else { std::stringstream url,content; char *tmpstr; // call url/method.suffix rapidjson::StringBuffer output; rapidjson::Writer w(output); input["parameters"].Accept(w); url << d_url << "/" << input["method"].GetString() << d_url_suffix; // then build content tmpstr = curl_easy_escape(d_c, output.GetString(), 0); content << "parameters=" << tmpstr; // convert into parameters=urlencoded curl_easy_setopt(d_c, CURLOPT_POSTFIELDSIZE, content.str().size()); curl_easy_setopt(d_c, CURLOPT_COPYPOSTFIELDS, content.str().c_str()); free(tmpstr); curl_easy_setopt(d_c, CURLOPT_URL, d_url.c_str()); curl_easy_setopt(d_c, CURLOPT_URL, url.str().c_str()); } } int HTTPConnector::send_message(const rapidjson::Document &input) { int rv; long rcode; struct curl_slist *slist; std::vector members; std::string method; // initialize curl d_c = curl_easy_init(); d_data = ""; curl_easy_setopt(d_c, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(d_c, CURLOPT_TIMEOUT, this->timeout); // turn off peer verification or set verification roots if (d_capath.empty()) { if (d_cafile.empty()) { curl_easy_setopt(d_c, CURLOPT_SSL_VERIFYPEER, 0); } else { curl_easy_setopt(d_c, CURLOPT_CAINFO, d_cafile.c_str()); } } else { curl_easy_setopt(d_c, CURLOPT_CAPATH, d_capath.c_str()); } slist = NULL; // build request based on mode if (d_post) post_requestbuilder(input, &slist); else restful_requestbuilder(input["method"].GetString(), input["parameters"], &slist); // setup write function helper curl_easy_setopt(d_c, CURLOPT_WRITEFUNCTION, &(httpconnector_write_data)); curl_easy_setopt(d_c, CURLOPT_WRITEDATA, this); // then we actually do it if (curl_easy_perform(d_c) != CURLE_OK) { // boo, it failed rv = -1; } else { // ensure the result was OK if (curl_easy_getinfo(d_c, CURLINFO_RESPONSE_CODE, &rcode) != CURLE_OK || rcode < 200 || rcode > 299) { rv = -1; } else { // ok. if d_data == 0 but rcode is 2xx then result:true if (this->d_data.size() == 0) this->d_data = "{\"result\": true}"; rv = this->d_data.size(); } } // clean up resources curl_slist_free_all(slist); curl_easy_cleanup(d_c); return rv; } int HTTPConnector::recv_message(rapidjson::Document &output) { rapidjson::StringStream ss(d_data.c_str()); int rv = -1; output.ParseStream<0>(ss); // offer whatever we read in send_message if (output.HasParseError() == false) rv = d_data.size(); d_data = ""; // cleanup here return rv; } #endif pdns-3.3/modules/remotebackend/test-remotebackend-json.cc0000644000014601777760000000314412154344061025076 0ustar00jenkinsnogroup00000000000000#include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include #include #include #include "pdns/json.hh" #include "pdns/statbag.hh" #include "pdns/packetcache.hh" StatBag S; PacketCache PC; ArgvMap &arg() { static ArgvMap arg; return arg; }; class RemoteLoader { public: RemoteLoader(); }; DNSBackend *be; #ifdef REMOTEBACKEND_HTTP #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE unit #include #include #include #include struct RemotebackendSetup { RemotebackendSetup() { be = 0; try { // setup minimum arguments ::arg().set("module-dir")=""; new RemoteLoader(); BackendMakers().launch("remote"); // then get us a instance of it ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns/endpoint.json,post=1,post_json=1"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; } catch (AhuException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } ~RemotebackendSetup() { } }; BOOST_GLOBAL_FIXTURE( RemotebackendSetup ); #else #include int main(void) { std::cout << "No HTTP support in remotebackend - skipping test" << std::endl; return 0; } #endif pdns-3.3/modules/remotebackend/test-remotebackend-post.cc0000644000014601777760000000311212154344061025105 0ustar00jenkinsnogroup00000000000000#include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include #include #include #include "pdns/json.hh" #include "pdns/statbag.hh" #include "pdns/packetcache.hh" StatBag S; PacketCache PC; ArgvMap &arg() { static ArgvMap arg; return arg; }; class RemoteLoader { public: RemoteLoader(); }; DNSBackend *be; #ifdef REMOTEBACKEND_HTTP #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE unit #include #include #include #include struct RemotebackendSetup { RemotebackendSetup() { be = 0; try { // setup minimum arguments ::arg().set("module-dir")=""; new RemoteLoader(); BackendMakers().launch("remote"); // then get us a instance of it ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns,post=1"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; } catch (AhuException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } ~RemotebackendSetup() { } }; BOOST_GLOBAL_FIXTURE( RemotebackendSetup ); #else #include int main(void) { std::cout << "No HTTP support in remotebackend - skipping test" << std::endl; return 0; } #endif pdns-3.3/modules/randombackend/0000755000014601777760000000000012165464054020032 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/randombackend/OBJECTLIBS0000644000014601777760000000000012145360424021355 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/randombackend/OBJECTFILES0000644000014601777760000000002012145360424021470 0ustar00jenkinsnogroup00000000000000randombackend.o pdns-3.3/modules/randombackend/Makefile.in0000644000014601777760000004613012165464027022103 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/randombackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) librandombackend_la_LIBADD = am_librandombackend_la_OBJECTS = randombackend.lo librandombackend_la_OBJECTS = $(am_librandombackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent librandombackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(librandombackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(librandombackend_la_SOURCES) DIST_SOURCES = $(librandombackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = librandombackend.la librandombackend_la_SOURCES = randombackend.cc librandombackend_la_LDFLAGS = -module -avoid-version all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/randombackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/randombackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done librandombackend.la: $(librandombackend_la_OBJECTS) $(librandombackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(librandombackend_la_LINK) -rpath $(libdir) $(librandombackend_la_OBJECTS) $(librandombackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randombackend.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/randombackend/Makefile.am0000644000014601777760000000030512155677761022076 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ EXTRA_DIST=OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = librandombackend.la librandombackend_la_SOURCES=randombackend.cc librandombackend_la_LDFLAGS=-module -avoid-version pdns-3.3/modules/randombackend/randombackend.cc0000644000014601777760000000615212145360424023127 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "pdns/utility.hh" #include "pdns/dnsbackend.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include /* FIRST PART */ class RandomBackend : public DNSBackend { public: RandomBackend(const string &suffix="") { setArgPrefix("random"+suffix); d_ourname=getArg("hostname"); } bool list(const string &target, int id) { return false; // we don't support AXFR } void lookup(const QType &type, const string &qdomain, DNSPacket *p, int zoneId) { if((type.getCode()!=QType::ANY && type.getCode()!=QType::A) || !pdns_iequals(qdomain, d_ourname)) // we only know about random.example.com A by default d_answer=""; // no answer else { ostringstream os; os< * Steinbuch Centre for Computing * Karlsruhe Institute of Technology * */ #include #include #include #include #include "pdns/namespaces.hh" class OracleException : public DBException { public: OracleException (string r) : DBException(r) {} OracleException (string context, OCIError *theErrorHandle) : DBException(context + ": ORA-UNKNOWN") { if (theErrorHandle != NULL) { char msg[2048]; sb4 errcode = 0; msg[0] = '\0'; OCIErrorGet((void *) theErrorHandle, 1, NULL, &errcode, (OraText*) msg, sizeof(msg), OCI_HTYPE_ERROR); reason = context + ": " + msg; } } }; class OracleBackend : public DNSBackend { public: OracleBackend(const string &suffix = "", OCIEnv *envh = NULL, char *poolname = NULL); virtual ~OracleBackend(); void lookup(const QType &qtype, const string &qname, DNSPacket *p = 0, int zoneId = -1); bool getBeforeAndAfterNames(uint32_t zoneId, const string& zone, const string& name, string& before, string& after); bool getBeforeAndAfterNamesAbsolute(uint32_t zoneId, const string& name, string& unhashed, string& before, string& after); bool get(DNSResourceRecord &rr); vector getDomainMasters(const string &domain, int zoneId); bool isMaster(const string &domain, const string &master); bool getDomainInfo(const string &domain, DomainInfo &di); void alsoNotifies(const string &domain, set *addrs); void getUnfreshSlaveInfos(vector* domains); void getUpdatedMasters(vector* domains); void setFresh(uint32_t zoneId); // No, it's not int zoneId. Really. void setNotified(uint32_t zoneId, uint32_t serial); // ditto bool list(const string &domain, int zoneId); bool startTransaction(const string &domain, int zoneId); bool feedRecord(const DNSResourceRecord &rr); bool commitTransaction(); bool abortTransaction(); bool superMasterBackend(const string &ip, const string &domain, const vector &nsset, string *account, DNSBackend **backend); bool createSlaveDomain(const string &ip, const string &domain, const string &account); bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); bool getTSIGKey(const string& name, string* algorithm, string* content); bool getDomainKeys(const string& name, unsigned int kind, vector& keys); bool removeDomainKey(const string& name, unsigned int id); int addDomainKey(const string& name, const KeyData& key); bool activateDomainKey(const string& name, unsigned int id); bool deactivateDomainKey(const string& name, unsigned int id); private: OCIEnv *oraenv; OCIError *oraerr; OCISvcCtx *pooledSvcCtx; OCIAuthInfo *masterAuthHandle; OCISvcCtx *masterSvcCtx; string basicQuerySQL; string basicIdQuerySQL; string anyQuerySQL; string anyIdQuerySQL; string listQuerySQL; string zoneInfoQuerySQL; string alsoNotifyQuerySQL; string zoneMastersQuerySQL; string isZoneMasterQuerySQL; string deleteZoneQuerySQL; string zoneSetLastCheckQuerySQL; string insertRecordQuerySQL; string finalizeAXFRQuerySQL; string unfreshZonesQuerySQL; string updatedMastersQuerySQL; string acceptSupernotificationQuerySQL; string insertSlaveQuerySQL; string insertMasterQuerySQL; string zoneSetNotifiedSerialQuerySQL; string prevNextNameQuerySQL; string prevNextHashQuerySQL; string getZoneMetadataQuerySQL; string delZoneMetadataQuerySQL; string setZoneMetadataQuerySQL; string getTSIGKeyQuerySQL; string getZoneKeysQuerySQL; string delZoneKeyQuerySQL; string addZoneKeyQuerySQL; string setZoneKeyStateQuerySQL; OCIStmt *curStmtHandle; const char *curStmtKey; int openTransactionZoneID; char myServerName[512]; char mQueryName[512]; char mQueryType[64]; char mQueryContent[4001]; char mQueryZone[512]; char mQueryAddr[64]; int mQueryZoneId; int mQueryTimestamp; char mResultName[512]; sb2 mResultNameInd; uint32_t mResultTTL; sb2 mResultTTLInd; char mResultType[64]; sb2 mResultTypeInd; char mResultContent[4001]; sb2 mResultContentInd; int mResultZoneId; sb2 mResultZoneIdInd; int mResultLastChange; sb2 mResultLastChangeInd; int mResultIsAuth; sb2 mResultIsAuthInd; char mResultPrevName[512]; sb2 mResultPrevNameInd; char mResultNextName[512]; sb2 mResultNextNameInd; bool d_dnssecQueries; void Cleanup(); void openMasterConnection(); bool setDomainKeyState(const string& name, unsigned int id, int active); OCIStmt* prepare_query (OCISvcCtx* orasvc, string& code, const char *key); void release_query (OCIStmt *stmt, const char *key); void define_output_str (OCIStmt *s, ub4 pos, sb2 *ind, char *buf, sb4 buflen); void define_output_int (OCIStmt *s, ub4 pos, sb2 *ind, int *buf); void define_output_uint (OCIStmt *s, ub4 pos, sb2 *ind, unsigned int *buf); void define_output_uint16 (OCIStmt *s, ub4 pos, sb2 *ind, uint16_t *buf); void define_output_uint32 (OCIStmt *s, ub4 pos, sb2 *ind, uint32_t *buf); void check_indicator (sb2 ind, bool null_okay); void define_fwd_query (OCIStmt *s); void bind_str (OCIStmt *s, const char *name, char *buf, sb4 buflen); void bind_str_failokay (OCIStmt *s, const char *name, char *buf, sb4 buflen); void bind_str_ind (OCIStmt *s, const char *name, char *buf, sb4 buflen, sb2 *ind); void bind_int (OCIStmt *s, const char *name, int *buf); void bind_uint (OCIStmt *s, const char *name, unsigned int *buf); void bind_uint16 (OCIStmt *s, const char *name, uint16_t *buf); void bind_uint16_ind (OCIStmt *s, const char *name, uint16_t *buf, sb2 *ind); void bind_uint32 (OCIStmt *s, const char *name, uint32_t *buf); }; /* vi: set sw=2 et : */ pdns-3.3/modules/oraclebackend/OBJECTLIBS0000644000014601777760000000000012136555572021354 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/oraclebackend/oraclebackend.cc0000644000014601777760000017414012160025353023100 0ustar00jenkinsnogroup00000000000000// $Id$ /* * Copyright (c) 2010-2011 * * Maik Zumstrull * Steinbuch Centre for Computing * Karlsruhe Institute of Technology * */ #include #include #include "pdns/namespaces.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "oraclebackend.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "pdns/lock.hh" #include static const char *basicQueryKey = "PDNS_Basic_Query"; static const char *basicQueryDefaultAuthSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change, auth " "FROM Records " "WHERE type = :type AND fqdn = lower(:name)"; static const char *basicQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change " "FROM Records " "WHERE type = :type AND fqdn = lower(:name)"; static const char *basicIdQueryKey = "PDNS_Basic_Id_Query"; static const char *basicIdQueryDefaultAuthSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change, auth " "FROM Records " "WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid"; static const char *basicIdQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change " "FROM Records " "WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid"; static const char *anyQueryKey = "PDNS_ANY_Query"; static const char *anyQueryDefaultAuthSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change, auth " "FROM Records " "WHERE fqdn = lower(:name)" " AND type IS NOT NULL " "ORDER BY type"; static const char *anyQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change " "FROM Records " "WHERE fqdn = lower(:name)" " AND type IS NOT NULL " "ORDER BY type"; static const char *anyIdQueryKey = "PDNS_ANY_Id_Query"; static const char *anyIdQueryDefaultAuthSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change, auth " "FROM Records " "WHERE fqdn = lower(:name)" " AND zone_id = :zoneid" " AND type IS NOT NULL " "ORDER BY type"; static const char *anyIdQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change " "FROM Records " "WHERE fqdn = lower(:name)" " AND zone_id = :zoneid" " AND type IS NOT NULL " "ORDER BY type"; static const char *listQueryKey = "PDNS_List_Query"; static const char *listQueryDefaultAuthSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change, auth " "FROM Records " "WHERE zone_id = :zoneid" " AND type IS NOT NULL " "ORDER BY fqdn, type"; static const char *listQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change " "FROM Records " "WHERE zone_id = :zoneid" " AND type IS NOT NULL " "ORDER BY fqdn, type"; static const char *zoneInfoQueryKey = "PDNS_Zone_Info_Query"; static const char *zoneInfoQueryDefaultSQL = "SELECT id, name, type, last_check, serial, notified_serial " "FROM Zones " "WHERE name = lower(:name)"; static const char *alsoNotifyQueryKey = "PDNS_Also_Notify_Query"; static const char *alsoNotifyQueryDefaultSQL = "SELECT an.hostaddr " "FROM Zones z JOIN ZoneAlsoNotify an ON z.id = an.zone_id " "WHERE z.name = lower(:name)"; static const char *zoneMastersQueryKey = "PDNS_Zone_Masters_Query"; static const char *zoneMastersQueryDefaultSQL = "SELECT master " "FROM Zonemasters " "WHERE zone_id = :zoneid"; static const char *isZoneMasterQueryKey = "PDNS_Is_Zone_Master_Query"; static const char *isZoneMasterQueryDefaultSQL = "SELECT zm.master " "FROM Zones z JOIN Zonemasters zm ON z.id = zm.zone_id " "WHERE z.name = lower(:name) AND zm.master = :master"; static const char *deleteZoneQueryKey = "PDNS_Delete_Zone_Query"; static const char *deleteZoneQueryDefaultSQL = "DELETE FROM Records WHERE zone_id = :zoneid"; static const char *zoneSetLastCheckQueryKey = "PDNS_Zone_Set_Last_Check_Query"; static const char *zoneSetLastCheckQueryDefaultSQL = "UPDATE Zones SET last_check = :lastcheck WHERE id = :zoneid"; static const char *zoneSetNotifiedSerialQueryKey = "PDNS_Zone_Set_NSerial_Query"; static const char *zoneSetNotifiedSerialQueryDefaultSQL = "UPDATE Zones SET notified_serial = :serial WHERE id = :zoneid"; static const char *insertRecordQueryKey = "PDNS_Insert_Record_Query"; static const char *insertRecordQueryDefaultSQL = "INSERT INTO Records (id, fqdn, zone_id, ttl, type, content) " "VALUES (records_id_seq.NEXTVAL, lower(:name), :zoneid, :ttl, :type, :content)"; static const char *finalizeAXFRQueryKey = "PDNS_Finalize_AXFR"; static const char *finalizeAXFRQueryDefaultSQL = "DECLARE\n" " zone_id INTEGER := :zoneid;\n" "BEGIN\n" " NULL;\n" "END;"; static const char *unfreshZonesQueryKey = "PDNS_Unfresh_Zones_Query"; static const char *unfreshZonesQueryDefaultSQL = "SELECT z.id, z.name, z.last_check, z.serial, zm.master " "FROM Zones z JOIN Zonemasters zm ON z.id = zm.zone_id " "WHERE z.type = 'SLAVE' " " AND (z.last_check IS NULL OR z.last_check + z.refresh < :ts)" "ORDER BY z.id"; static const char *updatedMastersQueryKey = "PDNS_Updated_Masters_Query"; static const char *updatedMastersQueryDefaultSQL = "SELECT id, name, serial, notified_serial " "FROM Zones " "WHERE type = 'MASTER' " "AND (notified_serial IS NULL OR notified_serial < serial)"; static const char *acceptSupernotificationQueryKey = "PDNS_Accept_Supernotification_Query"; static const char *acceptSupernotificationQueryDefaultSQL = "SELECT name " "FROM Supermasters " "WHERE ip = :ip AND nameserver = lower(:ns)"; static const char *insertSlaveQueryKey = "PDNS_Insert_Slave_Query"; static const char *insertSlaveQueryDefaultSQL = "INSERT INTO Zones (id, name, type) " "VALUES (zones_id_seq.NEXTVAL, lower(:zone), 'SLAVE') " "RETURNING id INTO :zoneid"; static const char *insertMasterQueryKey = "PDNS_Insert_Master_Query"; static const char *insertMasterQueryDefaultSQL = "INSERT INTO Zonemasters (zone_id, master) " "VALUES (:zoneid, :ip)"; static const char *prevNextNameQueryKey = "PDNS_Prev_Next_Name_Query"; static const char *prevNextNameQueryDefaultSQL = "BEGIN\n" " get_canonical_prev_next(:zoneid, :name, :prev, :next);\n" "END;"; static const char *prevNextHashQueryKey = "PDNS_Prev_Next_Hash_Query"; static const char *prevNextHashQueryDefaultSQL = "BEGIN\n" " get_hashed_prev_next(:zoneid, :hash, :unhashed, :prev, :next);\n" "END;"; static const char *getZoneMetadataQueryKey = "PDNS_Get_Zone_Metadata"; static const char *getZoneMetadataQueryDefaultSQL = "SELECT md.meta_content " "FROM Zones z JOIN ZoneMetadata md ON z.id = md.zone_id " "WHERE z.name = lower(:name) AND md.meta_type = :kind " "ORDER BY md.meta_ind"; static const char *delZoneMetadataQueryKey = "PDNS_Del_Zone_Metadata"; static const char *delZoneMetadataQueryDefaultSQL = "DELETE FROM ZoneMetadata md " "WHERE zone_id = (SELECT id FROM Zones z WHERE z.name = lower(:name)) " " AND md.meta_type = :kind"; static const char *setZoneMetadataQueryKey = "PDNS_Set_Zone_Metadata"; static const char *setZoneMetadataQueryDefaultSQL = "INSERT INTO ZoneMetadata (zone_id, meta_type, meta_ind, meta_content) " "VALUES (" " (SELECT id FROM Zones WHERE name = lower(:name))," " :kind, :i, :content" ")"; static const char *getTSIGKeyQueryKey = "PDNS_Get_TSIG_Key"; static const char *getTSIGKeyQueryDefaultSQL = "SELECT algorithm, secret " "FROM TSIGKeys " "WHERE name = :name"; static const char *getZoneKeysQueryKey = "PDNS_Get_Zone_Keys"; static const char *getZoneKeysQueryDefaultSQL = "SELECT k.id, k.flags, k.active, k.keydata " "FROM ZoneDNSKeys k JOIN Zones z ON z.id = k.zone_id " "WHERE z.name = lower(:name)"; static const char *delZoneKeyQueryKey = "PDNS_Del_Zone_Key"; static const char *delZoneKeyQueryDefaultSQL = "DELETE FROM ZoneDNSKeys WHERE id = :keyid"; static const char *addZoneKeyQueryKey = "PDNS_Add_Zone_Key"; static const char *addZoneKeyQueryDefaultSQL = "INSERT INTO ZoneDNSKeys (id, zone_id, flags, active, keydata) " "VALUES (" " zonednskeys_id_seq.NEXTVAL," " (SELECT id FROM Zones WHERE name = lower(:name))," " :flags," " :active," " :content" ") RETURNING id INTO :keyid"; static const char *setZoneKeyStateQueryKey = "PDNS_Set_Zone_Key_State"; static const char *setZoneKeyStateQueryDefaultSQL = "UPDATE ZoneDNSKeys SET active = :active WHERE id = :keyid"; static void string_to_cbuf (char *buf, const string& s, size_t bufsize) { if (s.size() >= bufsize) { throw std::overflow_error("OracleBackend: string does not fit into char buffer"); } strncpy(buf, s.c_str(), bufsize); } OracleBackend::OracleBackend (const string &suffix, OCIEnv *envh, char *poolname) { setArgPrefix(string("oracle") + suffix); sword err; // Initialize everything in a known state oraenv = envh; oraerr = NULL; pooledSvcCtx = NULL; masterAuthHandle = NULL; masterSvcCtx = NULL; curStmtHandle = NULL; openTransactionZoneID = -1; try { d_dnssecQueries = mustDo("dnssec"); } catch (ArgException e) { d_dnssecQueries = false; } // Process configuration options string_to_cbuf(myServerName, getArg("nameserver-name"), sizeof(myServerName)); if (d_dnssecQueries) { basicQuerySQL = getArg("basic-query-auth"); basicIdQuerySQL = getArg("basic-id-query-auth"); anyQuerySQL = getArg("any-query-auth"); anyIdQuerySQL = getArg("any-id-query-auth"); listQuerySQL = getArg("list-query-auth"); } else { basicQuerySQL = getArg("basic-query"); basicIdQuerySQL = getArg("basic-id-query"); anyQuerySQL = getArg("any-query"); anyIdQuerySQL = getArg("any-id-query"); listQuerySQL = getArg("list-query"); } zoneInfoQuerySQL = getArg("zone-info-query"); alsoNotifyQuerySQL = getArg("also-notify-query"); zoneMastersQuerySQL = getArg("zone-masters-query"); isZoneMasterQuerySQL = getArg("is-zone-master-query"); deleteZoneQuerySQL = getArg("delete-zone-query"); zoneSetLastCheckQuerySQL = getArg("zone-set-last-check-query"); insertRecordQuerySQL = getArg("insert-record-query"); finalizeAXFRQuerySQL = getArg("finalize-axfr-query"); unfreshZonesQuerySQL = getArg("unfresh-zones-query"); updatedMastersQuerySQL = getArg("updated-masters-query"); acceptSupernotificationQuerySQL = getArg("accept-supernotification-query"); insertSlaveQuerySQL = getArg("insert-slave-query"); insertMasterQuerySQL = getArg("insert-master-query"); zoneSetNotifiedSerialQuerySQL = getArg("zone-set-notified-serial-query"); prevNextNameQuerySQL = getArg("prev-next-name-query"); prevNextHashQuerySQL = getArg("prev-next-hash-query"); getZoneMetadataQuerySQL = getArg("get-zone-metadata-query"); delZoneMetadataQuerySQL = getArg("del-zone-metadata-query"); setZoneMetadataQuerySQL = getArg("set-zone-metadata-query"); getTSIGKeyQuerySQL = getArg("get-tsig-key-query"); getZoneKeysQuerySQL = getArg("get-zone-keys-query"); delZoneKeyQuerySQL = getArg("del-zone-key-query"); addZoneKeyQuerySQL = getArg("add-zone-key-query"); setZoneKeyStateQuerySQL = getArg("set-zone-key-state-query"); // Allocate an error handle err = OCIHandleAlloc(oraenv, (void**) &oraerr, OCI_HTYPE_ERROR, 0, NULL); if (err == OCI_ERROR) { throw OracleException("OCIHandleAlloc"); } // Logon to the database err = OCISessionGet(oraenv, oraerr, &pooledSvcCtx, NULL, (OraText*) poolname, strlen(poolname), NULL, 0, NULL, NULL, NULL, OCI_SESSGET_SPOOL); if (err == OCI_ERROR) { throw OracleException("Opening Oracle session", oraerr); } } void OracleBackend::openMasterConnection () { sword err; if (masterSvcCtx == NULL) { err = OCIHandleAlloc(oraenv, (void**) &masterAuthHandle, OCI_HTYPE_AUTHINFO, 0, NULL); if (err == OCI_ERROR) { throw OracleException("openMasterConnection: allocating auth handle"); } string database = getArg("master-database"); string username = getArg("master-username"); string password = getArg("master-password"); err = OCIAttrSet(masterAuthHandle, OCI_HTYPE_AUTHINFO, (void*)username.c_str(), username.size(), OCI_ATTR_USERNAME, oraerr); if (err == OCI_ERROR) { throw OracleException("openMasterConnection: setting username"); } err = OCIAttrSet(masterAuthHandle, OCI_HTYPE_AUTHINFO, (void*)password.c_str(), password.size(), OCI_ATTR_PASSWORD, oraerr); if (err == OCI_ERROR) { throw OracleException("openMasterConnection: setting password"); } err = OCISessionGet(oraenv, oraerr, &masterSvcCtx, masterAuthHandle, (OraText*)database.c_str(), database.size(), NULL, 0, NULL, NULL, NULL, OCI_SESSGET_STMTCACHE); if (err == OCI_ERROR) { throw OracleException("openMasterConnection OCISessionGet"); } } } OracleBackend::~OracleBackend () { Cleanup(); } void OracleBackend::lookup (const QType &qtype, const string &qname, DNSPacket *p, int zoneId) { sword rc; if (qtype.getCode() != QType::ANY) { if (zoneId < 0) { if (curStmtHandle != NULL) throw OracleException("Invalid state"); curStmtHandle = prepare_query(pooledSvcCtx, basicQuerySQL, basicQueryKey); curStmtKey = basicQueryKey; define_fwd_query(curStmtHandle); bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); bind_str(curStmtHandle, ":type", mQueryType, sizeof(mQueryType)); } else { if (curStmtHandle != NULL) throw OracleException("Invalid state"); curStmtHandle = prepare_query(pooledSvcCtx, basicIdQuerySQL, basicIdQueryKey); curStmtKey = basicIdQueryKey; define_fwd_query(curStmtHandle); bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); bind_str(curStmtHandle, ":type", mQueryType, sizeof(mQueryType)); bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); } } else { if (zoneId < 0) { if (curStmtHandle != NULL) throw OracleException("Invalid state"); curStmtHandle = prepare_query(pooledSvcCtx, anyQuerySQL, anyQueryKey); curStmtKey = anyQueryKey; define_fwd_query(curStmtHandle); bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); } else { if (curStmtHandle != NULL) throw OracleException("Invalid state"); curStmtHandle = prepare_query(pooledSvcCtx, anyIdQuerySQL, anyIdQueryKey); curStmtKey = anyIdQueryKey; define_fwd_query(curStmtHandle); bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); } } string_to_cbuf(mQueryName, qname, sizeof(mQueryName)); string_to_cbuf(mQueryType, qtype.getName(), sizeof(mQueryType)); mQueryZoneId = zoneId; rc = OCIStmtExecute(pooledSvcCtx, curStmtHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle Lookup", oraerr); } if (rc == OCI_NO_DATA) { release_query(curStmtHandle, curStmtKey); curStmtHandle = NULL; } } bool OracleBackend::getBeforeAndAfterNames ( uint32_t zoneId, const string& zone, const string& name, string& before, string& after) { if(!d_dnssecQueries) return -1; sword rc; OCIStmt *stmt; (void)zone; stmt = prepare_query(pooledSvcCtx, prevNextNameQuerySQL, prevNextNameQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_str_ind(stmt, ":prev", mResultPrevName, sizeof(mResultPrevName), &mResultPrevNameInd); bind_str_ind(stmt, ":next", mResultNextName, sizeof(mResultNextName), &mResultNextNameInd); bind_uint32(stmt, ":zoneid", &zoneId); string_to_cbuf(mQueryName, name, sizeof(mQueryName)); mResultPrevNameInd = -1; mResultNextNameInd = -1; rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "Oracle getBeforeAndAfterNames", oraerr ); } check_indicator(mResultPrevNameInd, false); check_indicator(mResultNextNameInd, false); before = mResultPrevName; after = mResultNextName; release_query(stmt, prevNextNameQueryKey); return true; } bool OracleBackend::getBeforeAndAfterNamesAbsolute(uint32_t zoneId, const string& name, string& unhashed, string& before, string& after) { if(!d_dnssecQueries) return -1; sword rc; OCIStmt *stmt; stmt = prepare_query(pooledSvcCtx, prevNextHashQuerySQL, prevNextHashQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":hash", mQueryName, sizeof(mQueryName)); bind_str_ind(stmt, ":unhashed", mResultName, sizeof(mResultName), &mResultNameInd); bind_str_ind(stmt, ":prev", mResultPrevName, sizeof(mResultPrevName), &mResultPrevNameInd); bind_str_ind(stmt, ":next", mResultNextName, sizeof(mResultNextName), &mResultNextNameInd); bind_uint32(stmt, ":zoneid", &zoneId); string_to_cbuf(mQueryName, name, sizeof(mQueryName)); mResultNameInd = -1; mResultPrevNameInd = -1; mResultNextNameInd = -1; rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "Oracle getBeforeAndAfterNamesAbsolute", oraerr ); } check_indicator(mResultNameInd, false); check_indicator(mResultPrevNameInd, false); check_indicator(mResultNextNameInd, false); unhashed = mResultName; before = mResultPrevName; after = mResultNextName; release_query(stmt, prevNextHashQueryKey); return true; } vector OracleBackend::getDomainMasters (const string &domain, int zoneId) { sword rc; OCIStmt *stmt; (void)domain; vector masters; char master[512]; sb2 master_ind; openMasterConnection(); stmt = prepare_query(masterSvcCtx, zoneMastersQuerySQL, zoneMastersQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":zoneid", &mQueryZoneId); mQueryZoneId = zoneId; define_output_str(stmt, 1, &master_ind, master, sizeof(master)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle getDomainMasters", oraerr); } while (rc != OCI_NO_DATA) { check_indicator(master_ind, false); masters.push_back(master); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "OracleBackend, fetching next zone master", oraerr ); } } release_query(stmt, zoneMastersQueryKey); return masters; } bool OracleBackend::isMaster (const string &domain, const string &master) { sword rc; OCIStmt *stmt; openMasterConnection(); stmt = prepare_query(masterSvcCtx, isZoneMasterQuerySQL, isZoneMasterQueryKey); string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); string_to_cbuf(mQueryName, master, sizeof(mQueryName)); char res_master[512]; sb2 res_master_ind; bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); bind_str(stmt, ":master", mQueryName, sizeof(mQueryName)); define_output_str(stmt, 1, &res_master_ind, res_master, sizeof(res_master)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle isMaster", oraerr); } release_query(stmt, isZoneMasterQueryKey); if (rc != OCI_NO_DATA) { check_indicator(res_master_ind, false); return true; } return false; } bool OracleBackend::getDomainInfo (const string &domain, DomainInfo &di) { sword rc; OCIStmt *stmt; int zone_id; sb2 zone_id_ind; int last_check; sb2 last_check_ind; uint32_t serial; sb2 serial_ind; uint32_t notified_serial; sb2 notified_serial_ind; openMasterConnection(); stmt = prepare_query(masterSvcCtx, zoneInfoQuerySQL, zoneInfoQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); define_output_int(stmt, 1, &zone_id_ind, &zone_id); define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); define_output_str(stmt, 3, &mResultTypeInd, mResultType, sizeof(mResultType)); define_output_int(stmt, 4, &last_check_ind, &last_check); define_output_uint32(stmt, 5, &serial_ind, &serial); define_output_uint32(stmt, 6, ¬ified_serial_ind, ¬ified_serial); string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle getDomainInfo", oraerr); } if (rc == OCI_NO_DATA) { release_query(stmt, zoneInfoQueryKey); return false; } check_indicator(zone_id_ind, false); check_indicator(mResultNameInd, false); check_indicator(serial_ind, true); if (zone_id < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); di.id = zone_id; di.zone = mResultName; di.serial = serial; di.backend = this; check_indicator(mResultTypeInd, false); if (strcasecmp(mResultType, "NATIVE") == 0) { di.kind = DomainInfo::Native; } else if (strcasecmp(mResultType, "MASTER") == 0) { di.kind = DomainInfo::Master; check_indicator(notified_serial_ind, false); di.notified_serial = notified_serial; } else if (strcasecmp(mResultType, "SLAVE") == 0) { di.kind = DomainInfo::Slave; check_indicator(last_check_ind, true); di.last_check = last_check; di.masters = getDomainMasters(mResultName, zone_id); } else { throw OracleException("Unknown zone type in Oracle backend"); } di.kind = DomainInfo::Native; release_query(stmt, zoneInfoQueryKey); return true; } void OracleBackend::alsoNotifies(const string &domain, set *addrs) { sword rc; OCIStmt *stmt; char hostaddr[512]; sb2 hostaddr_ind; openMasterConnection(); stmt = prepare_query(masterSvcCtx, alsoNotifyQuerySQL, alsoNotifyQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); define_output_str(stmt, 1, &hostaddr_ind, hostaddr, sizeof(hostaddr)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle alsoNotifies", oraerr); } while (rc != OCI_NO_DATA) { check_indicator(hostaddr_ind, false); addrs->insert(hostaddr); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "OracleBackend alsoNotifies fetch", oraerr ); } } release_query(stmt, alsoNotifyQueryKey); } void OracleBackend::getUnfreshSlaveInfos (vector* domains) { sword rc; OCIStmt *stmt; struct timeval now; gettimeofday(&now, NULL); mQueryTimestamp = now.tv_sec; int last_check; sb2 last_check_ind; uint32_t serial; sb2 serial_ind; char master[512]; sb2 master_ind; openMasterConnection(); stmt = prepare_query(masterSvcCtx, unfreshZonesQuerySQL, unfreshZonesQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":ts", &mQueryTimestamp); define_output_int(stmt, 1, &mResultZoneIdInd, &mResultZoneId); define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); define_output_int(stmt, 3, &last_check_ind, &last_check); define_output_uint32(stmt, 4, &serial_ind, &serial); define_output_str(stmt, 5, &master_ind, master, sizeof(master)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle getUnfreshSlaveInfos", oraerr); } while (rc != OCI_NO_DATA) { check_indicator(mResultZoneIdInd, false); check_indicator(mResultNameInd, false); check_indicator(serial_ind, true); check_indicator(last_check_ind, true); int zoneId = mResultZoneId; if (mResultZoneId < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); DomainInfo di; di.id = mResultZoneId; di.zone = mResultName; di.last_check = last_check; di.kind = DomainInfo::Slave; di.backend = this; if (serial_ind == 0) { di.serial = serial; } while (rc != OCI_NO_DATA && zoneId == mResultZoneId) { check_indicator(master_ind, false); di.masters.push_back(master); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "OracleBackend, fetching next unfresh slave master", oraerr ); } check_indicator(mResultZoneIdInd, false); } domains->push_back(di); } release_query(stmt, unfreshZonesQueryKey); } void OracleBackend::getUpdatedMasters (vector* domains) { sword rc; OCIStmt *stmt; uint32_t serial; sb2 serial_ind; uint32_t notified_serial; sb2 notified_serial_ind; openMasterConnection(); stmt = prepare_query(masterSvcCtx, updatedMastersQuerySQL, updatedMastersQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); define_output_int(stmt, 1, &mResultZoneIdInd, &mResultZoneId); define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); define_output_uint32(stmt, 3, &serial_ind, &serial); define_output_uint32(stmt, 4, ¬ified_serial_ind, ¬ified_serial); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle getUpdatedMasters", oraerr); } while (rc != OCI_NO_DATA) { check_indicator(mResultZoneIdInd, false); check_indicator(mResultNameInd, false); check_indicator(serial_ind, false); check_indicator(notified_serial_ind, true); if (mResultZoneId < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); DomainInfo di; di.id = mResultZoneId; di.zone = mResultName; di.serial = serial; di.notified_serial = notified_serial; di.kind = DomainInfo::Master; di.backend = this; domains->push_back(di); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "OracleBackend, fetching next updated master", oraerr ); } } release_query(stmt, updatedMastersQueryKey); } void OracleBackend::setFresh (uint32_t zoneId) { sword rc; OCIStmt *stmt; mQueryZoneId = zoneId; struct timeval now; gettimeofday(&now, NULL); mQueryTimestamp = now.tv_sec; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle setFresh BEGIN", oraerr); } stmt = prepare_query(masterSvcCtx, zoneSetLastCheckQuerySQL, zoneSetLastCheckQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":zoneid", &mQueryZoneId); bind_int(stmt, ":lastcheck", &mQueryTimestamp); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setFresh", oraerr); } release_query(stmt, zoneSetLastCheckQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc) { throw OracleException("Oracle setFresh COMMIT", oraerr); } } void OracleBackend::setNotified (uint32_t zoneId, uint32_t serial) { sword rc; OCIStmt *stmt; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle setNotified BEGIN", oraerr); } stmt = prepare_query(masterSvcCtx, zoneSetNotifiedSerialQuerySQL, zoneSetNotifiedSerialQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_uint32(stmt, ":serial", &serial); bind_uint32(stmt, ":zoneid", &zoneId); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setNotified", oraerr); } release_query(stmt, zoneSetNotifiedSerialQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc) { throw OracleException("Oracle setNotified COMMIT", oraerr); } } bool OracleBackend::list (const string &domain, int zoneId) { sword rc; // This is only for backends that cannot lookup by zoneId, // we can discard (void)domain; if (curStmtHandle != NULL) throw OracleException("Invalid state"); curStmtHandle = prepare_query(pooledSvcCtx, listQuerySQL, listQueryKey); curStmtKey = listQueryKey; define_fwd_query(curStmtHandle); bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); mQueryZoneId = zoneId; rc = OCIStmtExecute(pooledSvcCtx, curStmtHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle List", oraerr); } if (rc == OCI_SUCCESS || rc == OCI_SUCCESS_WITH_INFO) { return true; } if (rc == OCI_NO_DATA) { release_query(curStmtHandle, curStmtKey); curStmtHandle = NULL; } return false; } bool OracleBackend::get (DNSResourceRecord &rr) { sword rc; if (curStmtHandle == NULL) { return false; } check_indicator(mResultNameInd, false); check_indicator(mResultTTLInd, false); check_indicator(mResultTypeInd, false); check_indicator(mResultContentInd, false); check_indicator(mResultZoneIdInd, false); check_indicator(mResultLastChangeInd, false); if (d_dnssecQueries) check_indicator(mResultIsAuthInd, false); rr.qname = mResultName; rr.ttl = mResultTTL; rr.qtype = mResultType; rr.domain_id = mResultZoneId; rr.last_modified = mResultLastChange; if (d_dnssecQueries) rr.auth = mResultIsAuth > 0; else rr.auth = 1; if ((rr.qtype.getCode() == QType::MX) || (rr.qtype.getCode() == QType::SRV)) { unsigned priority = 0; int skip = 0; sscanf(mResultContent, "%u %n", &priority, &skip); rr.priority = priority; rr.content = mResultContent + skip; } else { rr.content = mResultContent; } rc = OCIStmtFetch2(curStmtHandle, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("OracleBackend, fetching next row", oraerr); } if (rc == OCI_NO_DATA) { release_query(curStmtHandle, curStmtKey); curStmtHandle = NULL; } return true; } bool OracleBackend::startTransaction (const string &domain, int zoneId) { sword rc; OCIStmt *stmt; (void)domain; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle startTransaction", oraerr); } if (zoneId >= 0) { if (openTransactionZoneID >= 0) { throw OracleException("Attempt to start AXFR during AXFR"); } mQueryZoneId = openTransactionZoneID = zoneId; stmt = prepare_query(masterSvcCtx, deleteZoneQuerySQL, deleteZoneQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":zoneid", &mQueryZoneId); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle startTransaction deleteZone", oraerr); } release_query(stmt, deleteZoneQueryKey); } return true; } bool OracleBackend::feedRecord (const DNSResourceRecord &rr) { sword rc; OCIStmt *stmt; uint32_t ttl; char content[4001]; stmt = prepare_query(masterSvcCtx, insertRecordQuerySQL, insertRecordQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":zoneid", &mQueryZoneId); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_str(stmt, ":type", mQueryType, sizeof(mQueryType)); bind_uint32(stmt, ":ttl", &ttl); bind_str(stmt, ":content", content, sizeof(content)); mQueryZoneId = rr.domain_id; string_to_cbuf(mQueryName, rr.qname, sizeof(mQueryName)); ttl = rr.ttl; string_to_cbuf(mQueryType, rr.qtype.getName(), sizeof(mQueryType)); if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) { snprintf(content, sizeof(content), "%d %s", rr.priority, rr.content.c_str()); } else { string_to_cbuf(content, rr.content, sizeof(content)); } rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle feedRecord", oraerr); } release_query(stmt, insertRecordQueryKey); return true; } bool OracleBackend::commitTransaction () { sword rc; OCIStmt *stmt; if (openTransactionZoneID >= 0) { stmt = prepare_query(masterSvcCtx, finalizeAXFRQuerySQL, finalizeAXFRQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_int(stmt, ":zoneid", &openTransactionZoneID); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle commitTransaction finalizeAXFR", oraerr); } release_query(stmt, finalizeAXFRQueryKey); openTransactionZoneID = -1; } rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc) { throw OracleException("Oracle commitTransaction", oraerr); } return true; } bool OracleBackend::abortTransaction () { sword err; err = OCITransRollback(masterSvcCtx, oraerr, OCI_DEFAULT); if (err) { throw OracleException("Oracle abortTransaction", oraerr); } return true; } bool OracleBackend::superMasterBackend (const string &ip, const string &domain, const vector &nsset, string *account, DNSBackend **backend) { sword rc; OCIStmt *stmt; bool result = false; (void)domain; string_to_cbuf(mQueryAddr, ip, sizeof(mQueryAddr)); openMasterConnection(); stmt = prepare_query(masterSvcCtx, acceptSupernotificationQuerySQL, acceptSupernotificationQueryKey); define_output_str(stmt, 1, &mResultNameInd, mResultName, sizeof(mResultName)); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":ns", mQueryName, sizeof(mQueryName)); bind_str(stmt, ":ip", mQueryAddr, sizeof(mQueryAddr)); for (vector::const_iterator i=nsset.begin(); i != nsset.end(); ++i) { string_to_cbuf(mQueryName, i->content, sizeof(mQueryName)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle superMasterBackend", oraerr); } if (rc != OCI_NO_DATA) { *account = mResultName; *backend = this; result = true; break; } } release_query(stmt, acceptSupernotificationQueryKey); return result; } bool OracleBackend::createSlaveDomain(const string &ip, const string &domain, const string &account) { sword rc; OCIStmt *insertSlaveQueryHandle; OCIStmt *insertMasterQueryHandle; string_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle createSlaveDomain BEGIN", oraerr); } insertSlaveQueryHandle = prepare_query(masterSvcCtx, insertSlaveQuerySQL, insertSlaveQueryKey); bind_str_failokay(insertSlaveQueryHandle, ":nsname", myServerName, sizeof(myServerName)); bind_int(insertSlaveQueryHandle, ":zoneid", &mQueryZoneId); bind_str(insertSlaveQueryHandle, ":zone", mQueryZone, sizeof(mQueryZone)); insertMasterQueryHandle = prepare_query(masterSvcCtx, insertMasterQuerySQL, insertMasterQueryKey); bind_str_failokay(insertMasterQueryHandle, ":nsname", myServerName, sizeof(myServerName)); bind_int(insertMasterQueryHandle, ":zoneid", &mQueryZoneId); bind_str(insertMasterQueryHandle, ":ip", mQueryAddr, sizeof(mQueryAddr)); rc = OCIStmtExecute(masterSvcCtx, insertSlaveQueryHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "Oracle createSlaveDomain insertSlave", oraerr); } string_to_cbuf(mQueryAddr, ip, sizeof(mQueryAddr)); rc = OCIStmtExecute(masterSvcCtx, insertMasterQueryHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException( "Oracle createSlaveDomain insertMaster", oraerr); } release_query(insertSlaveQueryHandle, insertSlaveQueryKey); release_query(insertMasterQueryHandle, insertMasterQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc) { throw OracleException("Oracle createSlaveDomain COMMIT", oraerr); } return true; } bool OracleBackend::getDomainMetadata (const string& name, const string& kind, vector& meta) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; stmt = prepare_query(pooledSvcCtx, getZoneMetadataQuerySQL, getZoneMetadataQueryKey); bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); define_output_str(stmt, 1, &mResultContentInd, mResultContent, sizeof(mResultContent)); string_to_cbuf(mQueryName, name, sizeof(mQueryName)); string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); while (rc != OCI_NO_DATA) { if (rc == OCI_ERROR) { throw OracleException("Oracle getDomainMetadata", oraerr); } check_indicator(mResultContentInd, true); string content = mResultContent; meta.push_back(content); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); } release_query(stmt, getZoneMetadataQueryKey); return true; } bool OracleBackend::setDomainMetadata(const string& name, const string& kind, const vector& meta) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainMetadata BEGIN", oraerr); } string_to_cbuf(mQueryName, name, sizeof(mQueryName)); string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); stmt = prepare_query(masterSvcCtx, delZoneMetadataQuerySQL, delZoneMetadataQueryKey); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainMetadata DELETE", oraerr); } release_query(stmt, delZoneMetadataQueryKey); stmt = prepare_query(masterSvcCtx, setZoneMetadataQuerySQL, setZoneMetadataQueryKey); int i = 0; bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); bind_int(stmt, ":i", &i); bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); for (vector::const_iterator it = meta.begin(); it != meta.end(); ++it) { string_to_cbuf(mQueryContent, *it, sizeof(mQueryContent)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainMetadata INSERT", oraerr); } i++; } release_query(stmt, setZoneMetadataQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainMetadata COMMIT", oraerr); } return true; } bool OracleBackend::getTSIGKey (const string& name, string* algorithm, string* content) { if(!d_dnssecQueries) return -1; sword rc; OCIStmt *stmt; stmt = prepare_query(pooledSvcCtx, getTSIGKeyQuerySQL, getTSIGKeyQueryKey); string_to_cbuf(mQueryName, name, sizeof(mQueryName)); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); define_output_str(stmt, 1, &mResultTypeInd, mResultType, sizeof(mResultType)); define_output_str(stmt, 2, &mResultContentInd, mResultContent, sizeof(mResultContent)); rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_NO_DATA) { return false; } if (rc == OCI_ERROR) { throw OracleException("Oracle getTSIGKey", oraerr); } check_indicator(mResultTypeInd, false); check_indicator(mResultContentInd, false); *algorithm = mResultType; *content = mResultContent; release_query(stmt, getTSIGKeyQueryKey); return true; } bool OracleBackend::getDomainKeys (const string& name, unsigned int kind, vector& keys) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; stmt = prepare_query(pooledSvcCtx, getZoneKeysQuerySQL, getZoneKeysQueryKey); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); string_to_cbuf(mQueryName, name, sizeof(mQueryName)); sb2 key_id_ind = 0; unsigned int key_id = 0; sb2 key_flags_ind = 0; uint16_t key_flags = 0; sb2 key_active_ind = 0; int key_active = 0; define_output_uint(stmt, 1, &key_id_ind, &key_id); define_output_uint16(stmt, 2, &key_flags_ind, &key_flags); define_output_int(stmt, 3, &key_active_ind, &key_active); define_output_str(stmt, 4, &mResultContentInd, mResultContent, sizeof(mResultContent)); rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); while (rc != OCI_NO_DATA) { if (rc == OCI_ERROR) { throw OracleException("Oracle getDomainKeys", oraerr); } check_indicator(key_id_ind, false); check_indicator(key_flags_ind, false); check_indicator(key_active_ind, false); check_indicator(mResultContentInd, false); KeyData kd; kd.id = key_id; kd.flags = key_flags; kd.active = key_active; kd.content = mResultContent; keys.push_back(kd); rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); } release_query(stmt, getZoneKeysQueryKey); return true; } bool OracleBackend::removeDomainKey (const string& name, unsigned int id) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle removeDomainKey BEGIN", oraerr); } stmt = prepare_query(masterSvcCtx, delZoneKeyQuerySQL, delZoneKeyQueryKey); bind_uint(stmt, ":keyid", &id); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle removeDomainKey DELETE", oraerr); } release_query(stmt, delZoneKeyQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle removeDomainKey COMMIT", oraerr); } return true; } int OracleBackend::addDomainKey (const string& name, const KeyData& key) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; int key_id = -1; uint16_t key_flags = key.flags; int key_active = key.active; openMasterConnection(); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle addDomainKey BEGIN", oraerr); } string_to_cbuf(mQueryName, name, sizeof(mQueryName)); string_to_cbuf(mQueryContent, key.content, sizeof(mQueryContent)); stmt = prepare_query(masterSvcCtx, addZoneKeyQuerySQL, addZoneKeyQueryKey); bind_int(stmt, ":keyid", &key_id); bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); bind_uint16(stmt, ":flags", &key_flags); bind_int(stmt, ":active", &key_active); bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle addDomainKey INSERT", oraerr); } release_query(stmt, addZoneKeyQueryKey); rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle addDomainKey COMMIT", oraerr); } return key_id; } bool OracleBackend::setDomainKeyState (const string& name, unsigned int id, int active) { if(!d_dnssecQueries) return -1; DomainInfo di; if (getDomainInfo(name, di) == false) return false; sword rc; OCIStmt *stmt; openMasterConnection(); stmt = prepare_query(masterSvcCtx, setZoneKeyStateQuerySQL, setZoneKeyStateQueryKey); bind_uint(stmt, ":keyid", &id); bind_int(stmt, ":active", &active); rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainKeyState BEGIN", oraerr); } rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainKeyState UPDATE", oraerr); } rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); if (rc == OCI_ERROR) { throw OracleException("Oracle setDomainKeyState COMMIT", oraerr); } release_query(stmt, setZoneKeyStateQueryKey); return true; } bool OracleBackend::activateDomainKey (const string& name, unsigned int id) { return setDomainKeyState(name, id, 1); } bool OracleBackend::deactivateDomainKey (const string& name, unsigned int id) { return setDomainKeyState(name, id, 0); } void OracleBackend::Cleanup () { sword err; if (masterSvcCtx != NULL) { err = OCITransRollback(masterSvcCtx, oraerr, OCI_DEFAULT); // No error check, we don't care if ROLLBACK failed err = OCISessionRelease(masterSvcCtx, oraerr, NULL, 0, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Oracle cleanup, OCISessionRelease (master)", oraerr); } masterSvcCtx = NULL; OCIHandleFree(masterAuthHandle, OCI_HTYPE_AUTHINFO); masterAuthHandle = NULL; } if (pooledSvcCtx != NULL) { err = OCITransRollback(pooledSvcCtx, oraerr, OCI_DEFAULT); // No error check, we don't care if ROLLBACK failed err = OCISessionRelease(pooledSvcCtx, oraerr, NULL, 0, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Oracle cleanup, OCISessionRelease (pooled)", oraerr); } pooledSvcCtx = NULL; } if (oraerr != NULL) { OCIHandleFree(oraerr, OCI_HTYPE_ERROR); oraerr = NULL; } } OCIStmt* OracleBackend::prepare_query (OCISvcCtx *orasvc, string& code, const char *key) { sword err; OCIStmt *handle = NULL; err = OCIStmtPrepare2(orasvc, &handle, oraerr, (OraText*) code.c_str(), code.length(), (OraText*) key, strlen(key), OCI_NTV_SYNTAX, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Preparing Oracle statement", oraerr); } return handle; } void OracleBackend::release_query (OCIStmt *stmt, const char *key) { sword err; err = OCIStmtRelease(stmt, oraerr, (OraText*)key, strlen(key), OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Releasing Oracle statement", oraerr); } } void OracleBackend::define_output_str (OCIStmt *s, ub4 pos, sb2 *ind, char *buf, sb4 buflen) { sword err; OCIDefine *handle = NULL; err = OCIDefineByPos(s, &handle, oraerr, pos, buf, buflen, SQLT_STR, ind, NULL, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Defining output for Oracle statement", oraerr); } } void OracleBackend::define_output_int (OCIStmt *s, ub4 pos, sb2 *ind, int *buf) { sword err; OCIDefine *handle = NULL; err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(int), SQLT_INT, ind, NULL, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Defining output for Oracle statement", oraerr); } } void OracleBackend::define_output_uint (OCIStmt *s, ub4 pos, sb2 *ind, unsigned int *buf) { sword err; OCIDefine *handle = NULL; err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(unsigned int), SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Defining output for Oracle statement", oraerr); } } void OracleBackend::define_output_uint16 (OCIStmt *s, ub4 pos, sb2 *ind, uint16_t *buf) { sword err; OCIDefine *handle = NULL; err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(uint16_t), SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Defining output for Oracle statement", oraerr); } } void OracleBackend::define_output_uint32 (OCIStmt *s, ub4 pos, sb2 *ind, uint32_t *buf) { sword err; OCIDefine *handle = NULL; err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(uint32_t), SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { throw OracleException("Defining output for Oracle statement", oraerr); } } void OracleBackend::check_indicator (sb2 ind, bool null_okay) { if ((!null_okay) && (ind == -1)) { throw OracleException("Received NULL where a value was expected"); } if ((ind < -1) || (ind > 0)) { throw OracleException("Return value truncated"); } } void OracleBackend::define_fwd_query (OCIStmt *s) { const ub4 n = 100; sword err = OCIAttrSet(s, OCI_HTYPE_STMT, (void*) &n, sizeof(ub4), OCI_ATTR_PREFETCH_ROWS, oraerr); if (err == OCI_ERROR) { throw OracleException("Activating row prefetching", oraerr); } define_output_str(s, 1, &mResultNameInd, mResultName, sizeof(mResultName)); define_output_uint32(s, 2, &mResultTTLInd, &mResultTTL); define_output_str(s, 3, &mResultTypeInd, mResultType, sizeof(mResultType)); define_output_str(s, 4, &mResultContentInd, mResultContent, sizeof(mResultContent)); define_output_int(s, 5, &mResultZoneIdInd, &mResultZoneId); define_output_int(s, 6, &mResultLastChangeInd, &mResultLastChange); if (d_dnssecQueries) define_output_int(s, 7, &mResultIsAuthInd, &mResultIsAuth); } void OracleBackend::bind_str (OCIStmt *s, const char *name, char *buf, sb4 buflen) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, buflen, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_str (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_str_failokay (OCIStmt *s, const char *name, char *buf, sb4 buflen) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, buflen, SQLT_STR, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); (void)err; } void OracleBackend::bind_str_ind (OCIStmt *s, const char *name, char *buf, sb4 buflen, sb2 *ind) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, buflen, SQLT_STR, ind, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_str_ind (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_int (OCIStmt *s, const char *name, int *buf) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, sizeof(int), SQLT_INT, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_int (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_uint (OCIStmt *s, const char *name, unsigned int *buf) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, sizeof(unsigned int), SQLT_UIN, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_uint (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_uint16 (OCIStmt *s, const char *name, uint16_t *buf) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, sizeof(uint16_t), SQLT_UIN, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_uint16 (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_uint16_ind (OCIStmt *s, const char *name, uint16_t *buf, sb2 *ind) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, sizeof(uint16_t), SQLT_UIN, ind, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_uint16_ind (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } void OracleBackend::bind_uint32 (OCIStmt *s, const char *name, uint32_t *buf) { sword err; OCIBind *handle = NULL; err = OCIBindByName(s, &handle, oraerr, (OraText*) name, strlen(name), buf, sizeof(uint32_t), SQLT_UIN, NULL, NULL, NULL, 0, NULL, OCI_DEFAULT); if (err == OCI_ERROR) { string msg; msg.append("Oracle bind_uint32 (\""); msg.append(name); msg.append("\")"); throw OracleException(msg, oraerr); } } class OracleFactory : public BackendFactory { private: pthread_mutex_t factoryLock; OCIEnv *oraenv; OCIError *oraerr; OCISPool *mSessionPoolHandle; text *mSessionPoolName; ub4 mSessionPoolNameLen; void CreateSessionPool () { sword err; try { // set some envionment variables setenv("ORACLE_HOME", arg()["oracle-home"].c_str(), 1); setenv("ORACLE_SID", arg()["oracle-sid"].c_str(), 1); setenv("NLS_LANG", arg()["oracle-nls-lang"].c_str(), 1); // Initialize and create the environment err = OCIEnvCreate(&oraenv, OCI_THREADED, NULL, NULL, NULL, NULL, 0, NULL); if (err == OCI_ERROR) { throw OracleException("OCIEnvCreate"); } // Allocate an error handle err = OCIHandleAlloc(oraenv, (void**) &oraerr, OCI_HTYPE_ERROR, 0, NULL); if (err == OCI_ERROR) { throw OracleException("OCIHandleAlloc"); } const char *dbname = arg()["oracle-pool-database"].c_str(); const char *dbuser = arg()["oracle-pool-username"].c_str(); const char *dbpass = arg()["oracle-pool-password"].c_str(); ub4 sess_min = arg().asNum("oracle-session-min"); ub4 sess_max = arg().asNum("oracle-session-max"); ub4 sess_inc = arg().asNum("oracle-session-inc"); ub4 get_mode = OCI_SPOOL_ATTRVAL_NOWAIT; // Create a session pool err = OCIHandleAlloc(oraenv, (void**) &mSessionPoolHandle, OCI_HTYPE_SPOOL, 0, NULL); if (err == OCI_ERROR) { throw OracleException("OCIHandleAlloc"); } err = OCISessionPoolCreate(oraenv, oraerr, mSessionPoolHandle, (OraText **) &mSessionPoolName, &mSessionPoolNameLen, (OraText *) dbname, strlen(dbname), sess_min, sess_max, sess_inc, (OraText *) dbuser, strlen(dbuser), (OraText *) dbpass, strlen(dbpass), OCI_SPC_STMTCACHE | OCI_SPC_HOMOGENEOUS); if (err == OCI_ERROR) { throw OracleException("Creating Oracle session pool", oraerr); } // Set session pool NOWAIT err = OCIAttrSet(mSessionPoolHandle, OCI_HTYPE_SPOOL, &get_mode, 0, OCI_ATTR_SPOOL_GETMODE, oraerr); if (err == OCI_ERROR) { throw OracleException("Setting session pool get mode", oraerr); } } catch (OracleException &theException) { L << Logger::Critical << "OracleFactory: " << theException.reason << endl; Cleanup(); throw theException; } } void Cleanup () { sword err; if (mSessionPoolHandle != NULL) { try { err = OCISessionPoolDestroy(mSessionPoolHandle, oraerr, OCI_SPD_FORCE); OCIHandleFree(mSessionPoolHandle, OCI_HTYPE_SPOOL); mSessionPoolHandle = NULL; if (err == OCI_ERROR) { throw OracleException("OCISessionPoolDestroy", oraerr); } } catch (OracleException &theException) { L << Logger::Error << "Failed to destroy Oracle session pool: " << theException.reason << endl; } } if (oraerr != NULL) { OCIHandleFree(oraerr, OCI_HTYPE_ERROR); oraerr = NULL; } if (oraenv != NULL) { OCIHandleFree(oraenv, OCI_HTYPE_ENV); oraenv = NULL; } } public: OracleFactory () : BackendFactory("oracle") { pthread_mutex_init(&factoryLock, NULL); oraenv = NULL; oraerr = NULL; mSessionPoolHandle = NULL; mSessionPoolName = NULL; mSessionPoolNameLen = 0; } ~OracleFactory () { Cleanup(); pthread_mutex_destroy(&factoryLock); } void declareArguments (const string & suffix = "") { declare(suffix,"home", "Oracle home path", ""); declare(suffix,"sid", "Oracle sid", "XE"); declare(suffix,"nls-lang", "Oracle language", "AMERICAN_AMERICA.AL32UTF8"); declare(suffix, "pool-database", "Database to connect to for the session pool", "powerdns"); declare(suffix, "pool-username", "Username to connect as for the session pool", "powerdns"); declare(suffix, "pool-password", "Password to connect with for the session pool", ""); declare(suffix, "session-min", "Number of sessions to open at startup", "4"); declare(suffix, "session-inc", "Number of sessions to open when growing", "2"); declare(suffix, "session-max", "Max number of sessions to have open", "20"); declare(suffix, "master-database", "Database to connect to for write access", "powerdns"); declare(suffix, "master-username", "Username to connect as for write access", "powerdns"); declare(suffix, "master-password", "Password to connect with for write access", ""); declare(suffix, "dnssec", "Assume DNSSEC Schema is in place", "no"); declare(suffix, "nameserver-name", "", ""); declare(suffix, "basic-query", "", basicQueryDefaultSQL); declare(suffix, "basic-query-auth", "", basicQueryDefaultAuthSQL); declare(suffix, "basic-id-query", "", basicIdQueryDefaultSQL); declare(suffix, "basic-id-query-auth", "", basicIdQueryDefaultAuthSQL); declare(suffix, "any-query", "", anyQueryDefaultSQL); declare(suffix, "any-query-auth", "", anyQueryDefaultAuthSQL); declare(suffix, "any-id-query", "", anyIdQueryDefaultSQL); declare(suffix, "any-id-query-auth", "", anyIdQueryDefaultAuthSQL); declare(suffix, "list-query", "", listQueryDefaultSQL); declare(suffix, "list-query-auth", "", listQueryDefaultAuthSQL); declare(suffix, "zone-info-query", "", zoneInfoQueryDefaultSQL); declare(suffix, "also-notify-query", "", alsoNotifyQueryDefaultSQL); declare(suffix, "zone-masters-query", "", zoneMastersQueryDefaultSQL); declare(suffix, "is-zone-master-query", "", isZoneMasterQueryDefaultSQL); declare(suffix, "delete-zone-query", "", deleteZoneQueryDefaultSQL); declare(suffix, "zone-set-last-check-query", "", zoneSetLastCheckQueryDefaultSQL); declare(suffix, "zone-set-notified-serial-query", "", zoneSetNotifiedSerialQueryDefaultSQL); declare(suffix, "insert-record-query", "", insertRecordQueryDefaultSQL); declare(suffix, "finalize-axfr-query", "", finalizeAXFRQueryDefaultSQL); declare(suffix, "unfresh-zones-query", "", unfreshZonesQueryDefaultSQL); declare(suffix, "updated-masters-query", "", updatedMastersQueryDefaultSQL); declare(suffix, "accept-supernotification-query", "", acceptSupernotificationQueryDefaultSQL); declare(suffix, "insert-slave-query", "", insertSlaveQueryDefaultSQL); declare(suffix, "insert-master-query", "", insertMasterQueryDefaultSQL); declare(suffix, "prev-next-name-query", "", prevNextNameQueryDefaultSQL); declare(suffix, "prev-next-hash-query", "", prevNextHashQueryDefaultSQL); declare(suffix, "get-zone-metadata-query", "", getZoneMetadataQueryDefaultSQL); declare(suffix, "del-zone-metadata-query", "", delZoneMetadataQueryDefaultSQL); declare(suffix, "set-zone-metadata-query", "", setZoneMetadataQueryDefaultSQL); declare(suffix, "get-tsig-key-query", "", getTSIGKeyQueryDefaultSQL); declare(suffix, "get-zone-keys-query", "", getZoneKeysQueryDefaultSQL); declare(suffix, "del-zone-key-query", "", delZoneKeyQueryDefaultSQL); declare(suffix, "add-zone-key-query", "", addZoneKeyQueryDefaultSQL); declare(suffix, "set-zone-key-state-query", "", setZoneKeyStateQueryDefaultSQL); } DNSBackend *make (const string & suffix = "") { { Lock l(&factoryLock); if (oraenv == NULL) { CreateSessionPool(); } } return new OracleBackend(suffix, oraenv, (char *) mSessionPoolName); } }; //! Magic class that is activated when the dynamic library is loaded class OracleLoader { public: OracleLoader() { BackendMakers().report(new OracleFactory); } }; static OracleLoader loader; /* vi: set sw=2 et : */ pdns-3.3/modules/oraclebackend/dropschema.sql0000644000014601777760000000110012136555572022661 0ustar00jenkinsnogroup00000000000000DROP PROCEDURE get_hashed_prev_next; DROP PROCEDURE get_canonical_prev_next; DROP FUNCTION dnsname_to_hashname; DROP FUNCTION base32hex_encode; DROP FUNCTION dnsname_to_raw; DROP FUNCTION label_reverse; DROP TABLE Records; DROP SEQUENCE records_id_seq; DROP TABLE AccessControlList; DROP TABLE TSIGKeys; DROP TABLE ZoneDNSKeys; DROP SEQUENCE zonednskeys_id_seq; DROP TABLE ZoneMetadata; DROP TABLE Supermasters; DROP SEQUENCE supermasters_id_seq; DROP TABLE Zonemasters; DROP TABLE ZoneAlsoNotifyHosts; DROP TABLE Zones; DROP SEQUENCE zones_id_seq; -- vi: set sw=2 et : -- pdns-3.3/modules/oraclebackend/schema.sql0000644000014601777760000003302012136555572022002 0ustar00jenkinsnogroup00000000000000-- THIS IS NOT PRODUCTION-QUALITY CODE -- -- This database schema is meant to serve as documentation-by-example for how -- certain things might be done. It has also been used for early testing of the -- backend. It should not be deployed as-is. CREATE SEQUENCE zones_id_seq; CREATE TABLE Zones ( id INTEGER CONSTRAINT pkey_zones PRIMARY KEY, name VARCHAR2(512) NOT NULL, type VARCHAR2(32) NOT NULL, last_check INTEGER, refresh NUMBER(10,0), serial NUMBER(10,0) DEFAULT 0 NOT NULL, notified_serial NUMBER(10,0), CONSTRAINT chk_zones_name CHECK (name = lower(name)), CONSTRAINT unq_zones_name UNIQUE (name), CONSTRAINT chk_zones_type CHECK ( type IN ('NATIVE', 'MASTER', 'SLAVE') AND (type = 'SLAVE' OR last_check IS NULL) ), CONSTRAINT chk_zones_serial CHECK (serial BETWEEN 0 AND 4294967295), CONSTRAINT chk_zones_nserial CHECK (notified_serial BETWEEN 0 AND 4294967295), CONSTRAINT chk_zones_refresh CHECK (refresh BETWEEN 0 AND 4294967295), CONSTRAINT chk_zones_master CHECK (type = 'MASTER' OR notified_serial IS NULL) ); CREATE INDEX zones_type_ind ON Zones (type); CREATE TABLE Zonemasters ( zone_id INTEGER NOT NULL CONSTRAINT fkey_zonemasters_zones REFERENCES Zones ON DELETE CASCADE, master VARCHAR2(512) NOT NULL, CONSTRAINT unq_zonemasters_zone_master UNIQUE (zone_id, master) ); CREATE INDEX zonemasters_zone_id_ind ON Zonemasters (zone_id); CREATE TABLE ZoneAlsoNotify ( zone_id INTEGER NOT NULL CONSTRAINT fkey_zonealsonotify_zones REFERENCES Zones ON DELETE CASCADE, hostaddr VARCHAR2(512) NOT NULL, CONSTRAINT unq_zonealsonotify_zone_host UNIQUE (zone_id, hostaddr) ); CREATE INDEX zonealsonotify_zone_id_ind ON ZoneAlsoNotify (zone_id); CREATE SEQUENCE supermasters_id_seq; CREATE TABLE Supermasters ( id INTEGER CONSTRAINT pkey_supermasters PRIMARY KEY, name VARCHAR2(64) NOT NULL, ip VARCHAR2(64) NOT NULL, nameserver VARCHAR2(512) NOT NULL ); CREATE INDEX supermasters_ip_ind ON Supermasters (ip); CREATE TABLE ZoneMetadata ( zone_id INTEGER NOT NULL CONSTRAINT fkey_zonemetadata_zones REFERENCES Zones, meta_type VARCHAR2(64) NOT NULL, meta_ind INTEGER NOT NULL, meta_content VARCHAR2(4000), CONSTRAINT pkey_zonemetadata PRIMARY KEY (zone_id, meta_type, meta_ind) ); CREATE SEQUENCE zonednskeys_id_seq; CREATE TABLE ZoneDNSKeys ( id INTEGER CONSTRAINT pkey_zonednskeys PRIMARY KEY, zone_id INTEGER NOT NULL CONSTRAINT fkey_zonednskeys_zones REFERENCES Zones, flags NUMBER(5,0) NOT NULL, active NUMBER(1,0) NOT NULL, keydata VARCHAR2(4000) NOT NULL, CONSTRAINT chk_zonednskeys_flags CHECK (flags BETWEEN 0 AND 65535), CONSTRAINT chk_zonednskeys_active CHECK (active IN (0, 1)) ); CREATE INDEX zonednskeys_zone_ind ON ZoneDNSKeys (zone_id); CREATE TABLE TSIGKeys ( name VARCHAR2(255) CONSTRAINT pkey_tsigkeys PRIMARY KEY, algorithm VARCHAR2(63) NOT NULL, secret VARCHAR2(2047) NOT NULL ); CREATE TABLE AccessControlList ( acl_type VARCHAR2(64) NOT NULL, acl_key VARCHAR2(256) NOT NULL, acl_val VARCHAR2(2048), CONSTRAINT chk_acl_type CHECK (acl_type = 'allow-axfr'), CONSTRAINT unq_acl_tkv UNIQUE (acl_type, acl_key, acl_val) ); CREATE INDEX acl_tk ON AccessControlList (acl_type, acl_key); CREATE SEQUENCE records_id_seq; CREATE TABLE Records ( id INTEGER CONSTRAINT pkey_records PRIMARY KEY, zone_id INTEGER NOT NULL CONSTRAINT fkey_records_zones REFERENCES Zones, fqdn VARCHAR2(512) NOT NULL, revfqdn VARCHAR2(512) NOT NULL, fqdnhash VARCHAR2(512), ttl NUMBER(10,0) NOT NULL, type VARCHAR2(32), content VARCHAR2(2048), last_change INTEGER DEFAULT 0 NOT NULL, auth NUMBER(1,0) DEFAULT 1 NOT NULL, CONSTRAINT chk_records_fqdn CHECK (fqdn = lower(fqdn)), CONSTRAINT chk_records_ttl CHECK (ttl BETWEEN 0 AND 4294967295), CONSTRAINT chk_records_type CHECK (type = upper(type)), CONSTRAINT unq_records_zntc UNIQUE (zone_id, fqdn, type, content), CONSTRAINT chk_records_tc CHECK ( type IS NULL AND content IS NULL OR type IS NOT NULL AND content IS NOT NULL ), CONSTRAINT chk_records_auth CHECK (auth IN (0, 1)) ); CREATE INDEX records_zone_id_ind ON Records (zone_id); CREATE INDEX records_revfqdn_ind ON Records (zone_id, revfqdn); CREATE INDEX records_fqdnhash_ind ON Records (zone_id, fqdnhash); CREATE INDEX records_last_change_ind ON Records (last_change); -- Only one SOA and NSEC3PARAM record per zone CREATE UNIQUE INDEX records_zonesoa_unq_ind ON Records ( CASE WHEN type IN ('SOA', 'NSEC3PARAM') THEN zone_id ELSE NULL END, CASE WHEN type IN ('SOA', 'NSEC3PARAM') THEN type ELSE NULL END ); CREATE FUNCTION label_reverse (dnsname IN VARCHAR2) RETURN VARCHAR2 AS pattern VARCHAR2(32) := '[^.]+'; match BINARY_INTEGER := 1; label VARCHAR2(63); out_dnsname VARCHAR2(512); BEGIN label := REGEXP_SUBSTR(dnsname, pattern, 1, match); match := match + 1; out_dnsname := label; LOOP label := REGEXP_SUBSTR(dnsname, pattern, 1, match); EXIT WHEN label IS NULL; out_dnsname := label || ' ' || out_dnsname; match := match + 1; END LOOP; RETURN(out_dnsname); END; / SHOW ERRORS CREATE FUNCTION dnsname_to_raw (in_dnsname IN VARCHAR2) RETURN RAW AS dnsname VARCHAR2(512) := LOWER(in_dnsname); rawname RAW(512); lpos BINARY_INTEGER := 1; rpos BINARY_INTEGER; label VARCHAR2(63); TYPE convarray IS VARRAY(64) OF RAW(1); byteval convarray := convarray( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C', '0D', '0E', '0F', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1A', '1B', '1C', '1D', '1E', '1F', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F' ); BEGIN IF dnsname IS NULL THEN RETURN('00'); END IF; WHILE lpos <= LENGTH(dnsname) LOOP rpos := INSTR(dnsname, '.', lpos); IF rpos = 0 THEN rpos := LENGTH(dnsname) + 1; END IF; label := SUBSTR(dnsname, lpos, rpos - lpos); rawname := UTL_RAW.CONCAT( rawname, byteval(LENGTH(label) + 1), UTL_I18N.STRING_TO_RAW(label, 'US7ASCII') ); lpos := rpos + 1; END LOOP; IF rpos = LENGTH(dnsname) THEN rawname := UTL_RAW.CONCAT(rawname, '00'); END IF; RETURN(rawname); END; / SHOW ERRORS -- This is clearly terrible, though it appears to work. -- For real deployment, you could upload the dnsjava -- library into your database and use its facilities. CREATE FUNCTION base32hex_encode ( in_string RAW ) RETURN VARCHAR2 AS off BINARY_INTEGER := 1; out_string VARCHAR2(6554); sub RAW(5); num INTEGER; TYPE convarray IS VARRAY(32) OF VARCHAR2(1); digit convarray := convarray( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v' ); BEGIN WHILE off + 4 <= UTL_RAW.LENGTH(in_string) LOOP sub := UTL_RAW.SUBSTR(in_string, off, 2); num := TO_NUMBER(sub, 'XXXX'); out_string := out_string || digit(FLOOR(num / 2048) + 1) || digit(FLOOR(MOD(num / 64, 32)) + 1) || digit(FLOOR(MOD(num / 2, 32)) + 1); sub := UTL_RAW.SUBSTR(in_string, off + 1, 3); num := TO_NUMBER(sub, 'XXXXXX'); out_string := out_string || digit(FLOOR(MOD(num / 4096, 32)) + 1) || digit(FLOOR(MOD(num / 128, 32)) + 1) || digit(FLOOR(MOD(num / 4, 32)) + 1); sub := UTL_RAW.SUBSTR(in_string, off + 3, 2); num := TO_NUMBER(sub, 'XXXX'); out_string := out_string || digit(FLOOR(MOD(num / 32, 32)) + 1) || digit(FLOOR(MOD(num, 32)) + 1); off := off + 5; END LOOP; IF off <= UTL_RAW.LENGTH(in_string) THEN sub := UTL_RAW.SUBSTR(in_string, off); CASE UTL_RAW.LENGTH(sub) WHEN 1 THEN num := TO_NUMBER(sub, 'XX'); out_string := out_string || digit(FLOOR(num / 8) + 1) || digit(FLOOR(MOD(num, 8)) * 4 + 1); WHEN 2 THEN num := TO_NUMBER(sub, 'XXXX'); out_string := out_string || digit(FLOOR(num / 2048) + 1) || digit(FLOOR(MOD(num / 64, 32)) + 1) || digit(FLOOR(MOD(num / 2, 32)) + 1) || digit(FLOOR(MOD(num, 2)) * 16 + 1); WHEN 3 THEN num := TO_NUMBER(sub, 'XXXXXX'); out_string := out_string || digit(FLOOR(num / 524288) + 1) || digit(FLOOR(MOD(num / 16384, 32)) + 1) || digit(FLOOR(MOD(num / 512, 32)) + 1) || digit(FLOOR(MOD(num / 16, 32)) + 1) || digit(FLOOR(MOD(num, 16)) * 2 + 1); WHEN 4 THEN num := TO_NUMBER(sub, 'XXXXXXXX'); out_string := out_string || digit(FLOOR(num / 134217728) + 1) || digit(FLOOR(MOD(num / 4194304, 32)) + 1) || digit(FLOOR(MOD(num / 131072, 32)) + 1) || digit(FLOOR(MOD(num / 4096, 32)) + 1) || digit(FLOOR(MOD(num / 128, 32)) + 1) || digit(FLOOR(MOD(num / 4, 32)) + 1) || digit(FLOOR(MOD(num, 4)) * 8 + 1); END CASE; END IF; RETURN(out_string); END; / SHOW ERRORS CREATE FUNCTION dnsname_to_hashname ( in_dnsname IN VARCHAR2, salt RAW, itercnt BINARY_INTEGER ) RETURN VARCHAR2 AS rawname RAW(512) := dnsname_to_raw(RTRIM(in_dnsname, '.') || '.'); rawsalt RAW(32) := salt; hashname RAW(64); iter BINARY_INTEGER := 0; BEGIN hashname := UTL_RAW.CONCAT(rawname, rawsalt); hashname := DBMS_CRYPTO.HASH(hashname, DBMS_CRYPTO.HASH_SH1); WHILE iter < itercnt LOOP hashname := UTL_RAW.CONCAT(hashname, rawsalt); hashname := DBMS_CRYPTO.HASH(hashname, DBMS_CRYPTO.HASH_SH1); iter := iter + 1; END LOOP; RETURN(base32hex_encode(hashname)); END; / SHOW ERRORS CREATE PROCEDURE get_canonical_prev_next ( in_zone_id INTEGER, in_fqdn VARCHAR2, out_prev OUT VARCHAR2, out_next OUT VARCHAR2 ) AS BEGIN SELECT * INTO out_prev FROM ( SELECT fqdn FROM Records WHERE zone_id = in_zone_id AND revfqdn <= label_reverse(LOWER(in_fqdn)) AND auth = 1 ORDER BY revfqdn DESC ) WHERE ROWNUM = 1; BEGIN SELECT * INTO out_next FROM ( SELECT fqdn FROM Records WHERE zone_id = in_zone_id AND revfqdn > label_reverse(LOWER(in_fqdn)) AND auth = 1 ORDER BY revfqdn ASC ) WHERE ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN SELECT name INTO out_next FROM Zones WHERE id = in_zone_id; END; END; / SHOW ERRORS CREATE PROCEDURE get_hashed_prev_next ( in_zone_id INTEGER, in_fqdnhash VARCHAR2, out_fqdn OUT VARCHAR2, out_prev OUT VARCHAR2, out_next OUT VARCHAR2 ) AS BEGIN BEGIN SELECT * INTO out_prev, out_fqdn FROM ( SELECT fqdnhash, fqdn FROM Records WHERE zone_id = in_zone_id AND fqdnhash <= in_fqdnhash AND auth = 1 ORDER BY fqdnhash DESC ) WHERE ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN SELECT * INTO out_prev, out_fqdn FROM ( SELECT fqdnhash, fqdn FROM Records WHERE zone_id = in_zone_id AND auth = 1 ORDER BY fqdnhash DESC ) WHERE ROWNUM = 1; END; BEGIN SELECT * INTO out_next FROM ( SELECT fqdnhash FROM Records WHERE zone_id = in_zone_id AND fqdnhash > in_fqdnhash AND auth = 1 ORDER BY fqdnhash ASC ) WHERE ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN SELECT * INTO out_next FROM ( SELECT fqdnhash FROM Records WHERE zone_id = in_zone_id AND auth = 1 ORDER BY fqdnhash ASC ) WHERE ROWNUM = 1; END; END; / SHOW ERRORS CREATE TRIGGER records_fill_columns BEFORE INSERT OR UPDATE ON Records FOR EACH ROW BEGIN -- 'www.site.example' => 'example site www' for NSEC ordering :NEW.revfqdn := label_reverse(LOWER(:NEW.fqdn)); -- Hash the FQDN for NSEC3 ordering DECLARE nsec3param_string VARCHAR2(512); nsec3param_pattern VARCHAR2(512) := '^(\d+) +(\d+) +(\d+) +([0-9A-Fa-f]+)'; hashalgo BINARY_INTEGER; itcount BINARY_INTEGER; salt RAW(256); BEGIN SELECT meta_content INTO nsec3param_string FROM ZoneMetadata WHERE zone_id = :NEW.zone_id AND meta_type = 'NSEC3PARAM'; hashalgo := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 1); IF hashalgo != 1 THEN RAISE_APPLICATION_ERROR(-20000, 'NSEC3 hash is not SHA-1'); END IF; itcount := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 3); salt := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 4); :NEW.fqdnhash := dnsname_to_hashname(:NEW.fqdn, salt, itcount); EXCEPTION WHEN NO_DATA_FOUND THEN NULL; END; END; / SHOW ERRORS CREATE TRIGGER parse_zone_defining_records AFTER INSERT OR UPDATE ON Records FOR EACH ROW WHEN (NEW.type IN ('SOA')) BEGIN CASE :NEW.type WHEN 'SOA' THEN DECLARE pattern VARCHAR2(32) := '^[^ ]+ +[^ ]+ +(\d+) +(\d+)'; serial_str VARCHAR2(32) := REGEXP_SUBSTR(:NEW.content, pattern, 1, 1, '', 1); serial_num NUMBER(10,0) := TO_NUMBER(serial_str); refresh_str VARCHAR2(32) := REGEXP_SUBSTR(:NEW.content, pattern, 1, 1, '', 2); BEGIN IF serial_num = 0 THEN SELECT NVL(max(last_change), 0) INTO serial_num FROM Records WHERE zone_id = :NEW.zone_id; END IF; UPDATE Zones SET serial = serial_num, refresh = TO_NUMBER(refresh_str) WHERE id = :NEW.zone_id; END; END CASE; END; / SHOW ERRORS -- End of schema -- vi: set sw=2 et : -- pdns-3.3/modules/oraclebackend/OBJECTFILES0000644000014601777760000000002012136555572021467 0ustar00jenkinsnogroup00000000000000oraclebackend.o pdns-3.3/modules/oraclebackend/Makefile.in0000644000014601777760000004765512165464027022105 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/oraclebackend DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ ChangeLog INSTALL TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) liboraclebackend_la_DEPENDENCIES = am_liboraclebackend_la_OBJECTS = oraclebackend.lo liboraclebackend_la_OBJECTS = $(am_liboraclebackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent liboraclebackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(liboraclebackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(liboraclebackend_la_SOURCES) DIST_SOURCES = $(liboraclebackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = $(ORACLE_CFLAGS) @THREADFLAGS@ lib_LTLIBRARIES = liboraclebackend.la EXTRA_DIST = OBJECTFILES OBJECTLIBS schema.sql dropschema.sql liboraclebackend_la_SOURCES = oraclebackend.cc oraclebackend.hh liboraclebackend_la_LDFLAGS = -module -avoid-version $(ORACLE_LIBS) liboraclebackend_la_LIBADD = -lclntsh all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/oraclebackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/oraclebackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done liboraclebackend.la: $(liboraclebackend_la_OBJECTS) $(liboraclebackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(liboraclebackend_la_LINK) -rpath $(libdir) $(liboraclebackend_la_OBJECTS) $(liboraclebackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oraclebackend.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/oraclebackend/ChangeLog0000644000014601777760000000000012136555572021563 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/oraclebackend/INSTALL0000644000014601777760000000000012136555572021042 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/oraclebackend/README0000644000014601777760000000336612136555572020713 0ustar00jenkinsnogroup00000000000000An Oracle Database backend was originally contributed to PowerDNS in 2002 by Stefan Arentz. A new version amounting to a complete rewrite was contributed in 2011 by Maik Zumstrull , then at the Steinbuch Centre for Computing at the Karlsruhe Institute of Technology . --- Licensing Any contributions submitted to PowerDNS.COM BV by Maik Zumstrull / SCC are released under the conditions of the MIT license. Note that additional or different licensing terms may apply to code as redistributed by PowerDNS.COM BV. The terms of the license are found below. --- The MIT License Copyright (c) 2010-2011 Maik Zumstrull Steinbuch Centre for Computing Karlsruhe Institute of Technology Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pdns-3.3/modules/oraclebackend/TODO0000644000014601777760000000012612136555572020512 0ustar00jenkinsnogroup00000000000000 Oracle Backend todo Clean up our stuff in the destructor write configure.in stuff pdns-3.3/modules/oraclebackend/Makefile.am0000644000014601777760000000046412140444471022051 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=$(ORACLE_CFLAGS) @THREADFLAGS@ lib_LTLIBRARIES = liboraclebackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS schema.sql dropschema.sql liboraclebackend_la_SOURCES=oraclebackend.cc oraclebackend.hh liboraclebackend_la_LDFLAGS=-module -avoid-version $(ORACLE_LIBS) liboraclebackend_la_LIBADD=-lclntsh pdns-3.3/modules/gpgsqlbackend/0000755000014601777760000000000012165464054020047 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/gpgsqlbackend/OBJECTLIBS0000644000014601777760000000002612136555572021414 0ustar00jenkinsnogroup00000000000000-lpq -lssl -lcrypto pdns-3.3/modules/gpgsqlbackend/gpgsqlbackend.cc0000644000014601777760000002663312145153461023170 0ustar00jenkinsnogroup00000000000000#include #include #include "pdns/namespaces.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "gpgsqlbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "spgsql.hh" #include gPgSQLBackend::gPgSQLBackend(const string &mode, const string &suffix) : GSQLBackend(mode,suffix) { try { setDB(new SPgSQL(getArg("dbname"), getArg("host"), getArg("port"), getArg("socket"), getArg("user"), getArg("password"))); } catch(SSqlException &e) { L<~ limit 1"); declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select ordername from records where ordername ~>~ E'%s' and domain_id=%d and ordername is not null order by 1 using ~<~ limit 1"); declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 using ~>~ limit 1"); declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername=E'%s',auth=(%d = 1) where name=E'%s' and domain_id='%d'"); declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=true where domain_id='%d' and name='%s' and type='DS'"); declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=(%d = 1) where domain_id='%d' and name='%s'"); declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=false where name=E'%s' and type=E'%s' and domain_id='%d'"); declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d"); declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d"); declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d"); declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); declare(suffix,"delete-zone-query","", "delete from records where domain_id=%d"); declare(suffix,"delete-rrset-query","","delete from records where domain_id=%d and name=E'%s' and type=E'%s'"); declare(suffix,"add-domain-key-query","", "insert into cryptokeys (domain_id, flags, active, content) select id, %d, (%d = 1), '%s' from domains where name=E'%s'"); declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, case when active then 1 else 0 end as active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name=E'%s'"); declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name=E'%s' and domainmetadata.kind=E'%s'"); declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name=E'%s') and domainmetadata.kind=E'%s'"); declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (domain_id, kind, content) select id, '%s', '%s' from domains where name=E'%s'"); declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=true where domain_id=(select id from domains where name=E'%s') and cryptokeys.id=%d"); declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=false where domain_id=(select id from domains where name=E'%s') and cryptokeys.id=%d"); declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name=E'%s') and cryptokeys.id=%d"); declare(suffix,"get-tsig-key-query","", "select algorithm, secret from tsigkeys where name=E'%s'"); declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'"); } DNSBackend *make(const string &suffix="") { return new gPgSQLBackend(d_mode,suffix); } private: const string d_mode; }; //! Magic class that is activated when the dynamic library is loaded class gPgSQLLoader { public: //! This reports us to the main UeberBackend class gPgSQLLoader() { BackendMakers().report(new gPgSQLFactory("gpgsql")); BackendMakers().report(new gPgSQLFactory("gpgsql2")); L< #include "spgsql.hh" #include #include "pdns/logger.hh" #include "pdns/dns.hh" #include "pdns/namespaces.hh" bool SPgSQL::s_dolog; SPgSQL::SPgSQL(const string &database, const string &host, const string& port, const string &msocket, const string &user, const string &password) { d_db=0; d_connectstr="dbname="; d_connectstr+=database; d_connectstr+=" user="; d_connectstr+=user; if(!host.empty()) d_connectstr+=" host="+host; if(!port.empty()) d_connectstr+=" port="+port; d_connectlogstr=d_connectstr; if(!password.empty()) { d_connectlogstr+=" password="; d_connectstr+=" password="+password; } ensureConnect(); } void SPgSQL::setLog(bool state) { s_dolog=state; } SPgSQL::~SPgSQL() { PQfinish(d_db); } SSqlException SPgSQL::sPerrorException(const string &reason) { return SSqlException(reason+string(": ")+(d_db ? PQerrorMessage(d_db) : "no connection")); } void SPgSQL::ensureConnect() { if(d_db) PQfinish(d_db); d_db=PQconnectdb(d_connectstr.c_str()); if (!d_db || PQstatus(d_db)==CONNECTION_BAD) { try { throw sPerrorException("Unable to connect to database, connect string: "+d_connectlogstr); } catch(...) { if(d_db) PQfinish(d_db); d_db = 0; throw; } } } int SPgSQL::doCommand(const string &query) { if(s_dolog) L<= PQntuples(d_result)) { PQclear(d_result); return false; } for(int i=0;i #include #include "pdns/backends/gsql/gsqlbackend.hh" #include "pdns/namespaces.hh" /** The gPgSQLBackend is a DNSBackend that can answer DNS related questions. It looks up data in PostgreSQL */ class gPgSQLBackend : public GSQLBackend { public: gPgSQLBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails. }; pdns-3.3/modules/gpgsqlbackend/spgsql.hh0000644000014601777760000000164512136555572021713 0ustar00jenkinsnogroup00000000000000/* Copyright 2001 - 2005 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE for more information. */ #ifndef SPGSQL_HH #define SPGSQL_HH #include "pdns/namespaces.hh" #include "pdns/backends/gsql/ssql.hh" #include class SPgSQL : public SSql { public: SPgSQL(const string &database, const string &host="", const string& port="", const string &msocket="",const string &user="", const string &password=""); ~SPgSQL(); SSqlException sPerrorException(const string &reason); int doQuery(const string &query, result_t &result); int doQuery(const string &query); int doCommand(const string &query); bool getRow(row_t &row); string escape(const string &str); void setLog(bool state); private: void ensureConnect(); PGconn* d_db; string d_connectstr; string d_connectlogstr; PGresult* d_result; int d_count; static bool s_dolog; }; #endif /* SPGSQL_HH */ pdns-3.3/modules/gpgsqlbackend/Makefile.am0000644000014601777760000000111112140444471022067 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=-I@PGSQL_incdir@ @THREADFLAGS@ lib_LTLIBRARIES = libgpgsqlbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libgpgsqlbackend_la_SOURCES=gpgsqlbackend.cc gpgsqlbackend.hh \ spgsql.hh spgsql.cc ## Filter out known build breakers for Mac OS X ## Don't remove the empty lines between if and endif or tabs will screw up your makefile if OS_MACOSX libgpgsqlbackend_la_LDFLAGS=-module -avoid-version @PGSQL_lib@ -lpq else libgpgsqlbackend_la_LDFLAGS=-module -avoid-version @PGSQL_lib@ -Wl,-Bstatic -lpq -Wl,-Bdynamic endif libgpgsqlbackend_la_LIBADD=-lssl @LIBCRYPT@ -lcrypto pdns-3.3/modules/godbcbackend/0000755000014601777760000000000012165464054017630 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/godbcbackend/sodbc.hh0000644000014601777760000000436412136555572021256 0ustar00jenkinsnogroup00000000000000// The Generic ODBC Backend // By Michel Stol #ifndef SODBC_HH #define SODBC_HH #include #include // The following line makes Bert puke every time he sees it. //#define WINDOWS_LEAN_AND_MEAN //#include #include #include #include "pdns/backends/gsql/ssql.hh" //! ODBC SSql implementation for use with the Generic ODBC Backend. class SODBC : public SSql { private: //! Column type. struct column_t { SQLSMALLINT m_type; //!< Type of the column. SQLULEN m_size; //!< Column size. SQLPOINTER m_pData; //!< Pointer to the memory where to store the data. bool m_canBeNull; //!< Can this column be null? }; bool m_log; //!< Should we log? bool m_busy; //!< Are we busy executing a query? SQLHDBC m_connection; //!< Database connection handle. SQLHENV m_environment; //!< Database environment handle SQLHSTMT m_statement; //!< Database statement handle. //! Column info. std::vector< column_t > m_columnInfo; //! Throws a SQLException if the result has an error value. void testResult( SQLRETURN result, const std::string & message = "" ); public: //! Default constructor. /*! This constructor connects to an ODBC datasource and makes sure it's ready to use. \param database The database where the data is located (not used). \param dsn The ODBC DSN to use. \param username Username to use. \param password Password to use. */ SODBC( const std::string & dsn = "PowerDNS", const std::string & username = "", const std::string & password = "" ); //! Destructor. virtual ~SODBC( void ); //! Executes a query. int doQuery( const std::string & query ); //! Executes a query and stores the result. int doQuery( const std::string & query, result_t & result ); //! Executes a command. int doCommand( const std::string & command ); //! Escapes a SQL string. std::string escape( const std::string & name ); //! Returns a row. bool getRow( row_t & row ); //! Sets the logging state. void setLog( bool state ); //! Returns an exception. SSqlException sPerrorException( const std::string & reason ); }; #endif // SODBC_HH pdns-3.3/modules/godbcbackend/OBJECTLIBS0000644000014601777760000000000012136555572021165 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/godbcbackend/godbcbackend.cc0000644000014601777760000001076512136555572022542 0ustar00jenkinsnogroup00000000000000// The Generic ODBC Backend // By Michel Stol #include "pdns/utility.hh" #include #include #include #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "sodbc.hh" #include "godbcbackend.hh" // Connects to the database. gODBCBackend::gODBCBackend (const std::string & mode, const std::string & suffix) : GSQLBackend( mode, suffix ) { try { setDB( new SODBC( getArg( "datasource" ), getArg( "username" ), getArg( "password" ))); } catch( SSqlException & e ) { L< #include "pdns/utility.hh" #include #include "sodbc.hh" #include #include // Constructor. SODBC::SODBC( const std::string & dsn, const std::string & username, const std::string & password ) { SQLRETURN result; // Allocate an environment handle. result = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_environment ); testResult( result, "Could not allocate an environment handle." ); // Set ODBC version. (IEUW!) result = SQLSetEnvAttr( m_environment, SQL_ATTR_ODBC_VERSION, reinterpret_cast< void * >( SQL_OV_ODBC3 ), 0 ); testResult( result, "Could not set the ODBC version." ); // Allocate connection handle. result = SQLAllocHandle( SQL_HANDLE_DBC, m_environment, &m_connection ); testResult( result, "Could not allocate a connection handle." ); // Connect to the database. char *l_dsn = strdup( dsn.c_str()); char *l_username = strdup( username.c_str()); char *l_password = strdup( password.c_str()); result = SQLConnect( m_connection, reinterpret_cast< SQLTCHAR * >( l_dsn ), dsn.length(), reinterpret_cast< SQLTCHAR * >( l_username ), username.length(), reinterpret_cast< SQLTCHAR * >( l_password ), password.length()); free( l_dsn ); free( l_username ); free( l_password ); testResult( result, "Could not connect to ODBC datasource." ); // Allocate statement handle. result = SQLAllocHandle( SQL_HANDLE_STMT, m_connection, &m_statement ); testResult( result, "Could not allocate a statement handle." ); m_busy = false; m_log = false; } // Destructor. SODBC::~SODBC( void ) { // Disconnect from database and free all used resources. SQLFreeHandle( SQL_HANDLE_STMT, m_statement ); SQLDisconnect( m_connection ); SQLFreeHandle( SQL_HANDLE_DBC, m_connection ); SQLFreeHandle( SQL_HANDLE_ENV, m_environment ); // Free all allocated column memory. for ( int i = 0; i < m_columnInfo.size(); i++ ) { if ( m_columnInfo[ i ].m_pData ) delete m_columnInfo[ i ].m_pData; } } // Executes a query. int SODBC::doQuery( const std::string & query ) { SQLRETURN result; char *tmp; if ( m_busy ) throw SSqlException( "Tried to execute another query while being busy." ); tmp = strdup( query.c_str()); // Execute query. result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), query.length()); free( tmp ); testResult( result, "Could not execute query." ); // We are now busy. m_busy = true; // Determine the number of columns. SQLSMALLINT numColumns; SQLNumResultCols( m_statement, &numColumns ); if ( numColumns == 0 ) throw SSqlException( "Could not determine the number of columns." ); // Fill m_columnInfo. m_columnInfo.clear(); column_t column; SQLSMALLINT nullable; SQLSMALLINT type; for ( SQLSMALLINT i = 1; i <= numColumns; i++ ) { SQLDescribeCol( m_statement, i, NULL, 0, NULL, &type, &column.m_size, NULL, &nullable ); if ( nullable == SQL_NULLABLE ) column.m_canBeNull = true; else column.m_canBeNull = false; // Allocate memory. switch ( type ) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: column.m_type = SQL_C_CHAR; column.m_pData = new SQLCHAR[ column.m_size ]; break; case SQL_SMALLINT: case SQL_INTEGER: column.m_type = SQL_C_SLONG; column.m_size = sizeof( long int ); column.m_pData = new long int; break; case SQL_REAL: case SQL_FLOAT: case SQL_DOUBLE: column.m_type = SQL_C_DOUBLE; column.m_size = sizeof( double ); column.m_pData = new double; break; default: column.m_pData = NULL; } m_columnInfo.push_back( column ); } return 0; } // Executes a query. int SODBC::doQuery( const std::string & query, result_t & result ) { result.clear(); doQuery( query ); row_t row; while ( getRow( row )) result.push_back( row ); return result.size(); } // Executes a command. int SODBC::doCommand( const std::string & command ) { SQLRETURN result; char *tmp; if ( m_busy ) throw SSqlException( "Tried to execute another query while being busy." ); tmp = strdup( command.c_str()); // Execute query. result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), command.length()); free( tmp ); testResult( result, "Could not execute query." ); SQLFreeStmt( m_statement, SQL_CLOSE ); return 0; } // Escapes a SQL string. std::string SODBC::escape( const std::string & name ) { std::string a; for( std::string::const_iterator i = name.begin(); i != name.end(); ++i ) { if( *i == '\'' || *i == '\\' ) a += '\\'; a += *i; } return a; } // Returns the content of a row. bool SODBC::getRow( row_t & row ) { SQLRETURN result; row.clear(); result = SQLFetch( m_statement ); if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO ) { // We've got a data row, now lets get the results. SQLLEN len; for ( int i = 0; i < m_columnInfo.size(); i++ ) { if ( m_columnInfo[ i ].m_pData == NULL ) continue; // Clear buffer. memset( m_columnInfo[ i ].m_pData, 0, m_columnInfo[ i ].m_size ); SQLGetData( m_statement, i + 1, m_columnInfo[ i ].m_type, m_columnInfo[ i ].m_pData, m_columnInfo[ i ].m_size, &len ); if ( len == SQL_NULL_DATA ) { // Column is NULL, so we can skip the converting part. row.push_back( "" ); continue; } // Convert the data into strings. std::ostringstream str; switch ( m_columnInfo[ i ].m_type ) { case SQL_C_CHAR: row.push_back( reinterpret_cast< char * >( m_columnInfo[ i ].m_pData )); break; case SQL_C_SSHORT: case SQL_C_SLONG: str << *( reinterpret_cast< long * >( m_columnInfo[ i ].m_pData )); row.push_back( str.str()); break; case SQL_C_DOUBLE: str << *( reinterpret_cast< double * >( m_columnInfo[ i ].m_pData )); row.push_back( str.str()); break; default: // Eh? row.push_back( "" ); } } // Done! return true; } // No further results, or error. m_busy = false; // Free all allocated column memory. for ( int i = 0; i < m_columnInfo.size(); i++ ) { if ( m_columnInfo[ i ].m_pData ) delete m_columnInfo[ i ].m_pData; } SQLFreeStmt( m_statement, SQL_CLOSE ); return false; } // Sets the log state. void SODBC::setLog( bool state ) { m_log = state; } // Returns an exception. SSqlException SODBC::sPerrorException( const std::string & reason ) { return SSqlException( reason ); } // Tests the result. void SODBC::testResult( SQLRETURN result, const std::string & message ) { if ( result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO ) throw SSqlException( message ); } pdns-3.3/modules/godbcbackend/OBJECTFILES0000644000014601777760000000000012136555572021276 0ustar00jenkinsnogroup00000000000000pdns-3.3/modules/godbcbackend/godbcbackend.hh0000644000014601777760000000055312136555572022546 0ustar00jenkinsnogroup00000000000000// The Generic ODBC Backend // By Michel Stol #include #include "pdns/backends/gsql/gsqlbackend.hh" class gODBCBackend : public GSQLBackend { private: public: //! Constructor that connects to the database, throws an exception if something went wrong. gODBCBackend( const std::string & mode, const std::string & suffix ); }; pdns-3.3/modules/godbcbackend/Makefile.in0000644000014601777760000004763512165464027021714 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/godbcbackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libgodbcbackend_la_LIBADD = am_libgodbcbackend_la_OBJECTS = godbcbackend.lo sodbc.lo libgodbcbackend_la_OBJECTS = $(am_libgodbcbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libgodbcbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libgodbcbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libgodbcbackend_la_SOURCES) DIST_SOURCES = $(libgodbcbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I@UNIXODBC_incdir@ @THREADFLAGS@ lib_LTLIBRARIES = libgodbcbackend.la EXTRA_DIST = OBJECTFILES OBJECTLIBS libgodbcbackend_la_SOURCES = godbcbackend.cc godbcbackend.hh \ sodbc.hh sodbc.cc libgodbcbackend_la_LDFLAGS = -module -avoid-version -lodbc all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/godbcbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/godbcbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libgodbcbackend.la: $(libgodbcbackend_la_OBJECTS) $(libgodbcbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libgodbcbackend_la_LINK) -rpath $(libdir) $(libgodbcbackend_la_OBJECTS) $(libgodbcbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/godbcbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sodbc.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/godbcbackend/Makefile.am0000644000014601777760000000042112140444471021653 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=-I@UNIXODBC_incdir@ @THREADFLAGS@ lib_LTLIBRARIES = libgodbcbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libgodbcbackend_la_SOURCES=godbcbackend.cc godbcbackend.hh \ sodbc.hh sodbc.cc libgodbcbackend_la_LDFLAGS=-module -avoid-version -lodbc pdns-3.3/modules/db2backend/0000755000014601777760000000000012165464053017220 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/db2backend/DB2Exception.cc0000644000014601777760000000216612136555572021767 0ustar00jenkinsnogroup00000000000000// $Id$ #include "DB2Exception.hh" DB2Exception::DB2Exception(SQLRETURN inError) : mError(inError), mHandle(SQL_NULL_HANDLE), mErrorIndex(1) { } DB2Exception::DB2Exception(SQLRETURN inError, SQLSMALLINT inHandleType, SQLHANDLE inHandle) : mError(inError), mHandle(inHandle), mHandleType(inHandleType), mErrorIndex(1) { } SQLRETURN DB2Exception::GetError() { return mError; } bool DB2Exception::GetNextSqlError(int& outNativeError, string& outSqlState, string& outSqlMessage) { SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1]; SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; SQLINTEGER sqlcode; SQLSMALLINT length; bool theResult = false; if (mHandle != SQL_NULL_HANDLE) { SQLRETURN theError = SQLGetDiagRec(mHandleType, mHandle, mErrorIndex, sqlstate, &sqlcode, message, SQL_MAX_MESSAGE_LENGTH + 1, &length); if (theError == SQL_SUCCESS) { outNativeError = sqlcode; outSqlState = (const char*) sqlstate; outSqlMessage = (const char*) message; mErrorIndex++; theResult = true; } } return theResult; } pdns-3.3/modules/db2backend/DB2Backend.cc0000644000014601777760000004730112145162536021352 0ustar00jenkinsnogroup00000000000000// $Id$ #include #include #include #include #include "pdns/namespaces.hh" #include #include #include #include #include #include #include #include "DB2Exception.hh" #include "DB2Backend.hh" static const string kBackendName="[DB2Backend]"; static const int kForwardQuery = 0; static const int kForwardByZoneQuery = 1; static const int kForwardAnyQuery = 2; static const int kForwardWildcardQuery = 3; static const int kForwardWildcardAnyQuery = 4; static const int kListQuery = 5; static const int kNumQueries = 6; static const char *kQueries[kNumQueries] = { // ForwardQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where Name = ? and type = ?", // ForwardByZoneQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where Name = ? and Type = ? and ZoneId = ?", // ForwardAnyQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where Name = ?", // ForwardWildcardQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where Name like ? and Type = ?", // ForwardWildcardAnyQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where Name like ?", // ListQuery "select Content, TimeToLive, Priority, Type, ZoneId, 0 as ChangeDate, Name from Records where ZoneId = ?" }; static const char *kSoaQuery = "select Id,Hostmaster,Serial from Zones where Active = 1 and Name = ?"; DB2Backend::DB2Backend(const string &suffix) { SQLRETURN theError; // Initialize the handles mConnection = SQL_NULL_HANDLE; mEnvironment = SQL_NULL_HANDLE; for (int i = 0; i < kNumQueries; i++) { mStatements[i] = SQL_NULL_HANDLE; } try { // Allocate the Environment Handle theError = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &mEnvironment); if (theError != SQL_SUCCESS) { throw DB2Exception(theError); } // Allocate a Connection Handle theError = SQLAllocHandle(SQL_HANDLE_DBC, mEnvironment, &mConnection); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_ENV, mEnvironment); } // Try to connect to the database theError = SQLConnect(mConnection, (SQLCHAR*) arg()["db2-"+suffix+"server"].c_str(), SQL_NTS, (SQLCHAR*) arg()["db2-"+suffix+"user"].c_str(), SQL_NTS, (SQLCHAR*) arg()["db2-"+suffix+"password"].c_str(), SQL_NTS); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mConnection); } // Set autocommit to off theError = SQLSetConnectAttr(mConnection, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, SQL_NTS); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mConnection); } // Prepare the statements for (int i = 0; i < kNumQueries; i++) { // Allocate a Statement Handle theError = SQLAllocHandle(SQL_HANDLE_STMT, mConnection, &(mStatements[i])); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mConnection); } // Prepare the statement theError = SQLPrepare(mStatements[i], (SQLCHAR*) kQueries[i], SQL_NTS); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // // Bind Parameters // // Bind the Name parameter to all queries except the list statements if (i != kListQuery) { theError = SQLBindParameter(mStatements[i], 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 256, 0, mParamName, 256, NULL); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } } // Bind the Type parameter only to the kForwardQuery, kForwardByZoneQuery and kForwardWildcardQuery statements if (i == kForwardQuery || i == kForwardByZoneQuery || i == kForwardWildcardQuery) { theError = SQLBindParameter(mStatements[i], 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 256, 0, mParamType, 256, NULL); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } } // Bind the ZoneId parameter for the kForwardByZoneQuery and kListQuery queries if (i == kForwardByZoneQuery || i == kListQuery) { int theIndex = (i == kForwardByZoneQuery) ? 3 : 1; theError = SQLBindParameter(mStatements[i], theIndex, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &mParamZoneId, 0, NULL); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } } // // Bind Columns // // Bind the Content column mResultContentIndicator = 0; theError = SQLBindCol(mStatements[i], 1, SQL_C_CHAR, mResultContent, sizeof(mResultContent), &mResultContentIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the TimeToLive column mResultTimeToLiveIndicator = 0; theError = SQLBindCol(mStatements[i], 2, SQL_C_LONG, &mResultTimeToLive, sizeof(mResultTimeToLive), &mResultTimeToLiveIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the Priority column mResultPriorityIndicator = 0; theError = SQLBindCol(mStatements[i], 3, SQL_C_LONG, &mResultPriority, sizeof(mResultZoneId), &mResultPriorityIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the Type column mResultTypeIndicator = 0; theError = SQLBindCol(mStatements[i], 4, SQL_C_CHAR, mResultType, sizeof(mResultType), &mResultTypeIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the ZoneId column mResultZoneIdIndicator = 0; theError = SQLBindCol(mStatements[i], 5, SQL_C_LONG, &mResultZoneId, sizeof(mResultZoneId), &mResultZoneIdIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the ChangeDate column mResultChangeDateIndicator = 0; theError = SQLBindCol(mStatements[i], 6, SQL_C_LONG, &mResultChangeDate, sizeof(mResultChangeDate), &mResultChangeDateIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } // Bind the Name column mResultNameIndicator = 0; theError = SQLBindCol(mStatements[i], 7, SQL_C_CHAR, mResultName, sizeof(mResultName), &mResultNameIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mStatements[i]); } mStatementStates[i] = false; } // // Construct the SOA Query // // Prepare the SOA Query theError = SQLAllocHandle(SQL_HANDLE_STMT, mConnection, &mSoaStatement); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_DBC, mConnection); } theError = SQLPrepare(mSoaStatement, (SQLCHAR*) kSoaQuery, SQL_NTS); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } // Bind the Name parameter theError = SQLBindParameter(mSoaStatement, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 256, 0, mSoaParamName, 256, NULL); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } // Bind the ZoneId column mSoaResultZoneIdIndicator = 0; theError = SQLBindCol(mSoaStatement, 1, SQL_C_LONG, &mSoaResultZoneId, sizeof(mSoaResultZoneId), &mSoaResultZoneIdIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } // Bind the Hostmaster column mSoaResultHostmasterIndicator = 0; theError = SQLBindCol(mSoaStatement, 2, SQL_C_CHAR, mSoaResultHostmaster, 256, &mSoaResultHostmasterIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } // Bind the Serial column mSoaResultSerialIndicator = 0; theError = SQLBindCol(mSoaStatement, 3, SQL_C_LONG, &mSoaResultSerial, sizeof(mSoaResultSerial), &mSoaResultSerialIndicator); if (theError != SQL_SUCCESS) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } } catch (DB2Exception& theException) { // // Print out diagnostics // int theNativeError; string theSqlState, theSqlMessage; while (theException.GetNextSqlError(theNativeError, theSqlState, theSqlMessage) == true) { L << Logger::Warning << kBackendName << " Statement initialization failed with error " << theNativeError << endl; L << Logger::Warning << kBackendName << " SQL State : " << theSqlState << endl; L << Logger::Warning << kBackendName << " SQL Msg : " << theSqlMessage << endl; } this->Cleanup(); throw AhuException("DB2Backend Failed to Start"); } L << Logger::Warning << kBackendName << " Connection succeeded" << endl; } void DB2Backend::Cleanup() { for (int i = 0; i < kNumQueries; i++) { if (mStatements[i] != SQL_NULL_HANDLE) { (void) SQLFreeHandle(SQL_HANDLE_STMT, mStatements[i]); } } if (mConnection != SQL_NULL_HANDLE) { (void) SQLFreeHandle(SQL_HANDLE_DBC, mConnection); } if (mEnvironment != SQL_NULL_HANDLE) { (void) SQLFreeHandle(SQL_HANDLE_ENV, mEnvironment); } } DB2Backend::~DB2Backend() { this->Cleanup(); } void DB2Backend::lookup(const QType &qtype, const string &qname, DNSPacket *pkt_p, int zoneId ) { SQLRETURN theError; // // Choose the right query. All this logic and the query types could be // moved to the API. Saves duplicate code in backends. // int theQueryType = -1; if (qname[0] == '%') { if (qtype.getCode() == 255) { theQueryType = kForwardWildcardAnyQuery; } else { theQueryType = kForwardWildcardQuery; } } else { if (qtype.getCode() == 255) { theQueryType = kForwardAnyQuery; } else { if (zoneId != -1) { theQueryType = kForwardByZoneQuery; } else { theQueryType = kForwardQuery; } } } // // Fill in the correct query parameters // //cerr << ">>>>>>>> Query = " << kQueries[theQueryType] << endl; switch (theQueryType) { case kForwardQuery: case kForwardWildcardQuery: strncpy(mParamName, qname.c_str(), sizeof(mParamName)); strncpy(mParamType, qtype.getName().c_str(), sizeof(mParamType)); //cerr << ">>>>>>>> Name = " << mParamName << " Type = " << mParamType << endl; break; case kForwardByZoneQuery: strncpy(mParamName, qname.c_str(), sizeof(mParamName)); strncpy(mParamType, qtype.getName().c_str(), sizeof(mParamType)); mParamZoneId = zoneId; //cerr << ">>>>>>>> Name = " << mParamName << " Type = " << mParamType << " ZoneId = " << mParamZoneId << endl; break; case kForwardAnyQuery: case kForwardWildcardAnyQuery: strncpy(mParamName, qname.c_str(), sizeof(mParamName)); //cerr << ">>>>>>>> Name = " << mParamName << endl; break; } // // Execute the query // try { // // Close the cursor if it is in use // if (mStatementStates[theQueryType] == true) { theError = SQLCloseCursor(mStatements[theQueryType]); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO) { throw DB2Exception(theError, SQL_HANDLE_STMT, mStatements[theQueryType]); } } // // Execute the query // mResultContent[0] = mResultType[0] = mResultName[0] = 0x00; mResultTimeToLive = mResultPriority = mResultZoneId = mResultChangeDate = 0; theError = SQLExecute(mStatements[theQueryType]); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO && theError != SQL_NO_DATA_FOUND) { throw DB2Exception(theError, SQL_HANDLE_STMT, mStatements[theQueryType]); } mCurrentStatement = mStatements[theQueryType]; mStatementStates[theQueryType] = true; } catch (DB2Exception& theException) { // // Print out diagnostics // int theNativeError; string theSqlState, theSqlMessage; while (theException.GetNextSqlError(theNativeError, theSqlState, theSqlMessage) == true) { L << Logger::Warning << kBackendName << " SQLExecute() failed with error " << theNativeError << endl; L << Logger::Warning << kBackendName << " SQL State : " << theSqlState << endl; L << Logger::Warning << kBackendName << " SQL Msg : " << theSqlMessage << endl; } // // Rethrow for the nameserver // throw AhuException("Execute failed"); } } bool DB2Backend::list(int inZoneId) { SQLRETURN theError; bool theResult = false; try { // // Close the cursor // if (mStatementStates[kListQuery] == true) { theError = SQLCloseCursor(mStatements[kListQuery]); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO) { throw DB2Exception(theError, SQL_HANDLE_STMT, mCurrentStatement); } } // // Execute the query // mParamZoneId = inZoneId; theError = SQLExecute(mStatements[kListQuery]); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO && theError != SQL_NO_DATA_FOUND) { throw DB2Exception(theError, SQL_HANDLE_STMT, mStatements[kListQuery]); } mCurrentStatement = mStatements[kListQuery]; mStatementStates[kListQuery] = true; if (theResult != SQL_NO_DATA_FOUND) { theResult = true; } } catch (DB2Exception& theException) { throw AhuException("List failed"); } return theResult; } bool DB2Backend::get(DNSResourceRecord& outRecord) { bool theResult = false; try { // // Fetch a record // SQLRETURN theError = SQLFetch(mCurrentStatement); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO && theError != SQL_NO_DATA_FOUND) { throw DB2Exception(theError, SQL_HANDLE_STMT, mCurrentStatement); } // // If we have data then return it // //cerr << ">>>>>>>> Get theError = " << theError << endl; if (theError != SQL_NO_DATA_FOUND) { //cerr << ">>>>>>>> Name = " << mResultName << endl; //cerr << ">>>>>>>> Content = " << mResultContent << endl; //cerr << ">>>>>>>> Type = " << mResultType << endl; outRecord.content = mResultContent; outRecord.ttl = mResultTimeToLive; outRecord.priority = mResultPriority; outRecord.qtype = mResultType; outRecord.domain_id = mResultZoneId; outRecord.last_modified = mResultChangeDate; outRecord.qname = mResultName; theResult = true; } } catch (DB2Exception& theException) { // // Print out diagnostics // int theNativeError; string theSqlState, theSqlMessage; while (theException.GetNextSqlError(theNativeError, theSqlState, theSqlMessage) == true) { L << Logger::Warning << kBackendName << " SQLFetch() failed with error " << theNativeError << endl; L << Logger::Warning << kBackendName << " SQL State : " << theSqlState << endl; L << Logger::Warning << kBackendName << " SQL Msg : " << theSqlMessage << endl; } // // Rethrow for the nameserver // throw AhuException("Fetch failed"); } return theResult; } bool DB2Backend::getSOA(const string& inZoneName, SOAData& outSoaData) { bool theResult = false; try { // // Execute the query // strncpy(mSoaParamName, inZoneName.c_str(), sizeof(mSoaParamName)); SQLRETURN theError = SQLExecute(mSoaStatement); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO && theError != SQL_NO_DATA_FOUND) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } if (theError != SQL_NO_DATA_FOUND) { mSoaResultZoneId = mSoaResultSerial = 0; mSoaResultHostmaster[0] = mSoaResultNameserver[0] = 0x00; theError = SQLFetch(mSoaStatement); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } outSoaData.domain_id = mSoaResultZoneId; outSoaData.nameserver = arg()["default-soa-name"]; outSoaData.hostmaster = mSoaResultHostmaster; outSoaData.serial = mSoaResultSerial; outSoaData.refresh = 10800; outSoaData.retry = 3600; outSoaData.expire = 604800; outSoaData.default_ttl = 3600; theResult = true; } // // Close the cursor // theError = SQLCloseCursor(mSoaStatement); if (theError != SQL_SUCCESS && theError != SQL_SUCCESS_WITH_INFO) { throw DB2Exception(theError, SQL_HANDLE_STMT, mSoaStatement); } } catch (DB2Exception& theException) { // // Print out diagnostics // int theNativeError; string theSqlState, theSqlMessage; while (theException.GetNextSqlError(theNativeError, theSqlState, theSqlMessage) == true) { L << Logger::Warning << kBackendName << " SOA Record Lookup Failed: " << theNativeError << endl; L << Logger::Warning << kBackendName << " SQL State : " << theSqlState << endl; L << Logger::Warning << kBackendName << " SQL Msg : " << theSqlMessage << endl; } // // Rethrow for the nameserver // throw AhuException("GetSOA failed"); } return theResult; } //! For the dynamic loader DNSBackend *DB2Backend::maker() { DNSBackend *theBackend; try { theBackend = new DB2Backend; } catch (...) { theBackend = NULL; } return theBackend; } class DB2Factory : public BackendFactory { public: DB2Factory() : BackendFactory("db2") {} void declareArguments(const string &suffix="") { declare(suffix,"server","Server","powerdns"); declare(suffix,"user","User","powerdns"); declare(suffix,"password","Password","powerdns"); } DNSBackend *make(const string &suffix="") { return new DB2Backend(suffix); } }; //! Magic class that is activated when the dynamic library is loaded class DB2Loader { public: Loader() { BackendMakers().report(new DB2Factory); L << Logger::Notice << kBackendName << " This is the DB2 module version "VERSION" ("__DATE__", "__TIME__") reporting" << endl; } }; static DB2Loader db2loader; pdns-3.3/modules/db2backend/Makefile.in0000644000014601777760000004747612165464026021307 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/db2backend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libdb2backend_la_LIBADD = am_libdb2backend_la_OBJECTS = DB2Backend.lo DB2Exception.lo libdb2backend_la_OBJECTS = $(am_libdb2backend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libdb2backend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libdb2backend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libdb2backend_la_SOURCES) DIST_SOURCES = $(libdb2backend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ lib_LTLIBRARIES = libdb2backend.la libdb2backend_la_SOURCES = DB2Backend.cc DB2Backend.hh DB2Exception.cc DB2Exception.hh libdb2backend_la_LDFLAGS = -module -avoid-version -ldb2 all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/db2backend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/db2backend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libdb2backend.la: $(libdb2backend_la_OBJECTS) $(libdb2backend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libdb2backend_la_LINK) -rpath $(libdir) $(libdb2backend_la_OBJECTS) $(libdb2backend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DB2Backend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DB2Exception.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/db2backend/DB2Exception.hh0000644000014601777760000000115712136555572022000 0ustar00jenkinsnogroup00000000000000// $Id$ #ifndef DB2EXCEPTION_HH #define DB2EXCEPTION_HH #include #include "pdns/namespaces.hh" #include class DB2Exception { public: DB2Exception(SQLRETURN inError); DB2Exception(SQLRETURN inError, SQLSMALLINT inHandleType, SQLHANDLE inHandle); virtual ~DB2Exception(); SQLRETURN GetError(); bool GetNextSqlError(int& outNativeError, string& outSqlState, string& outSqlMessage); private: SQLRETURN mError; SQLHANDLE mHandle; SQLSMALLINT mHandleType; SQLSMALLINT mErrorIndex; }; #endif // DB2EXCEPTION_HH pdns-3.3/modules/db2backend/DB2Backend.hh0000644000014601777760000000400012136555572021357 0ustar00jenkinsnogroup00000000000000// $Id$ #ifndef DB2BACKEND_HH #define DB2BACKEND_HH #include #include #include "pdns/namespaces.hh" #include class DB2Backend : public DNSBackend { public: DB2Backend(const string &suffix = ""); ~DB2Backend(); void lookup(const QType &, const string &qdomain, DNSPacket *p = 0, int zoneId = -1); bool list(int inZoneId); bool get(DNSResourceRecord& outRecord); bool getSOA(const string &name, SOAData &soadata); static DNSBackend *maker(); private: void Cleanup(); private: // Handles SQLHANDLE mConnection; SQLHANDLE mEnvironment; SQLHANDLE mStatements[6]; bool mStatementStates[6]; SQLHANDLE mSoaStatement; SQLHANDLE mCurrentStatement; // Parameters char mParamName[256]; char mParamNameLength; char mParamType[256]; char mParamTypeLength; int mParamZoneId; int mParamZoneIdLength; // Columns char mResultContent[256]; SQLINTEGER mResultContentIndicator; int mResultTimeToLive; SQLINTEGER mResultTimeToLiveIndicator; int mResultPriority; SQLINTEGER mResultPriorityIndicator; char mResultType[256]; SQLINTEGER mResultTypeIndicator; int mResultZoneId; SQLINTEGER mResultZoneIdIndicator; int mResultChangeDate; SQLINTEGER mResultChangeDateIndicator; char mResultName[256]; SQLINTEGER mResultNameIndicator; // SOA Parameters char mSoaParamName[256]; // SOA Result int mSoaResultZoneId; SQLINTEGER mSoaResultZoneIdIndicator; char mSoaResultNameserver[256]; SQLINTEGER mSoaResultNameserverIndicator; char mSoaResultHostmaster[256]; SQLINTEGER mSoaResultHostmasterIndicator; int mSoaResultSerial; SQLINTEGER mSoaResultSerialIndicator; }; #endif /* DB2BACKEND_HH */ pdns-3.3/modules/db2backend/Makefile.am0000644000014601777760000000031312136555572021256 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ lib_LTLIBRARIES = libdb2backend.la libdb2backend_la_SOURCES=DB2Backend.cc DB2Backend.hh DB2Exception.cc DB2Exception.hh libdb2backend_la_LDFLAGS=-module -avoid-version -ldb2 pdns-3.3/modules/gsqlite3backend/0000755000014601777760000000000012165464054020305 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/gsqlite3backend/gsqlite3backend.hh0000644000014601777760000000112512136555572023674 0ustar00jenkinsnogroup00000000000000 // // SQLite backend for PowerDNS // Copyright (C) 2003, Michel Stol // #ifndef GSQLITEBACKEND_HH #define GSQLITEBACKEND_HH #include #include "pdns/backends/gsql/gsqlbackend.hh" //! The gSQLiteBackend retrieves it's data from a SQLite database (http://www.sqlite.org/) class gSQLite3Backend : public GSQLBackend { private: protected: public: //! Constructs the backend, throws an exception if it failed.. gSQLite3Backend( const std::string & mode, const std::string & suffix ); virtual string sqlEscape(const string &name); }; #endif // GSQLITEBACKEND_HH pdns-3.3/modules/gsqlite3backend/OBJECTLIBS0000644000014601777760000000001212136555572021645 0ustar00jenkinsnogroup00000000000000-lsqlite3 pdns-3.3/modules/gsqlite3backend/OBJECTFILES0000644000014601777760000000002212136555572021757 0ustar00jenkinsnogroup00000000000000gsqlite3backend.o pdns-3.3/modules/gsqlite3backend/gsqlite3backend.cc0000644000014601777760000002641412145153461023661 0ustar00jenkinsnogroup00000000000000// // SQLite backend for PowerDNS // Copyright (C) 2003, Michel Stol // Copyright (C) 2011, PowerDNS.COM BV // #include "pdns/utility.hh" #include #include #include #include #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "pdns/ssqlite3.hh" #include "gsqlite3backend.hh" #include // Connects to the database. gSQLite3Backend::gSQLite3Backend( const std::string & mode, const std::string & suffix ) : GSQLBackend( mode, suffix ) { try { SSQLite3 *ptr = new SSQLite3( getArg( "database" )); setDB( ptr); if(!getArg("pragma-synchronous").empty()) { SSQLite3::result_t res; ptr->doQuery("PRAGMA synchronous="+getArg("pragma-synchronous"), res); } } catch( SSqlException & e ) { L << Logger::Error << mode << ": connection failed: " << e.txtReason() << std::endl; throw AhuException( "Unable to launch " + mode + " connection: " + e.txtReason()); } L << Logger::Info << mode << ": connection to '"< '%s' and domain_id=%d and ordername is not null"); declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 desc limit 1"); declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'"); declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'"); declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'"); declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'"); declare( suffix, "master-zone-query", "Data", "select master from domains where name='%s' and type='SLAVE'"); declare( suffix, "info-zone-query", "","select id,name,master,last_check,notified_serial,type from domains where name='%s'"); declare( suffix, "info-all-slaves-query", "","select id,name,master,last_check,type from domains where type='SLAVE'"); declare( suffix, "supermaster-query", "", "select account from supermasters where ip='%s' and nameserver='%s'"); declare( suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE','%s','%s','%s')"); declare( suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,name) values ('%s',%d,%d,'%s',%d,'%s')"); declare( suffix, "insert-record-query-auth", "", "insert into records (content,ttl,prio,type,domain_id,name,auth) values ('%s',%d,%d,'%s',%d,'%s',%d)"); declare( suffix, "insert-record-order-query-auth","", "insert into records (content,ttl,prio,type,domain_id,name,ordername,auth) values ('%s',%d,%d,'%s',%d,'%s','%s','%d')"); declare( suffix, "insert-ent-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,name) values (null,'%d','%s')"); declare( suffix, "insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,auth) values (null,'%d','%s','1')"); declare( suffix, "insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (type,domain_id,name,ordername,auth) values (null,'%d','%s','%s','1')"); declare( suffix, "update-serial-query", "", "update domains set notified_serial=%d where id=%d"); declare( suffix, "update-lastcheck-query", "", "update domains set last_check=%d where id=%d"); declare (suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d"); declare( suffix, "info-all-master-query", "", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); declare( suffix, "delete-zone-query", "", "delete from records where domain_id=%d"); declare( suffix, "delete-rrset-query", "", "delete from records where domain_id = %d and name='%s' and type='%s'"); declare(suffix, "dnssec", "Assume DNSSEC Schema is in place","no"); declare(suffix,"add-domain-key-query","", "insert into cryptokeys (domain_id, flags, active, content) select id, %d, %d, '%s' from domains where name='%s'"); declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='%s'"); declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='%s' and domainmetadata.kind='%s'"); declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'"); declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (domain_id, kind, content) select id, '%s', '%s' from domains where name='%s'"); declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=1 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=0 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"get-tsig-key-query","", "select algorithm, secret from tsigkeys where name='%s'"); declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'"); } //! Constructs a new gSQLite3Backend object. DNSBackend *make( const string & suffix = "" ) { return new gSQLite3Backend( d_mode, suffix ); } private: const string d_mode; }; //! Magic class that is activated when the dynamic library is loaded class gSQLite3Loader { public: //! This reports us to the main UeberBackend class gSQLite3Loader() { BackendMakers().report( new gSQLite3Factory( "gsqlite3" )); L</dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ ctags ctags-recursive distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/opendbxbackend/0000755000014601777760000000000012165464054020211 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/opendbxbackend/odbxbackend.cc0000644000014601777760000005442212136555572022777 0ustar00jenkinsnogroup00000000000000#include "odbxbackend.hh" inline string& strbind( const string& search, const string& replace, string& subject ) { size_t pos = 0; while( ( pos = subject.find( search, pos ) ) != string::npos ) { subject.replace( pos, search.size(), replace ); pos += replace.size(); } return subject; } inline string& toLowerByRef( string& str ) { for( unsigned int i = 0; i < str.length(); i++ ) { str[i] = dns_tolower( str[i] ); } return str; } OdbxBackend::OdbxBackend( const string& suffix ) { vector hosts; try { m_result = NULL; m_handle[READ] = NULL; m_handle[WRITE] = NULL; m_myname = "[OpendbxBackend]"; m_default_ttl = arg().asNum( "default-ttl" ); m_qlog = arg().mustDo( "query-logging" ); setArgPrefix( "opendbx" + suffix ); if( getArg( "host" ).size() > 0 ) { L.log( m_myname + " WARNING: Using deprecated opendbx-host parameter", Logger::Warning ); stringtok( m_hosts[READ], getArg( "host" ), ", " ); m_hosts[WRITE] = m_hosts[READ]; } else { stringtok( m_hosts[READ], getArg( "host-read" ), ", " ); stringtok( m_hosts[WRITE], getArg( "host-write" ), ", " ); } if( !connectTo( m_hosts[READ], READ ) ) { throw( AhuException( "Fatal: Connecting to server for reading failed" ) ); } if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( AhuException( "Fatal: Connecting to server for writing failed" ) ); } } catch( std::exception& e ) { L.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(), Logger::Error ); throw( AhuException( "Fatal: STL exception" ) ); } } OdbxBackend::~OdbxBackend() { odbx_unbind( m_handle[WRITE] ); odbx_unbind( m_handle[READ] ); odbx_finish( m_handle[WRITE] ); odbx_finish( m_handle[READ] ); } bool OdbxBackend::getDomainInfo( const string& domain, DomainInfo& di ) { const char* tmp; try { DLOG( L.log( m_myname + " getDomainInfo()", Logger::Debug ) ); string stmt = getArg( "sql-zoneinfo" ); string& stmtref = strbind( ":name", escape( toLower( domain ), READ ), stmt ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } if( !getRecord( READ ) ) { return false; } do { di.id = 0; di.zone = ""; di.masters.clear(); di.last_check = 0; di.notified_serial = 0; di.kind = DomainInfo::Native; di.backend = this; di.serial = 0; if( ( tmp = odbx_field_value( m_result, 6 ) ) != NULL ) { SOAData sd; sd.serial = 0; fillSOAData( string( tmp, odbx_field_length( m_result, 6 ) ), sd ); if( sd.serial == 0 && ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) { sd.serial = strtol( tmp, NULL, 10 ); } di.serial = sd.serial; } if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) { di.last_check = strtol( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) { stringtok(di.masters, string( tmp, odbx_field_length( m_result, 3 ) ), ", \t"); } if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) { if( !strncmp( tmp, "SLAVE", 5 ) ) { di.kind = DomainInfo::Slave; } else if( !strncmp( tmp, "MASTER", 6 ) ) { di.kind = DomainInfo::Master; } } if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { di.zone = string( tmp, odbx_field_length( m_result, 1 ) ); } if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) { di.id = strtol( tmp, NULL, 10 ); } } while( getRecord( READ ) ); } catch( std::exception& e ) { L.log( m_myname + " getDomainInfo: Caught STL std::exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::getSOA( const string& domain, SOAData& sd, DNSPacket* p ) { const char* tmp; try { DLOG( L.log( m_myname + " getSOA()", Logger::Debug ) ); string stmt = getArg( "sql-lookupsoa" ); string& stmtref = strbind( ":name", escape( toLower( domain ), READ ), stmt ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } if( !getRecord( READ ) ) { return false; } do { sd.serial = 0; sd.ttl = m_default_ttl; if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) { fillSOAData( string( tmp, odbx_field_length( m_result, 3 ) ), sd ); } if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) { sd.ttl = strtoul( tmp, NULL, 10 ); } if( sd.serial == 0 && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { sd.serial = strtol( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) { sd.domain_id = strtol( tmp, NULL, 10 ); } if( sd.nameserver.empty() ) { sd.nameserver = arg()["default-soa-name"]; } if( sd.hostmaster.empty() ) { sd.hostmaster = "hostmaster." + domain; } sd.db = this; } while( getRecord( READ ) ); } catch( std::exception& e ) { L.log( m_myname + " getSOA: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::list( const string& target, int zoneid ) { try { DLOG( L.log( m_myname + " list()", Logger::Debug ) ); m_qname = ""; m_result = NULL; size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid ); if( len < 0 ) { L.log( m_myname + " list: Unable to convert zone id to string - format error", Logger::Error ); return false; } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " list: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); return false; } string stmt = getArg( "sql-list" ); string& stmtref = strbind( ":id", string( m_buffer, len ), stmt ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } } catch( std::exception& e ) { L.log( m_myname + " list: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } void OdbxBackend::lookup( const QType& qtype, const string& qname, DNSPacket* dnspkt, int zoneid ) { try { DLOG( L.log( m_myname + " lookup()", Logger::Debug ) ); string stmt; string& stmtref = stmt; m_result = NULL; m_qname = qname; if( zoneid < 0 ) { if( qtype.getCode() == QType::ANY ) { stmt = getArg( "sql-lookup" ); } else { stmt = getArg( "sql-lookuptype" ); stmtref = strbind( ":type", qtype.getName(), stmt ); } } else { if( qtype.getCode() == QType::ANY ) { stmt = getArg( "sql-lookupid" ); } else { stmt = getArg( "sql-lookuptypeid" ); stmtref = strbind( ":type", qtype.getName(), stmt ); } size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid ); if( len < 0 ) { L.log( m_myname + " lookup: Unable to convert zone id to string - format error", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " lookup: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } stmtref = strbind( ":id", string( m_buffer, len ), stmtref ); } string tmp = qname; stmtref = strbind( ":name", escape( toLowerByRef( tmp ), READ ), stmtref ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { throw( DBException( "Error: DB statement failed" ) ); } } catch( std::exception& e ) { L.log( m_myname + " lookup: Caught STL exception - " + e.what(), Logger::Error ); throw( DBException( "Error: STL exception" ) ); } } bool OdbxBackend::get( DNSResourceRecord& rr ) { const char* tmp; try { DLOG( L.log( m_myname + " get()", Logger::Debug ) ); if( getRecord( READ ) ) { rr.content = ""; rr.priority = 0; rr.domain_id = 0; rr.last_modified = 0; rr.ttl = m_default_ttl; rr.qname = m_qname; if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) { rr.domain_id = strtol( tmp, NULL, 10 ); } if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { rr.qname = string( tmp, odbx_field_length( m_result, 1 ) ); } if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) { rr.qtype = tmp; } if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) { rr.ttl = strtoul( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) { rr.priority = (uint16_t) strtoul( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) { rr.content = string( tmp, odbx_field_length( m_result, 5 ) ); } return true; } } catch( std::exception& e ) { L.log( m_myname + " get: Caught STL exception - " + e.what(), Logger::Error ); return false; } return false; } void OdbxBackend::setFresh( uint32_t domain_id ) { size_t len; try { DLOG( L.log( m_myname + " setFresh()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " setFresh: Master server is unreachable", Logger::Error ); throw( DBException( "Error: Server unreachable" ) ); } len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-update-lastcheck" ).c_str(), time( 0 ), domain_id ); if( len < 0 ) { L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - format error", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - insufficient buffer space", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } if( !execStmt( m_buffer, len, WRITE ) ) { throw( DBException( "Error: DB statement failed" ) ); } } catch ( std::exception& e ) { L.log( m_myname + " setFresh: Caught STL exception - " + e.what(), Logger::Error ); throw( DBException( "Error: STL exception" ) ); } } void OdbxBackend::setNotified( uint32_t domain_id, uint32_t serial ) { try { DLOG( L.log( m_myname + " setNotified()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " setFresh: Master server is unreachable", Logger::Error ); throw( DBException( "Error: Server unreachable" ) ); } size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-update-serial" ).c_str(), serial, domain_id ); if( len < 0 ) { L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - format error", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - insufficient buffer space", Logger::Error ); throw( DBException( "Error: Libc error" ) ); } if( !execStmt( m_buffer, len, WRITE ) ) { throw( DBException( "Error: DB statement failed" ) ); } } catch ( std::exception& e ) { L.log( m_myname + " setNotified: Caught STL exception - " + e.what(), Logger::Error ); throw( DBException( "Error: STL exception" ) ); } } bool OdbxBackend::isMaster( const string& domain, const string& ip ) { try { DLOG( L.log( m_myname + " isMaster()", Logger::Debug ) ); string stmt = getArg( "sql-master" ); string& stmtref = strbind( ":name", escape( toLower( domain ), READ ), stmt ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } if( !getRecord( READ ) ) { return false; } do { if( odbx_field_value( m_result, 0 ) != NULL ) { if( !strcmp( odbx_field_value( m_result, 0 ), ip.c_str() ) ) { while( getRecord( READ ) ); return true; } } } while( getRecord( READ ) ); } catch ( std::exception& e ) { L.log( m_myname + " isMaster: Caught STL exception - " + e.what(), Logger::Error ); return false; } return false; } void OdbxBackend::getUnfreshSlaveInfos( vector* unfresh ) { try { DLOG( L.log( m_myname + " getUnfreshSlaveInfos()", Logger::Debug ) ); if( unfresh == NULL ) { L.log( m_myname + " getUnfreshSlaveInfos: invalid parameter - NULL pointer", Logger::Error ); return; } getDomainList( getArg( "sql-infoslaves" ), unfresh, &checkSlave ); } catch ( std::exception& e ) { L.log( m_myname + " getUnfreshSlaveInfo: Caught STL exception - " + e.what(), Logger::Error ); } } void OdbxBackend::getUpdatedMasters( vector* updated ) { try { DLOG( L.log( m_myname + " getUpdatedMasters()", Logger::Debug ) ); if( updated == NULL ) { L.log( m_myname + " getUpdatedMasters: invalid parameter - NULL pointer", Logger::Error ); return; } getDomainList( getArg( "sql-infomasters" ), updated, &checkMaster ); } catch ( std::exception& e ) { L.log( m_myname + " getUpdatedMasters: Caught STL exception - " + e.what(), Logger::Error ); } } bool OdbxBackend::superMasterBackend( const string& ip, const string& domain, const vector& set, string* account, DNSBackend** ddb ) { try { DLOG( L.log( m_myname + " superMasterBackend()", Logger::Debug ) ); if( account != NULL && ddb != NULL ) { vector::const_iterator i; for( i = set.begin(); i != set.end(); i++ ) { string stmt = getArg( "sql-supermaster" ); string& stmtref = strbind( ":ip", escape( ip, READ ), stmt ); stmtref = strbind( ":ns", escape( i->content, READ ), stmtref ); if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } if( getRecord( READ ) ) { if( odbx_field_value( m_result, 0 ) != NULL ) { *account = string( odbx_field_value( m_result, 0 ), odbx_field_length( m_result, 0 ) ); } while( getRecord( READ ) ); *ddb=this; return true; } } } } catch ( std::exception& e ) { L.log( m_myname + " superMasterBackend: Caught STL exception - " + e.what(), Logger::Error ); return false; } return false; } bool OdbxBackend::createSlaveDomain( const string& ip, const string& domain, const string& account ) { try { DLOG( L.log( m_myname + " createSlaveDomain()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " createSlaveDomain: Master server is unreachable", Logger::Error ); return false; } string tmp = domain; size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-slave" ).c_str(), escape( toLowerByRef( tmp ), WRITE ).c_str(), escape( ip, WRITE ).c_str(), escape( account, WRITE ).c_str() ); if( len < 0 ) { L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - format error", Logger::Error ); return false; } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - insufficient buffer space", Logger::Error ); return false; } if( !execStmt( m_buffer, len, WRITE ) ) { return false; } } catch ( std::exception& e ) { L.log( m_myname + " createSlaveDomain: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::feedRecord( const DNSResourceRecord& rr ) { try { DLOG( L.log( m_myname + " feedRecord()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " feedRecord: Master server is unreachable", Logger::Error ); return false; } string tmp = rr.qname; size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-record" ).c_str(), rr.domain_id, escape( toLowerByRef( tmp ), WRITE ).c_str(), rr.qtype.getName().c_str(), rr.ttl, rr.priority, escape( rr.content, WRITE ).c_str() ); if( len < 0 ) { L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - format error", Logger::Error ); return false; } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - insufficient buffer space", Logger::Error ); return false; } if( !execStmt( m_buffer, len, WRITE ) ) { return false; } } catch ( std::exception& e ) { L.log( m_myname + " feedRecord: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::startTransaction( const string& domain, int zoneid ) { try { DLOG( L.log( m_myname + " startTransaction()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " startTransaction: Master server is unreachable", Logger::Error ); return false; } string stmtref = getArg( "sql-transactbegin" ); if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; } size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid ); if( len < 0 ) { L.log( m_myname + " startTransaction: Unable to convert zone id to string - format error", Logger::Error ); return false; } if( len > sizeof( m_buffer ) - 1 ) { L.log( m_myname + " startTransaction: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); return false; } if(zoneid >= 0) { string stmt = getArg( "sql-zonedelete" ); stmtref = strbind( ":id", string( m_buffer, len ), stmt ); if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; } } } catch ( std::exception& e ) { L.log( m_myname + " startTransaction: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::commitTransaction() { try { DLOG( L.log( m_myname + " commitTransaction()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " commitTransaction: Master server is unreachable", Logger::Error ); return false; } const string& stmt = getArg( "sql-transactend" ); if( !execStmt( stmt.c_str(), stmt.size(), WRITE ) ) { return false; } } catch ( std::exception& e ) { L.log( m_myname + " commitTransaction: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } bool OdbxBackend::abortTransaction() { try { DLOG( L.log( m_myname + " abortTransaction()", Logger::Debug ) ); if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) { L.log( m_myname + " abortTransaction: Master server is unreachable", Logger::Error ); return false; } const string& stmt = getArg( "sql-transactabort" ); if( !execStmt( stmt.c_str(), stmt.size(), WRITE ) ) { return false; } } catch ( std::exception& e ) { L.log( m_myname + " abortTransaction: Caught STL exception - " + e.what(), Logger::Error ); return false; } return true; } pdns-3.3/modules/opendbxbackend/OBJECTLIBS0000644000014601777760000000001112136555572021550 0ustar00jenkinsnogroup00000000000000-lopendbxpdns-3.3/modules/opendbxbackend/odbxbackend.hh0000644000014601777760000002031412136555572023002 0ustar00jenkinsnogroup00000000000000/* * PowerDNS OpenDBX Backend * Copyright (C) 2005-2007 Norbert Sendetzky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef ODBXBACKEND_HH #define ODBXBACKEND_HH #define BUFLEN 512 using std::string; using std::vector; bool checkSlave( uint32_t last, uint32_t notified, SOAData* sd, DomainInfo* di ); bool checkMaster( uint32_t last, uint32_t notified, SOAData* sd, DomainInfo* di ); class OdbxBackend : public DNSBackend { enum QueryType { READ, WRITE }; string m_myname; string m_qname; int m_default_ttl; bool m_qlog; odbx_t* m_handle[2]; odbx_result_t* m_result; char m_escbuf[BUFLEN]; char m_buffer[2*BUFLEN]; vector m_hosts[2]; string escape( const string& str, QueryType type ); bool connectTo( const vector& host, QueryType type ); bool getDomainList( const string& query, vector* list, bool (*check_fcn)(uint32_t,uint32_t,SOAData*,DomainInfo*) ); bool execStmt( const char* stmt, unsigned long length, QueryType type ); bool getRecord( QueryType type ); public: OdbxBackend( const string& suffix="" ); ~OdbxBackend(); void lookup( const QType& qtype, const string& qdomain, DNSPacket* p = 0, int zoneid = -1 ); bool getSOA( const string& domain, SOAData& sd, DNSPacket* p ); bool list( const string& target, int domain_id ); bool get( DNSResourceRecord& rr ); bool startTransaction( const string& domain, int domain_id ); bool commitTransaction(); bool abortTransaction(); bool isMaster( const string& domain, const string& ip ); bool getDomainInfo( const string& domain, DomainInfo& di ); bool feedRecord( const DNSResourceRecord& rr ); bool createSlaveDomain( const string& ip, const string& domain, const string& account ); bool superMasterBackend( const string& ip, const string& domain, const vector& nsset, string* account, DNSBackend** ddb ); void getUpdatedMasters( vector* updated ); void getUnfreshSlaveInfos( vector* unfresh ); void setFresh( uint32_t domain_id ); void setNotified( uint32_t domain_id, uint32_t serial ); }; class OdbxFactory : public BackendFactory { public: OdbxFactory() : BackendFactory( "opendbx" ) {} void declareArguments( const string &suffix="" ) { declare( suffix, "backend", "OpenDBX backend","mysql" ); declare( suffix, "host-read", "Name or address of one or more DBMS server to read from","127.0.0.1" ); declare( suffix, "host-write", "Name or address of one or more DBMS server used for updates","127.0.0.1" ); declare( suffix, "port", "Port the DBMS server are listening to","" ); declare( suffix, "database", "Database name containing the DNS records","powerdns" ); declare( suffix, "username","User for connecting to the DBMS","powerdns"); declare( suffix, "password","Password for connecting to the DBMS",""); declare( suffix, "sql-list", "AXFR query", "SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id" ); declare( suffix, "sql-lookup", "Lookup query","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"name\"=':name'" ); declare( suffix, "sql-lookupid", "Lookup query with id","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id AND r.\"name\"=':name'" ); declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"name\"=':name' AND r.\"type\"=':type'" ); declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id AND r.\"name\"=':name' AND r.\"type\"=':type'" ); declare( suffix, "sql-lookupsoa","Lookup query for SOA record","SELECT d.\"id\", d.\"auto_serial\", r.\"ttl\", r.\"content\" FROM \"records\" r JOIN \"domains\" d ON r.\"domain_id\"=d.\"id\" WHERE r.\"name\"=':name' AND r.\"type\"='SOA' AND d.\"status\"='A'" ); declare( suffix, "sql-zonedelete","Delete all records for this zone","DELETE FROM \"records\" WHERE \"domain_id\"=:id" ); declare( suffix, "sql-zoneinfo","Get domain info","SELECT d.\"id\", d.\"name\", d.\"type\", d.\"master\", d.\"last_check\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"name\"=':name' AND d.\"status\"='A'" ); declare( suffix, "sql-transactbegin", "Start transaction", "BEGIN" ); declare( suffix, "sql-transactend", "Finish transaction", "COMMIT" ); declare( suffix, "sql-transactabort", "Abort transaction", "ROLLBACK" ); declare( suffix, "sql-insert-slave","Add slave domain", "INSERT INTO \"domains\" ( \"name\", \"type\", \"master\", \"account\" ) VALUES ( '%s', 'SLAVE', '%s', '%s' )" ); declare( suffix, "sql-insert-record","Feed record into table", "INSERT INTO \"records\" ( \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" ) VALUES ( %d, '%s', '%s', %d, %d, '%s' )" ); declare( suffix, "sql-update-serial", "Set zone to notified", "UPDATE \"domains\" SET \"notified_serial\"=%d WHERE \"id\"=%d" ); declare( suffix, "sql-update-lastcheck", "Set time of last check", "UPDATE \"domains\" SET \"last_check\"=%d WHERE \"id\"=%d" ); declare( suffix, "sql-master", "Get master record for zone", "SELECT d.\"master\" FROM \"domains\" d WHERE d.\"name\"=':name' AND d.\"status\"='A' AND d.\"type\"='SLAVE'" ); declare( suffix, "sql-supermaster","Get supermaster info", "SELECT s.\"account\" FROM \"supermasters\" s WHERE s.\"ip\"=':ip' AND s.\"nameserver\"=':ns'" ); declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.\"id\", d.\"name\", d.\"master\", d.\"last_check\", d.\"notified_serial\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"status\"='A' AND d.\"type\"='SLAVE'" ); declare( suffix, "sql-infomasters", "Get all updated masters", "SELECT d.\"id\", d.\"name\", d.\"master\", d.\"last_check\", d.\"notified_serial\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"status\"='A' AND d.\"type\"='MASTER'" ); declare( suffix, "host", "deprecated, use host-read and host-write instead","" ); } DNSBackend* make( const string &suffix="" ) { return new OdbxBackend( suffix ); } }; class OdbxLoader { OdbxFactory factory; public: OdbxLoader() { BackendMakers().report( &factory ); L.log( " [OpendbxBackend] This is the opendbx module version "VERSION" ("__DATE__", "__TIME__") reporting", Logger::Info ); } }; static OdbxLoader odbxloader; #endif /* ODBXBACKEND_HH */ pdns-3.3/modules/opendbxbackend/OBJECTFILES0000644000014601777760000000003412136555572021666 0ustar00jenkinsnogroup00000000000000odbxbackend.o odbxprivate.o pdns-3.3/modules/opendbxbackend/Makefile.in0000644000014601777760000004772612165464027022276 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/opendbxbackend DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libopendbxbackend_la_DEPENDENCIES = am_libopendbxbackend_la_OBJECTS = odbxbackend.lo odbxprivate.lo libopendbxbackend_la_OBJECTS = $(am_libopendbxbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libopendbxbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libopendbxbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libopendbxbackend_la_SOURCES) DIST_SOURCES = $(libopendbxbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libopendbxbackend.la libopendbxbackend_la_SOURCES = odbxbackend.hh odbxbackend.cc odbxprivate.cc libopendbxbackend_la_LDFLAGS = -module -avoid-version libopendbxbackend_la_LIBADD = -l@LIBOPENDBX@ all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/opendbxbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/opendbxbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libopendbxbackend.la: $(libopendbxbackend_la_OBJECTS) $(libopendbxbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libopendbxbackend_la_LINK) -rpath $(libdir) $(libopendbxbackend_la_OBJECTS) $(libopendbxbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbxbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbxprivate.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/opendbxbackend/README0000644000014601777760000000013512136555572021074 0ustar00jenkinsnogroup00000000000000For more information, see http://wiki.linuxnetworks.de/doc/index.php/PowerDNS_OpenDBX_Backendpdns-3.3/modules/opendbxbackend/odbxprivate.cc0000644000014601777760000001664412136555572023066 0ustar00jenkinsnogroup00000000000000#include "odbxbackend.hh" unsigned int odbx_host_index[2] = { 0, 0 }; bool OdbxBackend::connectTo( const vector& hosts, QueryType type ) { int err; unsigned int h, i; int idx = odbx_host_index[type]++ % hosts.size(); if( m_handle[type] != NULL ) { odbx_unbind( m_handle[type] ); odbx_finish( m_handle[type] ); m_handle[type] = NULL; } if( type == WRITE && getArg( "backend" ) == "sqlite" ) { L.log( m_myname + " Using same SQLite connection for reading and writeing to '" + hosts[odbx_host_index[READ]] + "'", Logger::Notice ); m_handle[WRITE] = m_handle[READ]; return true; } for( i = 0; i < hosts.size(); i++ ) { h = ( idx + i ) % hosts.size(); if( ( err = odbx_init( &(m_handle[type]), getArg( "backend" ).c_str(), hosts[h].c_str(), getArg( "port" ).c_str() ) ) == ODBX_ERR_SUCCESS ) { if( ( err = odbx_bind( m_handle[type], getArg( "database" ).c_str(), getArg( "username" ).c_str(), getArg( "password" ).c_str(), ODBX_BIND_SIMPLE ) ) == ODBX_ERR_SUCCESS ) { L.log( m_myname + " Database connection (" + (type ? "write" : "read") + ") to '" + hosts[h] + "' succeeded", Logger::Notice ); return true; } L.log( m_myname + " Unable to bind to database on host " + hosts[h] + " - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); continue; } L.log( m_myname + " Unable to connect to server on host " + hosts[h] + " - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); } m_handle[type] = NULL; return false; } bool OdbxBackend::execStmt( const char* stmt, unsigned long length, QueryType type ) { int err; DLOG( L.log( m_myname + " execStmt()", Logger::Debug ) ); if( m_qlog ) { L.log( m_myname + " Query: " + stmt, Logger::Info ); } if( ( err = odbx_query( m_handle[type], stmt, length ) ) < 0 ) { L.log( m_myname + " execStmt: Unable to execute query - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); if( err != -ODBX_ERR_PARAM && odbx_error_type( m_handle[type], err ) > 0 ) { return false; } // ODBX_ERR_PARAM workaround if( !connectTo( m_hosts[type], type ) ) { return false; } if( odbx_query( m_handle[type], stmt, length ) < 0 ) { return false; } } if( type == WRITE ) { while( getRecord( type ) ); } return true; } bool OdbxBackend::getRecord( QueryType type ) { int err = 3; DLOG( L.log( m_myname + " getRecord()", Logger::Debug ) ); do { if( err < 0 ) { L.log( m_myname + " getRecord: Unable to get next result - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); throw( AhuException( "Error: odbx_result() failed" ) ); } if( m_result != NULL ) { if( err == 3 ) { if( ( err = odbx_row_fetch( m_result ) ) < 0 ) { L.log( m_myname + " getRecord: Unable to get next row - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); throw( AhuException( "Error: odbx_row_fetch() failed" ) ); } if( err > 0 ) { #ifdef VERBOSELOG unsigned int i; string fields; for( i = 0; i < odbx_column_count( m_result ); i++ ) { fields += string( odbx_column_name( m_result, i ) ); if( odbx_field_value( m_result, i ) != NULL ) { fields += "=" + string( odbx_field_value( m_result, i ) ) + ", "; } else { fields += "=NULL, "; } } L.log( m_myname + " Values: " + fields, Logger::Error ); #endif return true; } } odbx_result_free( m_result ); m_result = NULL; } } while( ( err = odbx_result( m_handle[type], &m_result, NULL, 0 ) ) != 0 ); m_result = NULL; return false; } string OdbxBackend::escape( const string& str, QueryType type ) { int err; unsigned long len = sizeof( m_escbuf ); DLOG( L.log( m_myname + " escape(string)", Logger::Debug ) ); if( ( err = odbx_escape( m_handle[type], str.c_str(), str.size(), m_escbuf, &len ) ) < 0 ) { L.log( m_myname + " escape(string): Unable to escape string - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); if( err != -ODBX_ERR_PARAM && odbx_error_type( m_handle[type], err ) > 0 ) { throw( runtime_error( "odbx_escape() failed" ) ); } // ODBX_ERR_PARAM workaround if( !connectTo( m_hosts[type], type ) ) { throw( runtime_error( "odbx_escape() failed" ) ); } if( odbx_escape( m_handle[type], str.c_str(), str.size(), m_escbuf, &len ) < 0 ) { throw( runtime_error( "odbx_escape() failed" ) ); } } return string( m_escbuf, len ); } bool OdbxBackend::getDomainList( const string& stmt, vector* list, bool (*check_fcn)(uint32_t,uint32_t,SOAData*,DomainInfo*) ) { const char* tmp; uint32_t nlast, nserial; SOAData sd; DLOG( L.log( m_myname + " getDomainList()", Logger::Debug ) ); if( !execStmt( stmt.c_str(), stmt.size(), READ ) ) { return false; } if( !getRecord( READ ) ) { return false; } do { DomainInfo di; nlast = 0; nserial = 0; sd.serial = 0; sd.refresh = 0; if( ( tmp = odbx_field_value( m_result, 6 ) ) != NULL ) { fillSOAData( string( tmp, odbx_field_length( m_result, 6 ) ), sd ); } if( !sd.serial && ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) { sd.serial = strtol( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) { nserial = strtol( tmp, NULL, 10 ); } if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) { nlast = strtol( tmp, NULL, 10 ); } if( (*check_fcn)( nlast, nserial, &sd, &di ) ) { if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) { stringtok(di.masters, string( tmp, odbx_field_length( m_result, 2 )), ", \t" ); } if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { di.zone = string( tmp, odbx_field_length( m_result, 1 ) ); } if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) { di.id = strtol( tmp, NULL, 10 ); } di.last_check = nlast; di.notified_serial = nserial; di.serial = sd.serial; di.backend = this; list->push_back( di ); } } while( getRecord( READ ) ); return true; } bool checkSlave( uint32_t nlast, uint32_t nserial, SOAData* sd, DomainInfo* di ) { if( nlast + sd->refresh < (uint32_t) time( 0 ) ) { di->kind = DomainInfo::Slave; return true; } return false; } bool checkMaster( uint32_t nlast, uint32_t nserial, SOAData* sd, DomainInfo* di ) { if( nserial != sd->serial ) { di->kind = DomainInfo::Master; return true; } return false; } pdns-3.3/modules/opendbxbackend/Makefile.am0000644000014601777760000000042412136555572022251 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libopendbxbackend.la libopendbxbackend_la_SOURCES = odbxbackend.hh odbxbackend.cc odbxprivate.cc libopendbxbackend_la_LDFLAGS =-module -avoid-version libopendbxbackend_la_LIBADD =-l@LIBOPENDBX@ pdns-3.3/modules/mydnsbackend/0000755000014601777760000000000012165464054017704 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/mydnsbackend/OBJECTLIBS0000644000014601777760000000002212136555572021245 0ustar00jenkinsnogroup00000000000000-lmysqlclient -lz pdns-3.3/modules/mydnsbackend/OBJECTFILES0000644000014601777760000000002012136555572021354 0ustar00jenkinsnogroup00000000000000mydnsbackend.o pdns-3.3/modules/mydnsbackend/Makefile.in0000644000014601777760000004745012165464027021763 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/mydnsbackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libmydnsbackend_la_LIBADD = am_libmydnsbackend_la_OBJECTS = mydnsbackend.lo libmydnsbackend_la_OBJECTS = $(am_libmydnsbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libmydnsbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libmydnsbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libmydnsbackend_la_SOURCES) DIST_SOURCES = $(libmydnsbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @MYSQL_inc@ @THREADFLAGS@ lib_LTLIBRARIES = libmydnsbackend.la EXTRA_DIST = OBJECTFILES OBJECTLIBS libmydnsbackend_la_SOURCES = mydnsbackend.cc mydnsbackend.hh libmydnsbackend_la_LDFLAGS = -module -avoid-version @MYSQL_lib@ all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/mydnsbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/mydnsbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libmydnsbackend.la: $(libmydnsbackend_la_OBJECTS) $(libmydnsbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libmydnsbackend_la_LINK) -rpath $(libdir) $(libmydnsbackend_la_OBJECTS) $(libmydnsbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mydnsbackend.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/mydnsbackend/mydnsbackend.cc0000644000014601777760000002735612156332430022662 0ustar00jenkinsnogroup00000000000000/* * PowerDNS backend module for MyDNS style databases * Author: Jonathan Oddy (Hostway UK) * * The schema used by MyDNS isn't suitable for retrieving results with a single * query. This means that existing PowerDNS backends are unable to make use of * the schema without lame hackery (or awful performance.) This module does * the nasty lookup logic required to make use of the schema, and should be as * tolerant as MyDNS when it comes to things being fully qualified or not. * * A known "bug" is that AXFRs will fail if your rr table contains invalid * junk. I'm not sure this is really a bug, if you've decided to put free-form * text in your data for an A record you have bigger issues. * * I'd advise avoiding the MyDNS schema if at all possible as the query count * for even simple lookups is daft. It's quite trivial to craft a request * that'll require 128 database queries to answer with a servfail! * * If you do not know what mydns is: http://mydns.bboy.net/ */ #include #include #include #include #include #include "pdns/namespaces.hh" #include #include #include "mydnsbackend.hh" #include #include #include #include #include #include static string backendName="[MyDNSbackend]"; MyDNSBackend::MyDNSBackend(const string &suffix) { setArgPrefix("mydns"+suffix); try { d_db = new SMySQL(getArg("dbname"), getArg("host"), getArgAsNum("port"), getArg("socket"), getArg("user"), getArg("password")); } catch(SSqlException &e) { L<doQuery(query); } catch (SSqlException &e) { throw AhuException("Query failed: "+e.txtReason()); } } bool MyDNSBackend::list(const string &target, int zoneId) { string query; string sname; SSql::row_t rrow; d_db->setLog(::arg().mustDo("query-logging")); query = "select origin, minimum from "+d_soatable+" where id = "; query+=itoa(zoneId); if (!d_soawhere.empty()) query+= " and "+d_soawhere; this->Query(query); if(!d_db->getRow(rrow)) return false; // No such zone d_origin = rrow[0]; if (d_origin[d_origin.length()-1] == '.') d_origin.erase(d_origin.length()-1); d_minimum = atol(rrow[1].c_str()); while (d_db->getRow(rrow)) { L<Query(query); d_qname = ""; return true; } bool MyDNSBackend::getSOA(const string& name, SOAData& soadata, DNSPacket*) { string query; SSql::row_t rrow; d_db->setLog(::arg().mustDo("query-logging")); if (name.empty()) return false; query = "select id, mbox, serial, ns, refresh, retry, expire, minimum, ttl from "+d_soatable+" where origin = '"; if (name.find_first_of("'\\")!=string::npos) query+=d_db->escape(name); else query+=name; query+=".'"; if (! d_soawhere.empty()) query += " and "+d_soawhere; this->Query(query); if(!(d_db->getRow(rrow))) { return false; } soadata.domain_id = atol(rrow[0].c_str()); soadata.hostmaster = rrow[1]; soadata.serial = atol(rrow[2].c_str()); soadata.nameserver = rrow[3]; soadata.refresh = atol(rrow[4].c_str()); soadata.retry = atol(rrow[5].c_str()); soadata.expire = atol(rrow[6].c_str()); soadata.default_ttl = atol(rrow[7].c_str()); soadata.ttl = atol(rrow[8].c_str()); if (d_useminimalttl && soadata.ttl < soadata.default_ttl) { soadata.ttl = soadata.default_ttl; } soadata.db = this; while (d_db->getRow(rrow)) { L<setLog(::arg().mustDo("query-logging")); if (qname.empty()) return; // Escape the name, after this point we only want to use it in queries if (qname.find_first_of("'\\")!=string::npos) sname=d_db->escape(qname); else sname = qname; sname += "."; if (zoneId < 0) { // First off we need to work out what zone we're working with // MyDNS records aren't always fully qualified, so we need to work out the zone ID. size_t pos; string sdom; pos = 0; sdom = sname; while (!sdom.empty() && pos != string::npos) { query = "select id, origin, minimum from "+d_soatable+" where origin = '"+sdom+"'"; if (!d_soawhere.empty()) query += " and "+d_soawhere; this->Query(query); if(d_db->getRow(rrow)) { zoneIdStr=rrow[0]; d_origin = rrow[1]; if (d_origin[d_origin.length()-1] == '.') d_origin.erase(d_origin.length()-1); d_minimum = atol(rrow[2].c_str()); found = true; break; } pos = sname.find_first_of(".",pos+1); sdom = sname.substr(pos+1); } } else { query = "select origin, minimum from "+d_soatable+" where id = "; query+=zoneIdStr; if (!d_soawhere.empty()) query+= " and "+d_soawhere; this->Query(query); if(!d_db->getRow(rrow)) { throw AhuException("lookup() passed zoneId = "+zoneIdStr+" but no such zone!"); } found = true; d_origin = rrow[0]; if (d_origin[d_origin.length()-1] == '.') d_origin.erase(d_origin.length()-1); d_minimum = atol(rrow[1].c_str()); } if (found) { while (d_db->getRow(rrow)) { L<escape(host); query = "select type, data, aux, ttl, zone from "+d_rrtable+" where zone = "; query+= zoneIdStr; query += " and (name = '"+host+"' or name = '"+sname+"')"; if(qtype.getCode()!=255) { // ANY query+=" and type='"; query+=qtype.getName(); query+="'"; } if (!d_rrwhere.empty()) query += " and "+d_rrwhere; if (qtype.getCode() == 255) { query += " union select 'SOA' as type, origin as data, '0' as aux, ttl, id as zone from "+d_soatable+" where id= " + zoneIdStr + " and origin = '"+qname+".'"; if (!d_soawhere.empty()) query += " and " + d_soawhere; } query += " order by type,aux,data"; this->Query(query); d_qname = qname; } } bool MyDNSBackend::get(DNSResourceRecord &rr) { if (d_origin.empty()) { // This happens if lookup() couldn't find the zone return false; } SSql::row_t rrow; if(!d_db->getRow(rrow)) { return false; } rr.qtype=rrow[0]; rr.content = rrow[1]; if(!d_qname.empty()) { // use this to distinguish between select with 'name' field (list()) and one without rr.qname=d_qname; } else { rr.qname=rrow[5]; if (rr.qname[rr.qname.length()-1] == '.') { rr.qname.erase(rr.qname.length()-1); // Fully qualified, nuke the last . } else { if (!rr.qname.empty()) rr.qname += "."; rr.qname += d_origin; // Not fully qualified } } if (rr.qtype.getCode() == QType::NS || rr.qtype.getCode()==QType::MX || rr.qtype.getCode() == QType::CNAME || rr.qtype.getCode() == QType::PTR) { if (rr.content[rr.content.length()-1] == '.') { rr.content.erase(rr.content.length()-1); // Fully qualified, nuke the last . } else { if (!rr.content.empty()) rr.content += "."; rr.content += d_origin; } } rr.priority = atol(rrow[2].c_str()); rr.ttl = atol(rrow[3].c_str()); if (d_useminimalttl && rr.ttl < d_minimum) rr.ttl = d_minimum; rr.domain_id=atol(rrow[4].c_str()); rr.last_modified=0; return true; } class MyDNSFactory : public BackendFactory { public: MyDNSFactory() : BackendFactory("mydns") {} void declareArguments(const string &suffix = "") { declare(suffix,"dbname","Pdns backend database name to connect to","mydns"); declare(suffix,"user","Pdns backend user to connect as","powerdns"); declare(suffix,"host","Pdns backend host to connect to",""); declare(suffix,"port","Pdns backend host to connect to",""); declare(suffix,"password","Pdns backend password to connect with",""); declare(suffix,"socket","Pdns backend socket to connect to",""); declare(suffix,"rr-table","Name of RR table to use","rr"); declare(suffix,"soa-table","Name of SOA table to use","soa"); declare(suffix,"soa-where","Additional WHERE clause for SOA","1 = 1"); declare(suffix,"rr-where","Additional WHERE clause for RR","1 = 1"); declare(suffix,"soa-active","Use the active column in the SOA table","yes"); declare(suffix,"rr-active","Use the active column in the RR table","yes"); declare(suffix,"use-minimal-ttl","Setting this to 'yes' will make the backend behave like MyDNS on the TTL values. Setting it to 'no' will make it ignore the minimal-ttl of the zone.","yes"); } MyDNSBackend *make(const string &suffix = "") { return new MyDNSBackend(suffix); } }; class MyDNSLoader { public: MyDNSLoader() { BackendMakers().report(new MyDNSFactory()); L< #include #include "pdns/namespaces.hh" #include class MyDNSBackend : public DNSBackend { public: MyDNSBackend(const string &suffix=""); ~MyDNSBackend(); MyDNSBackend *parent; void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1); bool list(const string &target, int domain_id); bool get(DNSResourceRecord &r); bool getSOA(const string& name, SOAData& soadata, DNSPacket*); private: void Query(const string& query); SMySQL *d_db; string d_qname; string d_rrtable; string d_soatable; string d_soawhere; string d_rrwhere; string d_origin; bool d_useminimalttl; unsigned int d_minimum; }; #endif /* MYDNSBACKEND_HH */ pdns-3.3/modules/mydnsbackend/Makefile.am0000644000014601777760000000035112140444471021731 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@MYSQL_inc@ @THREADFLAGS@ lib_LTLIBRARIES = libmydnsbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libmydnsbackend_la_SOURCES=mydnsbackend.cc mydnsbackend.hh libmydnsbackend_la_LDFLAGS=-module -avoid-version @MYSQL_lib@ pdns-3.3/modules/gmysqlbackend/0000755000014601777760000000000012165464054020066 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/gmysqlbackend/gmysqlbackend.cc0000644000014601777760000002570612145153461023226 0ustar00jenkinsnogroup00000000000000// $Id$ #include #include #include "pdns/namespaces.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "gmysqlbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "smysql.hh" #include gMySQLBackend::gMySQLBackend(const string &mode, const string &suffix) : GSQLBackend(mode,suffix) { try { setDB(new SMySQL(getArg("dbname"), getArg("host"), getArgAsNum("port"), getArg("socket"), getArg("user"), getArg("password"), getArg("group"))); } catch(SSqlException &e) { L< '%s' and domain_id=%d and ordername is not null"); declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null order by 1 desc limit 1"); declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'"); declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'"); declare(suffix,"nullify-ordername-and-auth-query", "DNSSEC nullify ordername and auth query", "update records set ordername=NULL,auth=0 where name='%s' and type='%s' and domain_id='%d'"); declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'"); declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d"); declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d"); declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=%d"); declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); declare(suffix,"delete-zone-query","", "delete from records where domain_id=%d"); declare(suffix,"delete-rrset-query","","delete from records where domain_id=%d and name='%s' and type='%s'"); declare(suffix,"add-domain-key-query","", "insert into cryptokeys (domain_id, flags, active, content) select id, %d, %d, '%s' from domains where name='%s'"); declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='%s'"); declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='%s' and domainmetadata.kind='%s'"); declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'"); declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (domain_id, kind, content) select id, '%s', '%s' from domains where name='%s'"); declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=1 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=0 where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"); declare(suffix,"get-tsig-key-query","", "select algorithm, secret from tsigkeys where name='%s'"); declare(suffix,"get-all-domains-query", "Retrieve all domains", "select records.domain_id, records.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from records, domains where records.domain_id=domains.id and records.type='SOA'"); } DNSBackend *make(const string &suffix="") { return new gMySQLBackend(d_mode,suffix); } private: const string d_mode; }; //! Magic class that is activated when the dynamic library is loaded class gMySQLLoader { public: //! This reports us to the main UeberBackend class gMySQLLoader() { BackendMakers().report(new gMySQLFactory("gmysql")); L< #include #include "pdns/misc.hh" #include "pdns/logger.hh" #include "pdns/dns.hh" #include "pdns/namespaces.hh" #include "pdns/lock.hh" bool SMySQL::s_dolog; pthread_mutex_t SMySQL::s_myinitlock = PTHREAD_MUTEX_INITIALIZER; SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const string &msocket, const string &user, const string &password, const string &group) { { Lock l(&s_myinitlock); mysql_init(&d_db); #if MYSQL_VERSION_ID >= 50013 my_bool reconnect = 1; mysql_options(&d_db, MYSQL_OPT_RECONNECT, &reconnect); #endif #if MYSQL_VERSION_ID > 51000 unsigned int timeout = 10; mysql_options(&d_db, MYSQL_OPT_READ_TIMEOUT, &timeout); mysql_options(&d_db, MYSQL_OPT_WRITE_TIMEOUT, &timeout); #endif mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, group.c_str()); if (!mysql_real_connect(&d_db, host.empty() ? NULL : host.c_str(), user.empty() ? NULL : user.c_str(), password.empty() ? NULL : password.c_str(), database.empty() ? NULL : database.c_str(), port, msocket.empty() ? NULL : msocket.c_str(), CLIENT_MULTI_RESULTS)) { throw sPerrorException("Unable to connect to database"); } d_rres=0; } } void SMySQL::setLog(bool state) { s_dolog=state; } SMySQL::~SMySQL() { mysql_close(&d_db); } SSqlException SMySQL::sPerrorException(const string &reason) { return SSqlException(reason+string(": ")+mysql_error(&d_db)); } int SMySQL::doCommand(const string &query) { return doQuery(query); } int SMySQL::doQuery(const string &query) { if(d_rres) throw SSqlException("Attempt to start new MySQL query while old one still in progress"); if(s_dolog) L< #include #include "pdns/backends/gsql/gsqlbackend.hh" #include "pdns/namespaces.hh" /** The gMySQLBackend is a DNSBackend that can answer DNS related questions. It looks up data in MySQL */ class gMySQLBackend : public GSQLBackend { public: gMySQLBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails. private: }; pdns-3.3/modules/gmysqlbackend/OBJECTFILES0000644000014601777760000000003112136555572021540 0ustar00jenkinsnogroup00000000000000gmysqlbackend.o smysql.o pdns-3.3/modules/gmysqlbackend/Makefile.in0000644000014601777760000005000412165464027022132 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/gmysqlbackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in INSTALL ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libgmysqlbackend_la_LIBADD = am_libgmysqlbackend_la_OBJECTS = gmysqlbackend.lo smysql.lo libgmysqlbackend_la_OBJECTS = $(am_libgmysqlbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libgmysqlbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libgmysqlbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libgmysqlbackend_la_SOURCES) DIST_SOURCES = $(libgmysqlbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @MYSQL_inc@ @THREADFLAGS@ $(BOOST_CPPFLAGS) lib_LTLIBRARIES = libgmysqlbackend.la EXTRA_DIST = OBJECTFILES OBJECTLIBS libgmysqlbackend_la_SOURCES = gmysqlbackend.cc gmysqlbackend.hh \ smysql.hh smysql.cc libgmysqlbackend_la_LDFLAGS = -module -avoid-version $(MYSQL_lib) all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/gmysqlbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/gmysqlbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libgmysqlbackend.la: $(libgmysqlbackend_la_OBJECTS) $(libgmysqlbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libgmysqlbackend_la_LINK) -rpath $(libdir) $(libgmysqlbackend_la_OBJECTS) $(libgmysqlbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmysqlbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smysql.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # -Wl,-Bstatic -lpq++ -lpq -Wl,-Bdynamic -lssl -lcrypt -lcrypto # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/gmysqlbackend/INSTALL0000644000014601777760000000027412136555572021126 0ustar00jenkinsnogroup00000000000000Edit the Makefile so it can find the main PowerDNS sources. This is the first line of the Makefile. You may want to change other things so it can find your PostgreSQL and MySQL sources. pdns-3.3/modules/gmysqlbackend/Makefile.am0000644000014601777760000000053712140444471022121 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@MYSQL_inc@ @THREADFLAGS@ $(BOOST_CPPFLAGS) lib_LTLIBRARIES = libgmysqlbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libgmysqlbackend_la_SOURCES=gmysqlbackend.cc gmysqlbackend.hh \ smysql.hh smysql.cc libgmysqlbackend_la_LDFLAGS=-module -avoid-version $(MYSQL_lib) # -Wl,-Bstatic -lpq++ -lpq -Wl,-Bdynamic -lssl -lcrypt -lcrypto pdns-3.3/modules/gmysqlbackend/smysql.hh0000644000014601777760000000160012136555572021740 0ustar00jenkinsnogroup00000000000000/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE for more information. $Id$ */ #ifndef SMYSQL_HH #define SMYSQL_HH #include #include "pdns/backends/gsql/ssql.hh" #include "pdns/utility.hh" class SMySQL : public SSql { public: SMySQL(const string &database, const string &host="", uint16_t port=0, const string &msocket="",const string &user="", const string &password="", const string &group=""); ~SMySQL(); SSqlException sPerrorException(const string &reason); int doQuery(const string &query, result_t &result); int doQuery(const string &query); int doCommand(const string &query); bool getRow(row_t &row); string escape(const string &str); void setLog(bool state); private: MYSQL d_db; MYSQL_RES *d_rres; static bool s_dolog; static pthread_mutex_t s_myinitlock; }; #endif /* SSMYSQL_HH */ pdns-3.3/modules/tinydnsbackend/0000755000014601777760000000000012165464054020242 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/tinydnsbackend/tinydnsbackend.hh0000644000014601777760000000452712136555572023577 0ustar00jenkinsnogroup00000000000000#ifndef TINYDNSBACKEND_HH #define TINYDNSBACKEND_HH #include #include #include #include #include #include #include #include #include "cdb.hh" #include #include #include #include using namespace ::boost; using namespace ::boost::multi_index; struct TinyDomainInfo { uint32_t id; uint32_t notified_serial; string zone; bool operator<(const TinyDomainInfo& tdi) const { return zone < tdi.zone; } }; struct TDI_SerialModifier { TDI_SerialModifier (const int newSerial) : d_newSerial(newSerial) {} void operator()(TinyDomainInfo& tdi) { tdi.notified_serial = d_newSerial; } private: int d_newSerial; }; class TinyDNSBackend : public DNSBackend { public: // Methods for simple operation TinyDNSBackend(const string &suffix); void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1); bool list(const string &target, int domain_id); bool get(DNSResourceRecord &rr); void getAllDomains(vector *domains); //Master mode operation void getUpdatedMasters(vector* domains); void setNotified(uint32_t id, uint32_t serial); private: vector getLocations(); //TypeDefs struct tag_zone{}; struct tag_domainid{}; typedef multi_index_container< TinyDomainInfo, indexed_by< hashed_unique, member >, hashed_unique, member > > > TDI_t; typedef map TDI_suffix_t; typedef TDI_t::index::type TDIByZone_t; typedef TDI_t::index::type TDIById_t; //data member variables uint64_t d_taiepoch; QType d_qtype; CDB *d_cdbReader; DNSPacket *d_dnspacket; // used for location and edns-client support. bool d_isWildcardQuery; // Indicate if the query received was a wildcard query. bool d_isAxfr; // Indicate if we received a list() and not a lookup(). bool d_locations; bool d_ignorebogus; string d_suffix; // Statics static pthread_mutex_t s_domainInfoLock; static TDI_suffix_t s_domainInfo; static uint32_t s_lastId; // used to give a domain an id. }; #endif // TINYDNSBACKEND_HH pdns-3.3/modules/tinydnsbackend/OBJECTLIBS0000644000014601777760000000000612136555572021605 0ustar00jenkinsnogroup00000000000000-lcdb pdns-3.3/modules/tinydnsbackend/cdb.hh0000644000014601777760000000134212136555572021317 0ustar00jenkinsnogroup00000000000000#ifndef CDB_HH #define CDB_HH #include #include #include #include #include // This class is responsible for the reading of a CDB file. // The constructor opens the CDB file, the destructor closes it, so make sure you call that. class CDB { public: CDB(const string &cdbfile); ~CDB(); int searchKey(const string &key); bool searchSuffix(const string &key); void searchAll(); bool readNext(pair &value); vector findall(string &key); private: int d_fd; bool moveToNext(); struct cdb d_cdb; struct cdb_find d_cdbf; char *d_key; unsigned d_seqPtr; enum SearchType { SearchSuffix, SearchKey, SearchAll } d_searchType; }; #endif // CDB_HH pdns-3.3/modules/tinydnsbackend/OBJECTFILES0000644000014601777760000000002612136555572021720 0ustar00jenkinsnogroup00000000000000tinydnsbackend.o cdb.opdns-3.3/modules/tinydnsbackend/Makefile.in0000644000014601777760000004765712165464027022332 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/tinydnsbackend DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libtinydnsbackend_la_LIBADD = am_libtinydnsbackend_la_OBJECTS = cdb.lo tinydnsbackend.lo libtinydnsbackend_la_OBJECTS = $(am_libtinydnsbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libtinydnsbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libtinydnsbackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libtinydnsbackend_la_SOURCES) DIST_SOURCES = $(libtinydnsbackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @CDB_CFLAGS@ @THREADFLAGS@ lib_LTLIBRARIES = libtinydnsbackend.la EXTRA_DIST = OBJECTFILES OBJECTLIBS libtinydnsbackend_la_SOURCES = cdb.cc cdb.hh tinydnsbackend.cc tinydnsbackend.hh libtinydnsbackend_la_LDFLAGS = -module -avoid-version @CDB_LIBS@ all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/tinydnsbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/tinydnsbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtinydnsbackend.la: $(libtinydnsbackend_la_OBJECTS) $(libtinydnsbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libtinydnsbackend_la_LINK) -rpath $(libdir) $(libtinydnsbackend_la_OBJECTS) $(libtinydnsbackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tinydnsbackend.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/tinydnsbackend/cdb.cc0000644000014601777760000000553512136555572021315 0ustar00jenkinsnogroup00000000000000#include "cdb.hh" #include #include #include #include CDB::CDB(const string &cdbfile) { d_fd = open(cdbfile.c_str(), O_RDONLY); if (d_fd < 0) { L< 0); } bool CDB::readNext(pair &value) { while (moveToNext()) { unsigned int pos; unsigned int len; pos = cdb_keypos(&d_cdb); len = cdb_keylen(&d_cdb); char *key = (char *)malloc(len); cdb_read(&d_cdb, key, len, pos); if (d_searchType == SearchSuffix) { char *p = strstr(key, d_key); if (p == NULL) { free(key); continue; } } string skey(key, len); free(key); pos = cdb_datapos(&d_cdb); len = cdb_datalen(&d_cdb); char *val = (char *)malloc(len); cdb_read(&d_cdb, val, len, pos); string sval(val, len); free(val); value = make_pair(skey, sval); return true; } // We're done searching, so we can clean up d_key if (d_searchType != SearchAll) { free(d_key); } return false; } vector CDB::findall(string &key) { vector ret; struct cdb_find cdbf; cdb_findinit(&cdbf, &d_cdb, key.c_str(), key.size()); int x=0; while(cdb_findnext(&cdbf) > 0) { x++; unsigned int vpos = cdb_datapos(&d_cdb); unsigned int vlen = cdb_datalen(&d_cdb); char *val = (char *)malloc(vlen); cdb_read(&d_cdb, val, vlen, vpos); string sval(val, vlen); ret.push_back(sval); free(val); } return ret; } pdns-3.3/modules/tinydnsbackend/Makefile.am0000644000014601777760000000037712140444471022277 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@CDB_CFLAGS@ @THREADFLAGS@ lib_LTLIBRARIES = libtinydnsbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libtinydnsbackend_la_SOURCES=cdb.cc cdb.hh tinydnsbackend.cc tinydnsbackend.hh libtinydnsbackend_la_LDFLAGS=-module -avoid-version @CDB_LIBS@pdns-3.3/modules/tinydnsbackend/tinydnsbackend.cc0000644000014601777760000002355212156332430023550 0ustar00jenkinsnogroup00000000000000#include "tinydnsbackend.hh" #include "pdns/lock.hh" #include #include #include #include #include #include #include static string backendname="[TinyDNSBackend] "; uint32_t TinyDNSBackend::s_lastId; pthread_mutex_t TinyDNSBackend::s_domainInfoLock=PTHREAD_MUTEX_INITIALIZER; TinyDNSBackend::TDI_suffix_t TinyDNSBackend::s_domainInfo; vector TinyDNSBackend::getLocations() { vector ret; if (! d_dnspacket) { return ret; } //TODO: We do not have IPv6 support. Netmask remote = d_dnspacket->getRealRemote(); if (remote.getBits() != 32) { return ret; } unsigned long addr = remote.getNetwork().sin4.sin_addr.s_addr; char key[6]; key[0] = '\000'; key[1] = '\045'; key[2] = (addr )&0xff; key[3] = (addr >> 8)&0xff; key[4] = (addr >> 16)&0xff; key[5] = (addr >> 24)&0xff; for (int i=4;i>=0;i--) { string searchkey(key, i+2); CDB *reader = new CDB(getArg("dbfile")); ret = reader->findall(searchkey); delete reader; //Biggest item wins, so when we find something, we can jump out. if (ret.size() > 0) { break; } } return ret; } TinyDNSBackend::TinyDNSBackend(const string &suffix) { setArgPrefix("tinydns"+suffix); d_suffix = suffix; d_locations = mustDo("locations"); d_ignorebogus = mustDo("ignore-bogus-records"); d_taiepoch = 4611686018427387904ULL + getArgAsNum("tai-adjust"); d_dnspacket = NULL; d_cdbReader = NULL; d_isAxfr = false; d_isWildcardQuery = false; } void TinyDNSBackend::getUpdatedMasters(vector* retDomains) { Lock l(&s_domainInfoLock); //TODO: We could actually lock less if we do it per suffix. if (! s_domainInfo.count(d_suffix)) { TDI_t tmp; s_domainInfo.insert( make_pair(d_suffix,tmp) ); } TDI_t *domains = &s_domainInfo[d_suffix]; vector allDomains; getAllDomains(&allDomains); if (domains->size() == 0 && !mustDo("notify-on-startup")) { for (vector::iterator di=allDomains.begin(); di!=allDomains.end(); ++di) { di->notified_serial = 0; } } for(vector::iterator di=allDomains.begin(); di!=allDomains.end(); ++di) { TDIByZone_t& zone_index = domains->get(); TDIByZone_t::iterator itByZone = zone_index.find(di->zone); if (itByZone == zone_index.end()) { s_lastId++; TinyDomainInfo tmp; tmp.zone = di->zone; tmp.id = s_lastId; tmp.notified_serial = di->serial; domains->insert(tmp); di->id = s_lastId; if (di->notified_serial > 0) { retDomains->push_back(*di); } } else { if (itByZone->notified_serial < di->serial) { di->id = itByZone->id; retDomains->push_back(*di); } } } } void TinyDNSBackend::setNotified(uint32_t id, uint32_t serial) { Lock l(&s_domainInfoLock); if (!s_domainInfo.count(d_suffix)) { throw new AhuException("Can't get list of domains to set the serial."); } TDI_t *domains = &s_domainInfo[d_suffix]; TDIById_t& domain_index = domains->get(); TDIById_t::iterator itById = domain_index.find(id); if (itById == domain_index.end()) { L<zone<<" to "< *domains) { d_isAxfr=true; d_dnspacket = NULL; d_cdbReader=new CDB(getArg("dbfile")); d_cdbReader->searchAll(); DNSResourceRecord rr; while (get(rr)) { if (rr.qtype.getCode() == QType::SOA) { SOAData sd; fillSOAData(rr.content, sd); DomainInfo di; di.id = -1; //TODO: Check if this is ok. di.backend=this; di.zone = rr.qname; di.serial = sd.serial; di.notified_serial = sd.serial; di.kind = DomainInfo::Master; di.last_check = time(0); domains->push_back(di); } } } bool TinyDNSBackend::list(const string &target, int domain_id) { d_isAxfr=true; string key = simpleCompress(target); d_cdbReader=new CDB(getArg("dbfile")); return d_cdbReader->searchSuffix(key); } void TinyDNSBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p, int zoneId) { d_isAxfr = false; string queryDomain = toLowerCanonic(qdomain); string key=simpleCompress(queryDomain); DLOG(L<searchKey(key); d_dnspacket = pkt_p; } bool TinyDNSBackend::get(DNSResourceRecord &rr) { pair record; while (d_cdbReader->readNext(record)) { string val = record.second; string key = record.first; //DLOG(L< bytes; const char *sval = val.c_str(); unsigned int len = val.size(); bytes.resize(len); copy(sval, sval+len, bytes.begin()); PacketReader pr(bytes); rr.qtype = QType(pr.get16BitInt()); if(d_isAxfr || d_qtype.getCode() == QType::ANY || rr.qtype == d_qtype) { char locwild = pr.get8BitInt(); if(locwild != '\075' && (locwild == '\076' || locwild == '\053')) { if (d_isAxfr && d_locations) { // We skip records with a location in AXFR, unless we disable locations. continue; } char recloc[2]; recloc[0] = pr.get8BitInt(); recloc[1] = pr.get8BitInt(); if (d_locations) { bool foundLocation = false; vector locations = getLocations(); while(locations.size() > 0) { string locId = locations.back(); locations.pop_back(); if (recloc[0] == locId[0] && recloc[1] == locId[1]) { foundLocation = true; break; } } if (!foundLocation) { continue; } } } if (d_isAxfr && (val[2] == '\052' || val[2] == '\053' )) { // Keys are not stored with wildcard character, with AXFR we need to add that. key.insert(0, 1, '\052'); key.insert(0, 1, '\001'); } rr.qname.clear(); simpleExpandTo(key, 0, rr.qname); rr.qname = stripDot(rr.qname); // strip the last dot, packethandler needs this. rr.domain_id=-1; // 11:13.21 <@ahu> IT IS ALWAYS AUTH --- well not really because we are just a backend :-) // We could actually do NSEC3-NARROW DNSSEC according to Habbie, if we do, we need to change something ehre. rr.auth = true; rr.ttl = pr.get32BitInt(); uint64_t timestamp = pr.get32BitInt(); timestamp <<= 32; timestamp += pr.get32BitInt(); if(timestamp) { uint64_t now = d_taiepoch + time(NULL); if (rr.ttl == 0) { if (timestamp < now) { continue; } rr.ttl = timestamp - now; } else if (now <= timestamp) { continue; } } try { DNSRecord dr; dr.d_class = 1; dr.d_type = rr.qtype.getCode(); dr.d_clen = val.size()-pr.d_pos; DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr); string content = drc->getZoneRepresentation(); // cerr<<"CONTENT: "<parts; stringtok(parts,content," "); rr.priority=atoi(parts[0].c_str()); rr.content=content.substr(parts[0].size()+1); } else { rr.content = content; } } catch (...) { if (d_ignorebogus) { L< * This software is licensed under the terms of the GPL, version 2. * * $Id$ */ #include #include "ippreftree.hh" IPPrefTree::IPPrefTree(): nodecount(0) { root = allocateNode(); nodecount++; } IPPrefTree::~IPPrefTree() { removeNode(root); } void IPPrefTree::add(const string &prefix, const short value) { uint32_t ip; int preflen; parsePrefix(prefix, ip, preflen); add(ip, preflen, value); } void IPPrefTree::add(const uint32_t ip, const int preflen, const short value) { addNode(root, ip, preflenToNetmask(preflen), value); } short IPPrefTree::lookup(const string &prefix) const { uint32_t ip; int preflen; parsePrefix(prefix, ip, preflen); return lookup(ip, preflen); } short IPPrefTree::lookup(const uint32_t ip, const int preflen) const { const node_t *node = findDeepestFilledNode(root, ip, preflenToNetmask(preflen)); return (node == NULL ? 0 : node->value); } void IPPrefTree::clear() { // Remove all children of the root node, but not the root node itself (reallocate it) removeNode(root); root = allocateNode(); nodecount++; } int IPPrefTree::getNodeCount() const { return nodecount; } int IPPrefTree::getMemoryUsage() const { return nodecount * sizeof(node_t); } // Private methods inline uint32_t IPPrefTree::preflenToNetmask (const int preflen) const { return ~( (1 << (32 - preflen)) - 1); } inline void IPPrefTree::parsePrefix(const string &prefix, uint32_t &ip, int &preflen) const { // Parse the prefix string (with format 131.155.230.139/25) std::istringstream is(prefix); ip = 0; preflen = 32; char c; for (int i = 0; i < 4; i++) { int octet = 0; is >> octet; ip = (ip << 8) | octet; is.get(c); if (c != '.' && c != '/') throw ParsePrefixException("Invalid format: expected '.' or '/'"); } if (is.good() && c == '/') { // Read the prefix length is >> preflen; } } void IPPrefTree::addNode(node_t *node, const uint32_t ip, const uint32_t mask, const short value) { if (mask == 0) { // We are at the correct depth in the tree node->value = value; } else { /* mask > 0 */ // We need to walk deeper into the tree, and extend it if needed int b = (ip >> 31); if (node->child[b] == NULL) { node->child[b] = allocateNode(); nodecount++; } // Recursively add addNode(node->child[b], ip << 1, mask << 1, value); } } node_t * IPPrefTree::allocateNode() { node_t *node = new node_t; // Initialize node->child[0] = node->child[1] = NULL; node->value = 0; return node; } const node_t * IPPrefTree::findDeepestFilledNode(const node_t *node, const uint32_t ip, const uint32_t mask) const { if (node == NULL) return NULL; if (mask == 0) { return (node->value == 0 ? NULL : node); } else { /* mask > 0 */ int b = (ip >> 31); const node_t *descendant = findDeepestFilledNode(node->child[b], ip << 1, mask << 1); if (descendant == NULL) { if (node->value != 0) // Children have no (more) explicit information, do we? return node; else return NULL; } else return descendant; } } void IPPrefTree::removeNode(node_t *node) { if (node == NULL) return; // Recursively remove and deallocate all descendants removeNode(node->child[0]); removeNode(node->child[1]); nodecount--; delete node; } pdns-3.3/modules/geobackend/ippreftree.hh0000644000014601777760000000312712136555572022021 0ustar00jenkinsnogroup00000000000000/* ippreftree.hh * Copyright (C) 2004 Mark Bergsma * This software is licensed under the terms of the GPL, version 2. * * $Id$ */ #include #include #include #include #include "pdns/namespaces.hh" // Use old style C structs for efficiency typedef struct node_t { node_t *child[2]; short value; } node_t; class IPPrefTree{ public: IPPrefTree(); ~IPPrefTree(); void add(const string &prefix, const short value); void add(const uint32_t ip, const int preflen, const short value); short lookup(const string &prefix) const; short lookup(const uint32_t ip, const int preflen) const; void clear(); int getNodeCount() const; int getMemoryUsage() const; private: node_t *root; // root of the tree int nodecount; // total number of nodes in the tree void addNode(node_t * node, const uint32_t ip, const uint32_t mask, const short value); node_t * allocateNode(); const node_t * findDeepestFilledNode(const node_t *root, const uint32_t ip, const uint32_t mask) const; void removeNode(node_t * node); inline uint32_t preflenToNetmask(const int preflen) const; inline void parsePrefix(const string &prefix, uint32_t &ip, int &preflen) const; }; class ParsePrefixException { public: ParsePrefixException() { reason = ""; }; ParsePrefixException(string r) { reason = r; }; string reason; }; pdns-3.3/modules/geobackend/geobackend.hh0000644000014601777760000000726412136555572021744 0ustar00jenkinsnogroup00000000000000/* geobackend.hh * Copyright (C) 2004 Mark Bergsma * This software is licensed under the terms of the GPL, version 2. * * $Id$ */ #include #include #include #include #include #include "ippreftree.hh" #include "pdns/namespaces.hh" class GeoRecord { public: GeoRecord(); string qname; string origin; string directorfile; map dirmap; }; class GeoBackend : public DNSBackend{ public: GeoBackend(const string &suffix); ~GeoBackend(); virtual void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1); virtual bool list(const string &target, int domain_id); virtual bool get(DNSResourceRecord &r); virtual bool getSOA(const string &name, SOAData &soadata, DNSPacket *p=0); virtual void reload(); virtual void rediscover(string *status = 0); private: // Static resources, shared by all instances static IPPrefTree *ipt; static vector nsRecords; static map georecords; static string soaMasterServer; static string soaHostmaster; static string zoneName; static uint32_t geoTTL; static uint32_t nsTTL; static time_t lastDiscoverTime; const static string logprefix; bool forceReload; // Locking static bool first; static int backendcount; static pthread_mutex_t startup_lock; static pthread_mutex_t ipt_lock; vector answers; vector::const_iterator i_answers; void answerGeoRecord(const QType &qtype, const string &qdomain, DNSPacket *p); void answerLocalhostRecord(const string &qdomain, DNSPacket *p); void queueNSRecords(const string &qname); void queueGeoRecords(); void fillGeoResourceRecord(const string &qname, const string &target, DNSResourceRecord *rr); const inline string resolveTarget(const GeoRecord &gr, short isocode) const; void loadZoneName(); void loadTTLValues(); void loadSOAValues(); void loadNSRecords(); void loadIPLocationMap(); void loadGeoRecords(); void loadDirectorMaps(const vector &newgrs); void loadDirectorMap(GeoRecord &gr); }; class GeoFactory : public BackendFactory{ public: GeoFactory() : BackendFactory("geo") {} void declareArguments(const string &suffix = "") { declare(suffix, "zone", "zonename to be served", ""); declare(suffix, "soa-values", "values of the SOA master nameserver and hostmaster fields, comma seperated", ""); declare(suffix, "ns-records", "targets of the NS records, comma separated.", ""); declare(suffix, "ttl", "TTL value for geo records", "3600"); declare(suffix, "ns-ttl", "TTL value for NS records", "86400"); declare(suffix, "ip-map-zonefile", "path to the rbldnsd format zonefile", "zz.countries.nerd.dk.rbldnsd"); declare(suffix, "maps", "list of paths to director maps or directories containing director map files", ""); } DNSBackend *make(const string &suffix) { return new GeoBackend(suffix); } }; class GeoLoader { public: GeoLoader() { BackendMakers().report(new GeoFactory); L << Logger::Info << "[GeoBackend] This is the geobackend (" __DATE__", "__TIME__" - $Revision: 1.1 $) reporting" << endl; } }; static GeoLoader geoloader; pdns-3.3/modules/geobackend/OBJECTFILES0000644000014601777760000000003212136555572020777 0ustar00jenkinsnogroup00000000000000geobackend.o ippreftree.o pdns-3.3/modules/geobackend/Makefile.in0000644000014601777760000004755412165464026021407 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = modules/geobackend DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libgeobackend_la_LIBADD = am_libgeobackend_la_OBJECTS = geobackend.lo ippreftree.lo libgeobackend_la_OBJECTS = $(am_libgeobackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libgeobackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libgeobackend_la_LDFLAGS) \ $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libgeobackend_la_SOURCES) DIST_SOURCES = $(libgeobackend_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ $(BOOST_CPPFLAGS) EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libgeobackend.la libgeobackend_la_SOURCES = geobackend.cc geobackend.hh ippreftree.cc ippreftree.hh libgeobackend_la_LDFLAGS = -module -avoid-version all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/geobackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/geobackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libgeobackend.la: $(libgeobackend_la_OBJECTS) $(libgeobackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libgeobackend_la_LINK) -rpath $(libdir) $(libgeobackend_la_OBJECTS) $(libgeobackend_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geobackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ippreftree.Plo@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/geobackend/geobackend.cc0000644000014601777760000004101612136555572021723 0ustar00jenkinsnogroup00000000000000/* geobackend.cc * Copyright (C) 2004 Mark Bergsma * This software is licensed under the terms of the GPL, version 2. * * $Id$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "geobackend.hh" using boost::trim_right; // Static members IPPrefTree * GeoBackend::ipt; vector GeoBackend::nsRecords; map GeoBackend::georecords; string GeoBackend::soaMasterServer; string GeoBackend::soaHostmaster; string GeoBackend::zoneName; uint32_t GeoBackend::geoTTL; uint32_t GeoBackend::nsTTL; time_t GeoBackend::lastDiscoverTime = 0; const string GeoBackend::logprefix = "[geobackend] "; bool GeoBackend::first = true; int GeoBackend::backendcount = 0; pthread_mutex_t GeoBackend::startup_lock; pthread_mutex_t GeoBackend::ipt_lock; // Class GeoRecord GeoRecord::GeoRecord() : origin(".") {} // Class GeoBackend, public methods GeoBackend::GeoBackend(const string &suffix) : forceReload(false) { setArgPrefix("geo" + suffix); // Make sure only one (the first) backend instance is initializing static things Lock lock(&startup_lock); backendcount++; if (!first) return; first = false; ipt = NULL; loadZoneName(); loadTTLValues(); loadSOAValues(); loadNSRecords(); reload(); } GeoBackend::~GeoBackend() { Lock lock(&startup_lock); backendcount--; if (backendcount == 0) { for (map::iterator i = georecords.begin(); i != georecords.end(); ++i) delete i->second; if (ipt != NULL) { delete ipt; ipt = NULL; } } } bool GeoBackend::getSOA(const string &name, SOAData &soadata, DNSPacket *p) { if (toLower(name) != toLower(zoneName) || soaMasterServer.empty() || soaHostmaster.empty()) return false; soadata.nameserver = soaMasterServer; soadata.hostmaster = soaHostmaster; soadata.domain_id = 1; // We serve only one zone soadata.db = this; // These values are bogus for backends like this one soadata.serial = 1; soadata.refresh = 86400; soadata.retry = 2*soadata.refresh; soadata.expire = 7*soadata.refresh; soadata.default_ttl = 3600; return true; } void GeoBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p, int zoneId) { answers.clear(); if ((qtype.getCode() == QType::NS || qtype.getCode() == QType::ANY) && toLower(qdomain) == toLower(zoneName)) queueNSRecords(qdomain); if (qtype.getCode() == QType::ANY || qtype.getCode() == QType::CNAME) answerGeoRecord(qtype, qdomain, pkt_p); if ((qtype.getCode() == QType::ANY || qtype.getCode() == QType::A) && toLower(qdomain) == "localhost." + toLower(zoneName)) answerLocalhostRecord(qdomain, pkt_p); if (!answers.empty()) i_answers = answers.begin(); } bool GeoBackend::list(const string &target, int domain_id) { answers.clear(); queueNSRecords(zoneName); answerLocalhostRecord("localhost."+zoneName, NULL); queueGeoRecords(); if (!answers.empty()) i_answers = answers.begin(); return true; } bool GeoBackend::get(DNSResourceRecord &r) { if (answers.empty()) return false; if (i_answers != answers.end()) { // FIXME DNSResourceRecord could do with a copy constructor DNSResourceRecord *ir = *i_answers; r.qtype = ir->qtype; r.qname = ir->qname; r.content = ir->content; r.priority = ir->priority; r.ttl = ir->ttl; r.domain_id = ir->domain_id; r.last_modified = ir->last_modified; r.auth = 1; delete ir; i_answers++; return true; } else { answers.clear(); return false; } } void GeoBackend::reload() { forceReload = true; rediscover(); forceReload = false; } void GeoBackend::rediscover(string *status) { // Store current time for use after discovery struct timeval nowtime; gettimeofday(&nowtime, NULL); loadIPLocationMap(); loadGeoRecords(); // Use time at start of discovery for checking whether files have changed // next time lastDiscoverTime = nowtime.tv_sec; } // Private methods void GeoBackend::answerGeoRecord(const QType &qtype, const string &qdomain, DNSPacket *p) { const string lqdomain = toLower(qdomain); if (georecords.count(lqdomain) == 0) return; GeoRecord *gr = georecords[lqdomain]; // Try to find the isocode of the country corresponding to the source ip // If that fails, use the default short isocode = 0; if (p != NULL && ipt != NULL) { try { isocode = ipt->lookup(p->getRemote()); } catch(ParsePrefixException &e) { // Ignore L << Logger::Notice << logprefix << "Unable to parse IP '" << p->getRemote() << " as IPv4 prefix" << endl; } } DNSResourceRecord *rr = new DNSResourceRecord; string target = resolveTarget(*gr, isocode); fillGeoResourceRecord(qdomain, target, rr); L << Logger::Debug << logprefix << "Serving " << qdomain << " " << rr->qtype.getName() << " " << target << " to " << p->getRemote() << " (" << isocode << ")" << endl; answers.push_back(rr); } void GeoBackend::answerLocalhostRecord(const string &qdomain, DNSPacket *p) { short isocode = 0; if (p != NULL) { try { isocode = ipt->lookup(p->getRemote()); } catch(ParsePrefixException &e) {} // Ignore } ostringstream target; target << "127.0." << ((isocode >> 8) & 0xff) << "." << (isocode & 0xff); DNSResourceRecord *rr = new DNSResourceRecord; rr->qtype = QType::A; rr->qname = qdomain; rr->content = target.str(); rr->priority = 0; rr->ttl = geoTTL; rr->domain_id = 1; rr->last_modified = 0; answers.push_back(rr); } void GeoBackend::queueNSRecords(const string &qname) { // nsRecords may be empty, e.g. when used in overlay mode for (vector::const_iterator i = nsRecords.begin(); i != nsRecords.end(); ++i) { DNSResourceRecord *rr = new DNSResourceRecord; rr->qtype = QType::NS; rr->qname = qname; rr->content = *i; rr->priority = 0; rr->ttl = nsTTL; rr->domain_id = 1; rr->last_modified = 0; answers.push_back(rr); } } void GeoBackend::queueGeoRecords() { for (map::const_iterator i = georecords.begin(); i != georecords.end(); ++i) { GeoRecord *gr = i->second; DNSResourceRecord *rr = new DNSResourceRecord; fillGeoResourceRecord(gr->qname, resolveTarget(*gr, 0), rr); answers.push_back(rr); } } void GeoBackend::fillGeoResourceRecord(const string &qdomain, const string &target, DNSResourceRecord *rr) { rr->qtype = QType::CNAME; rr->qname = qdomain; rr->content = target; rr->priority = 0; rr->ttl = geoTTL; rr->domain_id = 1; rr->last_modified = 0; } const string GeoBackend::resolveTarget(const GeoRecord &gr, short isocode) const { // If no mapping exists for this isocode, use the default if (gr.dirmap.count(isocode) == 0) isocode = 0; // Append $ORIGIN only if target does not end with a dot string target(gr.dirmap.find(isocode)->second); if (target[target.size()-1] != '.') target += gr.origin; else target.resize(target.size()-1); return target; } void GeoBackend::loadZoneName() { zoneName = getArg("zone"); if (zoneName.empty()) throw AhuException("zone parameter must be set"); } void GeoBackend::loadTTLValues() { geoTTL = getArgAsNum("ttl"); nsTTL = getArgAsNum("ns-ttl"); } void GeoBackend::loadSOAValues() { vector values; stringtok(values, getArg("soa-values"), " ,"); if (values.empty()) // No SOA values, probably no SOA record wanted because of overlay mode return; if (values.size() != 2) throw AhuException("Invalid number of soa-values specified in configuration"); soaMasterServer = values[0]; soaHostmaster = values[1]; } void GeoBackend::loadNSRecords() { stringtok(nsRecords, getArg("ns-records"), " ,"); } void GeoBackend::loadIPLocationMap() { string filename = getArg("ip-map-zonefile"); if (filename.empty()) throw AhuException("No IP map zonefile specified in configuration"); // Stat file to see if it has changed since last read struct stat stbuf; if (stat(filename.c_str(), &stbuf) != 0 || !S_ISREG(stbuf.st_mode)) { const string errormsg = "stat() failed, or " + filename + " is no regular file."; if (lastDiscoverTime == 0) // We have no older map, bail out throw AhuException(errormsg); else { // Log, but continue L << Logger::Error << logprefix << errormsg; return; } } if (stbuf.st_mtime < lastDiscoverTime && !forceReload) // File hasn't changed return; std::ifstream ifs(filename.c_str(), std::ios::in); if (!ifs) throw AhuException("Unable to open IP map zonefile for read: " + stringerror()); L << Logger::Info << logprefix << "Parsing IP map zonefile" << endl; IPPrefTree *new_ipt = new IPPrefTree; string line; int linenr = 0, entries = 0; while (getline(ifs, line)) { linenr++; trim_right(line); // Erase whitespace if (line[0] == '#') continue; // Skip comments vector words; stringtok(words, line, " :"); if (words.empty() || words[0] == "$SOA") continue; // Assume words[0] is a prefix. Feed it to the ip prefix tree try { // Parse country code nr if (words.size() < 2 || words[1].empty()) { L << Logger::Warning << logprefix << "Country code number is missing at line " << linenr << endl; continue; } struct in_addr addr; if (inet_aton(words[1].c_str(), &addr) < 0) { L << Logger::Warning << logprefix << "Invalid IP address '" << words[1] << " at line " << linenr << endl; continue; } short value = ntohl(addr.s_addr) & 0x7fff; new_ipt->add(words[0], value); entries++; } catch(ParsePrefixException &e) { L << Logger::Warning << logprefix << "Error while parsing prefix at line " << linenr << ": " << e.reason << endl; } } ifs.close(); L << Logger::Info << logprefix << "Finished parsing IP map zonefile: added " << entries << " prefixes, stored in " << new_ipt->getNodeCount() << " nodes using " << new_ipt->getMemoryUsage() << " bytes of memory" << endl; // Swap the new tree with the old tree IPPrefTree *oldipt = NULL; { Lock iptl(&ipt_lock); oldipt = ipt; ipt = new_ipt; } // Delete the old ip prefix tree if (oldipt != NULL) delete oldipt; } void GeoBackend::loadGeoRecords() { vector newgrs; vector maps; stringtok(maps, getArg("maps"), " ,"); for (vector::const_iterator i = maps.begin(); i != maps.end(); ++i) { struct stat stbuf; if (stat(i->c_str(), &stbuf) != 0) continue; if (S_ISREG(stbuf.st_mode)) { // Regular file GeoRecord *gr = new GeoRecord; gr->directorfile = *i; newgrs.push_back(gr); } else if (S_ISDIR(stbuf.st_mode)) { // Directory DIR *dir = opendir(i->c_str()); if (dir != NULL) { struct dirent *dent; while ((dent = readdir(dir)) != NULL) { string filename(*i); if (filename[filename.size()-1] != '/') filename += '/'; if (dent->d_name[0] == '.') continue; // skip filenames starting with a dot filename += dent->d_name; if (stat(filename.c_str(), &stbuf) != 0 || !S_ISREG(stbuf.st_mode)) continue; // skip everything but regular files GeoRecord *gr = new GeoRecord; gr->directorfile = filename; newgrs.push_back(gr); } closedir(dir); } } } loadDirectorMaps(newgrs); } void GeoBackend::loadDirectorMaps(const vector &newgrs) { map new_georecords; int mapcount = 0; for (vector::const_iterator i = newgrs.begin(); i != newgrs.end(); ++i) { GeoRecord *gr = *i; try { loadDirectorMap(*gr); if (new_georecords.count(gr->qname) == 0) { new_georecords[gr->qname] = gr; mapcount++; } else throw AhuException("duplicate georecord " + gr->qname + ", skipping"); } catch(AhuException &e) { L << Logger::Error << logprefix << "Error occured while reading director file " << gr->directorfile << ": " << e.reason << endl; delete gr; } } // Swap the new georecord map with the old one. georecords.swap(new_georecords); L << Logger::Notice << logprefix << "Finished parsing " << mapcount << " director map files, " << newgrs.size() - mapcount << " failures" << endl; // Cleanup old georecords for (map::iterator i = new_georecords.begin(); i != new_georecords.end(); ++i) delete i->second; } void GeoBackend::loadDirectorMap(GeoRecord &gr) { L << Logger::Info << logprefix << "Parsing director map " << gr.directorfile << endl; std::ifstream ifs(gr.directorfile.c_str(), std::ios::in); if (!ifs) throw AhuException("Error opening file."); string line; while(getline(ifs, line)) { trim_right(line); // Erase whitespace if (line.empty() || line[0] == '#') continue; // Skip empty lines and comments // Parse $RECORD if (line.substr(0, 7) == "$RECORD") { gr.qname = line.substr(8); trim_right(gr.qname); if (gr.qname[gr.qname.size()-1] != '.') gr.qname += '.' + zoneName; else { gr.qname.resize(gr.qname.size()-1); // Check whether zoneName is a prefix of this FQDN if (gr.qname.rfind(zoneName) == string::npos) throw AhuException("georecord " + gr.qname + " is out of zone " + zoneName); } continue; } // Parse $ORIGIN if (line.substr(0, 7) == "$ORIGIN") { gr.origin = line.substr(8); trim_right_if(gr.origin, boost::is_any_of(" \t.")); gr.origin.insert(0, "."); continue; } std::istringstream ii(line); short isocode; string target; ii >> isocode >> target; gr.dirmap[isocode] = target; } // Do some checks on the validness of this director map / georecord if (gr.qname.empty()) throw AhuException("$RECORD line empty or missing, georecord qname unknown"); if (gr.dirmap.count(0) == 0) throw AhuException("No default (0) director map entry"); } pdns-3.3/modules/geobackend/README0000644000014601777760000007242412136555572020221 0ustar00jenkinsnogroup00000000000000PowerDNS geobackend setup notes =============================== These are the steps I went through to set up geobackend for PowerDNS on FreeBSD -STABLE. By the time you read this maybe geobackend is part of the PowerDNS main CVS so perhaps not much of this will apply. In that case you should skip further down to the configuration part. Before I carry on I should probably point out that if you don't know how DNS works much, or if you have never installed PowerDNS ever before, then you probably won't understand any of this. In that case you should probably go and do some reading/practicing before trying to set this up for yourself. As a minimum of DNS knowledge I would say you need to understand: - Basically how DNS servers answer queries - What common DNS terms like "CNAME" "RR" and "SOA" mean - How to use diagnostic utilities such as "dig" to test your setup. So, how this should work on Linux or any general Unix system. This didn't work for me so I ended up having to do it another way, but anyhow.. 1. Download PowerDNS source from http://www.powerdns.com/downloads/index.php - you want the GPL sources. 2. Edit configure.in in the main directory so that where it has the list of backends at the bottom, you add: modules/geobackend/Makefile 3. $ cd modules and get the geobackend: $ cvs -d :pserver:anon@cvs.blitzed.org:/data/cvs login (press at password prompt) $ cvs -d :pserver:anon@cvs.blitzed.org:/data/cvs co -d geobackend geo-dns $ cd .. to return to top of build directory. 4. Regenerate the autotools with: $ aclocal $ autoheader $ automake --add-missing --copy --foreign $ autoconf 5. Do a ./configure with the flags you normally would use, but also --with-dynmodules="geo" 6. Install PowerDNS as normal for how you would normally use it. This did not work for me on FreeBSD: no matter what combination of autoconf, automake, libtool was installed I would always get one error or another at the stage where I was running those commands. So, after a few hours of messing around I decided to just compile the geobackend outside of the PowerDNS source tree. Probably if/when geobackend is made part of PowerDNS, this will "just work", but in the meantime here's what I did: 1. Install PowerDNS from the port /usr/ports/dns/powerdns as normal. Do not do a "make clean" yet though! Make sure your PowerDNS works as you'd expect without any of this geobackend stuff before going further. 2. Somewhere else, get the source of our geobackend as above in step 3. 3. Compile geobackend: $ c++ -I/usr/ports/dns/powerdns/work/pdns-2.9.15 -O2 -Wall -c geobackend.cc $ c++ -I/usr/ports/dns/powerdns/work/pdns-2.9.15 -O2 -Wall -c ippreftree.cc $ c++ ippreftree.o geobackend.o -Wl,-soname -Wl,libgeobackend.so.0 -shared -o libgeobackend.so All of those should compile and link without error. 4. Now you need to copy that shared library to the system library directory, as root: # cp libgeobackend.so /usr/local/lib/ Now whichever way you managed to get libgeobackend.so compiled, you are now ready to configure PowerDNS. This is what Blitzed's configuration looks like right now (but this is very much an experiment so things are bound to get out of date quickly). By the way, I could not find a SysV-style startup script installed by the FreeBSD port so I had to copy one from debian and put it in /usr/local/etc/rc.d/pdns.sh. You can get that file here: http://nubian.blitzed.org/pdns.sh And another thing is that the FreeBSD port doesn't add any new users for PowerDNS's use. You probably don't want to run it as root even without our code in it! So be sure to add some sensible user and group like "pdns". PowerDNS Configuration ====================== Here is the relevant parts of my /usr/local/etc/pdns.conf file as running on FreeBSD -STABLE: # ------------------------------------------------------------------------- # To make it run as user@group pdns:pdns instead of root:root setgid=pdns setuid=pdns # These totally disable query+packet caching for all zones. This is necessary # because otherwise when the exact same question is asked twice in a short # period of time (by default, 10 seconds), the same response will be given # without any backends getting involved. # # This is bad for geobackend because obviously every question can potentially # require a new answer based only on the IP of the user's nameserver. Now, it # should be noted that if you have other zones in PowerDNS then they will have # their query cache disabled as well. That's not ideal, so you probably want # to run a separate instance of PowerDNS just for geobackend. Maybe one day # there will be config options to set per-zone query caching time or something. query-cache-ttl=0 cache-ttl=0 # Log a lot of stuff. Logging is slow. We will disable this when we are happy # things are working. :) loglevel=7 # But these logs are not interesting at the moment log-dns-details=no # This disables wildcards which is more efficient. geobackend doesn't use # them, so if none of your backends need them, set this, otherwise comment it # out. wildcards=no # The geobackend launch=geo # The zone that your geo-balanced RR is inside of. The whole zone has to be # delegated to the PowerDNS backend, so you will generally want to make up some # subzone of your main zone. We chose "geo.blitzed.org". # geo-zone=geo.blitzed.org # The only parts of the SOA for "geo.blitzed.org" that apply here are the # master server name and the contact address. geo-soa-values=ns0.blitzed.org,hostmaster@blitzed.org # List of NS records of the PowerDNS servers that are authoritative for your # GLB zone. geo-ns-records=ns0.blitzed.org,ns1.blitzed.org # The TTL of the CNAME records that geobackend will return. Since the same # resolver will always get the same CNAME (apart from if the director-map # changes) it is safe to return a reasonable TTL, so if you leave this # commented then a sane default will be chosen. #geo-ttl=3600 # The TTL of the NS records that will be returned. Leave this commented if you # don't understand. #geo-ns-ttl=86400 # This is the real guts of the data that drives this backend. This is a DNS # zone file for RBLDNSD, a nameserver specialised for running large DNS zones # typical of DNSBLs and such. We choose it for our data because it is easier # to parse than the BIND-format one. # # Anyway, it comes from http://countries.nerd.dk/more.html - there are details # there for how to rsync your own copy. You'll want to do that regularly, # every couple of days maybe. We believe the nerd.dk guys take the netblock # info from Regional Internet Registries (RIRs) like RIPE, ARIN, APNIC. From # that they build a big zonefile of IP/prefixlen -> ISO-country-code mappings. geo-ip-map-zonefile=/usr/local/etc/zz.countries.nerd.dk.rbldnsd # And finally this last directive tells the geobackend where to find the map # files that say a) which RR to answer for, and b) what actual resource record # to return for each ISO country code. The setting here is a comma-separated # list of paths, each of which may either be a single map file or a directory # that will contain map files. If you are only ever going to serve one RR then # a single file is probably better, but if you're going to serve many then a # directory would probably be better. The rest of this documentation will # assume you chose a directory. geo-maps=/usr/local/etc/geo-maps # ------------------------------------------------------------------------- Map configuration ================= Above you defined a directory which should contain one file for each RR you are going to serve. This section describes the format for those files. There is a perl script in the geo-dns module (http://cvs.blitzed.org/geo-dns/iso2region.pl) which will print out a useful template for starting with. There are just two lines you MUST add for your own setup. The one that Blitzed is using is here: http://nubian.blitzed.org/irc.geo.blitzed.org The first line you must add is the $RECORD line. This tells the geobackend which RR within the geo-zone the file is for, so for example the file above gives: $RECORD irc meaning it is for irc.geo.blitzed.org. The second line that must be present is the $ORIGIN line: $ORIGIN iso.blitzed.org. The rest of this file is a list of mappings of ISO country to RR, and the $ORIGIN line tells the geobackend how to qualify the RRs. Any relative RR with be qualified by adding a dot and then this $ORIGIN string onto it. So all the relative RRs that follow are actually in the "iso.blitzed.org." zone. If you want to refer to an RR outside the $ORIGIN, put a trailing dot. The final mandatory line is the 0 mapping: 0 pool.blitzed.org. This is the "default" mapping. It's possible that you will get a query from an IP that is not represented in the nerd.dk zone. Maybe it is a new allocation by a RIR, or maybe something unexpected happened like you got a query from IPv6 or from an RFC1918 address. Or, there could be some error elsewhere in the geobackend that makes it want to give up. In any of these cases it needs to return a CNAME to a useful default. The default chosen for blitzed is "pool.blitzed.org." (note the trailing dot puts it outside the $ORIGIN!). At the moment, pool.blitzed.org is a round-robin of A records of all our connected servers, but the best way to handle it is under debate. Since it is in one of our regular zone files we can change it later how we want. The entire rest of the file is optional, and takes the format of an ISO country code (number) and an RR to map it to. iso2region.pl will have helpfully added comments with the country name so you can see what is what: # Belgium 56 eu Lines starting with # are comments. That's mainly so you can tell what the ISO code corresponds to, and maybe later when you are tweaking where all these countries will go to you can add some documentation for why you did it. The "56" is the ISO country code (see http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html) for Belgium. The "eu" tells the geobackend that if a query for irc.geo.blitzed.org should come in from someone in Belgium, then it should respond with a CNAME for "eu.iso.blitzed.org". That's it. That is the RR that gets sent back. Every other line in this file is the same, just code->RR maps. At this point you might be wondering when the user gets the actual IP address sent to them. The answer is that we have chosen to make our geobackend only respond with CNAMEs to other RRs that are assumed to be hosted elsewhere in DNS. Our main blitzed.org zone is hosted in bind servers like it has been for years. In that zone we have entries for every one of the RRs that appears on the right hand side in the director-map. A list of those RRs is as follows: an.iso.blitzed.org. af.iso.blitzed.org. as.iso.blitzed.org. eu.iso.blitzed.org. na.iso.blitzed.org. oc.iso.blitzed.org. sa.iso.blitzed.org. These correspond to the ISO names for the regions/continents (Antarctica, Africa, Asia, Europe, North America, Oceania, South America) and are represented in our DNS at the moment by either a list of A records of servers "near" there, or else a CNAME to a "nearby" region. For example we have no servers in Antarctica or Asia. We just CNAME those to "na.iso.blitzed.org." to send those users to North American servers instead. Doing it this way is just our first attempt, we are still experimenting and might decide to do it different. All you need to know is that the geobackend gives the CNAMEs you tell it to give, it's your business what those CNAMEs are and what they end up resolving to. DNS configuration ================= Time to configure the things that go into your existing DNS setup: 1. The geographically load-balanced zone needs to be delegated to your PowerDNS servers. For Blitzed we chose "geo.blitzed.org.", so: geo NS ns0.blitzed.org. geo NS ns1.blitzed.org. geo NS ns2.blitzed.org. 2. The lists of servers that correspond to each CNAME that your director-map can possibly come up with. The above configuration can only answer one of: pool.blitzed.org. an.iso.blitzed.org. af.iso.blitzed.org. as.iso.blitzed.org. eu.iso.blitzed.org. na.iso.blitzed.org. oc.iso.blitzed.org. sa.iso.blitzed.org. We have no servers in Antarctica so we just send that to North America: an.iso CNAME na.iso.blitzed.org. Other regions that actually have servers light look like: na.iso A 1.2.3.4 ; Some server in North America na.iso A 2.3.4.1 ; Some other server in North America 3. Eventually you probably will want to use a more friendly name than something like "irc.geo.blitzed.org.". At that point you could just do the equivalent of: irc CNAME irc.geo.blitzed.org. BEAR IN MIND THAT THERE MIGHT BE BUGS IN THIS BACKEND AND IF YOU DO THIS TO YOUR MAIN POOL AND IT STOPS RESPONDING, SENDS YOUR USERS TO THE WRONG SERVERS, OR EVEN TO THE WRONG NETWORKS, OR ANYTHING ELSE UNFORTUNATE HAPPENS AT ALL, THEN THAT'S JUST TOUGH LUCK AS THIS CODE COMES WITH NO WARRANTY, GUARANTEE OR ASSURANCE OF ANY KIND! Testing ======= OK! If you're still awake after all that, it is ready to test. By the way, at the moment some of the logging from the geobackend is a severity "debug" (facility "daemon" if using FreeBSD port). The default FreeBSD -STABLE install does not log daemon.debug to any file. If you don't add daemon.debug to your /etc/syslog.conf then you might not see some of the logs I shall talk about later. Most logging will be removed or made optional anyway as it slows things down. - Start PowerDNS # /usr/local/etc/rc.d/pdns.sh start - Check your logs! You should see something like this: Feb 26 16:07:45 nubian pdns[4661]: PowerDNS 2.9.15 (C) 2001-2004 PowerDNS.COM BV (Feb 9 2004, 23:40:35) starting up Feb 26 16:07:45 nubian pdns[4661]: PowerDNS comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2. Feb 26 16:07:45 nubian pdns[4661]: Set effective group id to 1023 Feb 26 16:07:45 nubian pdns[4661]: Set effective user id to 1023 Feb 26 16:07:45 nubian pdns[4661]: Creating backend connection for TCP Feb 26 16:07:45 nubian pdns[4661]: [geobackend] Parsing IP map zonefile Feb 26 16:07:47 nubian pdns[4661]: [geobackend] Finished parsing IP map zonefile: added 53072 prefixes, stored in 132525 nodes using 1590300 bytes of memory Feb 26 16:07:47 nubian pdns[4661]: [geobackend] Parsing director map /usr/local/etc/geo-maps/irc.geo.blitzed.org Feb 26 16:07:47 nubian pdns[4661]: [geobackend] Finished parsing 2 director map files, 0 failures Feb 26 16:07:47 nubian pdns[4661]: About to create 3 backend threads Feb 26 16:07:47 nubian pdns[4661]: Done launching threads, ready to distribute questions As long as there were no errors, the server is ready, geobackend is probably working. You should now test with a suitable diagnostic tool: $ dig irc.geo.blitzed.org. ; <<>> DiG 9.2.2 <<>> irc.geo.blitzed.org. ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59602 ;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 5, ADDITIONAL: 5 ;; QUESTION SECTION: ;irc.geo.blitzed.org. IN A ;; ANSWER SECTION: irc.geo.blitzed.org. 0 IN CNAME eu.iso.blitzed.org. eu.iso.blitzed.org. 1 IN A 195.92.253.3 eu.iso.blitzed.org. 1 IN A 213.193.225.252 eu.iso.blitzed.org. 1 IN A 62.80.124.155 eu.iso.blitzed.org. 1 IN A 80.196.158.72 eu.iso.blitzed.org. 1 IN A 195.22.74.199 ;; AUTHORITY SECTION: blitzed.org. 3600 IN NS sou.nameserver.net. blitzed.org. 3600 IN NS bos.nameserver.net. blitzed.org. 3600 IN NS iad.nameserver.net. blitzed.org. 3600 IN NS phl.nameserver.net. blitzed.org. 3600 IN NS sjc.nameserver.net. ;; ADDITIONAL SECTION: bos.nameserver.net. 43200 IN A 203.20.52.5 iad.nameserver.net. 43200 IN A 192.148.252.171 phl.nameserver.net. 7200 IN A 203.56.139.102 sjc.nameserver.net. 43200 IN A 205.158.174.201 sou.nameserver.net. 34825 IN A 194.196.163.7 ;; Query time: 389 msec ;; SERVER: 192.168.0.5#53(192.168.0.5) ;; WHEN: Tue Feb 10 03:10:14 2004 ;; MSG SIZE rcvd: 322 What does this show? Well first of all it tells us that we looked for the A record of "irc.geo.blitzed.org." (A records are the default RR for dig). What we actually got back was a CNAME to "eu.iso.blitzed.org." At that point the work of geobackend and our PowerDNS server as a whole is done. All it is designed to do is return a CNAME based on the location of the server doing the query. The server I did that from is in UK, so a response of "eu.iso.blitzed.org." is correct. The rest of the data comes from the normal BIND9 nameservers that are authoritative for the "blitzed.org." zone, in this case a list of A records corresponding to our EU servers. Finally the list of authoritative servers for "blitzed.org." is given, those same BIND9 boxes. Meanwhile in the syslog of nubian, we have: Feb 10 03:07:02 nubian pdns[32106]: [geobackend] Serving irc.geo.blitzed.org CNAME eu.iso.blitzed.org to 82.195.224.5 (756) Here you can see that 82.195.224.5 asked for "irc.geo.blitzed.org." and was served the mapping for ISO code 756: "eu.iso.blitzed.org.". This log notice will be useful for debugging and refining the director-map by hand, but later it will probably be removed or made optional. Ongoing maintenance =================== New IPs are regularly allocated, also there may end up being corrections to the nerd.dk zones, so you should arrange to rsync this file every so often. I'm guessing once a week would be adequate. You may not be satisfied with your first try at the director-map either, so from time to time you may make changes. You might also add more map files to your geo-maps directory. Anytime those changes happen you will need to tell the geobackend to reread them. At the moment the best way to do this is: # pdns_control rediscover Feb 26 16:10:57 nubian pdns[4661]: Rediscovery was requested Feb 26 16:10:57 nubian pdns[4661]: [geobackend] Parsing IP map zonefile Feb 26 16:10:58 nubian pdns[4661]: [geobackend] Finished parsing IP map zonefile: added 53072 prefixes, stored in 132525 nodes using 1590300 bytes of memory Feb 26 16:10:58 nubian pdns[4661]: [geobackend] Parsing director map /usr/local/etc/geo-maps/irc.geo.blitzed.org Feb 26 16:10:58 nubian pdns[4661]: [geobackend] Parsing director map /usr/local/etc/geo-maps/irc.strugglers.net Feb 26 16:10:58 nubian pdns[4661]: [geobackend] Finished parsing 2 director map files, 0 failures About recursive nameservers =========================== There is a small but potentially confusing gotcha in all this regarding recursive nameservers. Normally the authoritative nameservers for your regular domain will not allow recursion, that is, they will return data only for the domains they are authoritative for, returning pointers to nameservers for everything else. Here's an example of an authoritative server for blitzed.org that does not allow recursion: $ dig www.bbc.co.uk @sou.nameserver.net ; <<>> DiG 9.2.3 <<>> www.bbc.co.uk @sou.nameserver.net ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38059 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 7, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.bbc.co.uk. IN A ;; AUTHORITY SECTION: uk. 166680 IN NS NS1.NIC.uk. uk. 166680 IN NS NS2.NIC.uk. uk. 166680 IN NS NS3.NIC.uk. uk. 166680 IN NS NS4.NIC.uk. uk. 166680 IN NS NS5.NIC.uk. uk. 166680 IN NS NSA.NIC.uk. uk. 166680 IN NS NSB.NIC.uk. ;; Query time: 56 msec ;; SERVER: 194.196.163.7#53(sou.nameserver.net) ;; WHEN: Mon Feb 23 02:22:16 2004 ;; MSG SIZE rcvd: 161 Note in the flags part the "rd", which means "recursion desired". Since this server does not offer recursion to me, all it does is pass back the hostname of the nameservers that can further answer my question (in this case the list of nic.uk servers). My own resolver would then carry on asking questions, which is how it should be. Look what happens if I pick a server that does allow recursion: $ dig www.bbc.co.uk @bos.nameserver.net ; <<>> DiG 9.2.3 <<>> www.bbc.co.uk @bos.nameserver.net ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51313 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;www.bbc.co.uk. IN A ;; ANSWER SECTION: www.bbc.co.uk. 899 IN CNAME www.bbc.net.uk. www.bbc.net.uk. 300 IN A 212.58.240.121 ;; AUTHORITY SECTION: bbc.net.uk. 148544 IN NS ns0.thny.bbc.co.uk. bbc.net.uk. 148544 IN NS ns0.thdo.bbc.co.uk. ;; ADDITIONAL SECTION: ns0.thny.bbc.co.uk. 62144 IN A 38.160.150.20 ns0.thdo.bbc.co.uk. 62144 IN A 212.58.224.20 ;; Query time: 321 msec ;; SERVER: 203.20.52.5#53(bos.nameserver.net) ;; WHEN: Mon Feb 23 02:27:14 2004 ;; MSG SIZE rcvd: 164 Note the extra flag that appeared, "ra". This is "recursion available", and the server true to its word has gone and got the information for us. Normally this probably would not be noticeable. In most cases it does not matter if your own resolver does the work or if some other server does. This geo-dns project is based totally on the IP address of the server that asks the question, however, so for this application it is critical. As far as geo-dns is concerned, you cannot have any nameserver that allows recursion be authoritative for your main domain. If you do, then any query which hits this server will cause it to go out and get the answer itself. It will hand back answers that are based on its own location, instead of the location of the client. After wondering why too many people were getting answers based on the location of bos.nameserver.net instead of their own location, we finally worked out it had recursion enabled. This note is to save you the same hassle. It is generally recommended anyway that nameservers which are meant to be authoritative for domains do not have recursion enabled (http://www.isc.org/pubs/tn/isc-tn-2002-2.txt), but in this case it is an absolute requirement if you wish to get any sensible results. Check they are not allowing recursion by use of dig as above before setting up this backend. (The specific example of bos.nameserver.net has since been fixed (had recursion disabled) so you will not be able to repeat this example) Hosting multiple domains ======================== You may have noticed that all of the instructions so far have talked only of the single example domain, geo.blitzed.org, and may be wondering how to serve multiple zones. The answer is, you don't need to. The only thing you want to serve is individual RRs, and this geobackend does allow you to serve multiple of these just by adding files to the geo-maps directory. So, assume you now want to apply geo-dns to the RR irc.strugglers.net, You might add a new director map to your geo-maps directory named "irc.strugglers.net" (name doesn't matter, just an example). Inside this file you would have something like: $RECORD irc.strugglers.net $ORIGIN iso.strugglers.net. 0 bar.example.com. # List of code->RR maps follow, unqualified RRs are inside # iso.strugglers.net Once you now do a "pdns_control rediscover", your geobackend will be configured to answer for irc.strugglers.net.geo.blitzed.org. Now the people who run strugglers.net's dns just need to add a handy CNAME in their example.com zone file: irc CNAME irc.strugglers.net.geo.blitzed.org. You can check it will work before they add the CNAME: $ dig +norecurse irc.strugglers.net.geo.blitzed.org. @ns0.blitzed.org ; <<>> DiG 9.2.3 <<>> +norecurse irc.strugglers.net.geo.blitzed.org. @ns0.blitzed.org ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3592 ;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;irc.strugglers.net.geo.blitzed.org. IN A ;; ANSWER SECTION: irc.strugglers.net.geo.blitzed.org. 3600 IN CNAME eu.iso.blitzed.org. ;; Query time: 234 msec ;; SERVER: 82.195.234.5#53(ns0.blitzed.org) ;; WHEN: Thu Feb 26 15:45:36 2004 ;; MSG SIZE rcvd: 73 so that is how you can geo-dnsify RRs in multiple zones. Other questions, corrections, etc.? =================================== Please subscribe to our "geo" list from http://lists.blitzed.org/listinfo/geo and tell us about it. Tell us about how you use this stuff too, we're interested in people's experiences. All this is too much for you? ============================= We're still beta-testing this ourselves. As long as it doesn't place too much load on our servers we are open to the idea of doing the PowerDNS part of this for you as well. We're not ready to do that yet; it will require more development and specification of how you would provide your own director-maps etc.. If you are interested then please subscribe to the geo list and help us work out the details. FAQ === Q1. My IRC network is based mostly in one country (e.g. Australia, Brazil, ...) so all my users are from one ISO code and this isn't so useful to me, what can I do? A1. Well, one of the assumptions made during the design of this backend is that latency and geographical distance doesn't have a good relationship at small scales, even within North America or Europe it probably does not *always* follow that short distance == low latency. To improve things further I think you will need to do actual measurements. Or you could look at the amount of hops in the AS path from your client to each of your servers. Maybe you can come up with more ideas, if so we'd like to hear. However, if you are able to get more detailed geographic info from somewhere then you could still feed it into this backend, you'd just have to give up on the ISO country code model. I can really only see this working for very big countries like Australia and North America. Remember also that your servers probably are not 100% reliable! Say you have 2 US servers; one in California and one in New York. You find some way to split the US up into two halves with one half going to California and one to New York. Now suppose the New York server dies. Half your US users are still being directed there because that's the nearest one! Worse still, those users probably think that what they are connecting to is a *random* server, yet every single time they get will directed to a dead server. They may conclude your entire network is dead. You would be better advised IMHO to just have one US pool with both servers in. If either dies, the irc clients will make a few more attempts and get the other. It might add a few more ms to the RTT, but it's better than not being able to get on at all, and it's better than ending up on a non-US server. Maybe one day we'll do a high-availability backend too, though. :) Q2. Why is this tied to IRC? Can I use it for other things? A2. Yes! The code itself is not restricted in usefulness to only IRC, it's just that IRC is a good example of a situation where you have a service that is commonly split across many widely-separated servers, lots of widely spread clients, and a serious lack of money for "real" solutions. It wouldn't be any harder to use it for things like HTTP or many other protocols. Q3. I don't want to run PowerDNS, will you make a custom backend for BIND9? A3. Probably not unless you're willing to pay or induce us in other ways! PowerDNS is fun, you should try it, maybe you can make it work with only one IP address by use of a forward zone in BIND and putting PowerDNS on a strange port. Q4. I have some ideas for other metrics you could use instead of origin country, like server load or user count, or ... will you implement that too? A4: In another backend maybe. Tell us about your ideas, if you can make them sound interesting and useful then maybe we will. Q5. I serve lots of RRs out of my geobackend and with lots of nameservers I find it hard to keep my geo-maps in sync between them all. Any hints? A5. At the moment we use rsync like this: 07 04 * * 0 pdns rsync -t rsync://calzone.hestdesign.com/countries/zz.countries.nerd.dk.rbldnsd /usr/local/etc/powerdns/zz.countries.nerd.dk.rbldnsd && /usr/local/bin/pdns_control rediscover > /dev/null */15 * * * * pdns NR=$(rsync -rt --delete --stats rsync://rsync.blitzed.org/geo/ /usr/local/etc/powerdns/directormaps | awk '/Number of files transferred/ { print $5 }'); [ $NR != "0" ] && /usr/local/bin/pdns_control rediscover > /dev/null Which will take care of getting a new nerd.dk zone weekly and will sync the geo-maps every 15 minutes, doing a rediscover if files were transferred. Contact ======= Author: Andy Smith but please direct any questions to the geo list thanks! http://lists.blitzed.org/listinfo/geo pdns-3.3/modules/geobackend/Makefile.am0000644000014601777760000000036212136555572021365 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ $(BOOST_CPPFLAGS) EXTRA_DIST=OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libgeobackend.la libgeobackend_la_SOURCES=geobackend.cc geobackend.hh ippreftree.cc ippreftree.hh libgeobackend_la_LDFLAGS=-module -avoid-version pdns-3.3/modules/Makefile.am0000644000014601777760000000040312145360424017265 0ustar00jenkinsnogroup00000000000000SUBDIRS=@moduledirs@ DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend xdbbackend tinydnsbackend remotebackend randombackend pdns-3.3/modules/xdbbackend/0000755000014601777760000000000012165464054017327 5ustar00jenkinsnogroup00000000000000pdns-3.3/modules/xdbbackend/xgdbm.hh0000644000014601777760000000061612136555572020760 0ustar00jenkinsnogroup00000000000000#ifndef XGDBM_HH #define XGDBM_HH #include "xdb.hh" #include class XGDBMWrapper : public XDBWrapper { public: XGDBMWrapper(const string &filename, Mode mode=ReadOnly); ~XGDBMWrapper(); bool get(const string &key, string &value); void del(const string &key); void put(const string &key, const string &value); private: static GDBM_FILE s_db; static int s_usecount; }; #endif pdns-3.3/modules/xdbbackend/OBJECTLIBS0000644000014601777760000000000612136555572020672 0ustar00jenkinsnogroup00000000000000-ltdb pdns-3.3/modules/xdbbackend/OBJECTFILES0000644000014601777760000000002412136555572021003 0ustar00jenkinsnogroup00000000000000xdbbackend.o xtdb.o pdns-3.3/modules/xdbbackend/Makefile.in0000644000014601777760000006173212165464027021405 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = xdb-fill$(EXEEXT) subdir = modules/xdbbackend DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" LTLIBRARIES = $(lib_LTLIBRARIES) libxdbbackend_la_LIBADD = am_libxdbbackend_la_OBJECTS = libxdbbackend_la-xdbbackend.lo \ libxdbbackend_la-xtdb.lo libxdbbackend_la_OBJECTS = $(am_libxdbbackend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libxdbbackend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(libxdbbackend_la_CXXFLAGS) $(CXXFLAGS) \ $(libxdbbackend_la_LDFLAGS) $(LDFLAGS) -o $@ PROGRAMS = $(bin_PROGRAMS) am_xdb_fill_OBJECTS = xdb-fill.$(OBJEXT) xtdb.$(OBJEXT) xdb_fill_OBJECTS = $(am_xdb_fill_OBJECTS) xdb_fill_LDADD = $(LDADD) xdb_fill_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(xdb_fill_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libxdbbackend_la_SOURCES) $(xdb_fill_SOURCES) DIST_SOURCES = $(libxdbbackend_la_SOURCES) $(xdb_fill_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @THREADFLAGS@ EXTRA_DIST = OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libxdbbackend.la libxdbbackend_la_SOURCES = xdbbackend.cc xtdb.cc xtdb.hh xdb.hh xgdbm.hh libxdbbackend_la_LDFLAGS = -module -avoid-version -ltdb libxdbbackend_la_CXXFLAGS = $(AM_CXXFLAGS) xdb_fill_SOURCES = xdb-fill.cc xtdb.cc xtdb.hh xdb_fill_LDFLAGS = -ltdb all: all-am .SUFFIXES: .SUFFIXES: .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/xdbbackend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign modules/xdbbackend/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libxdbbackend.la: $(libxdbbackend_la_OBJECTS) $(libxdbbackend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libxdbbackend_la_LINK) -rpath $(libdir) $(libxdbbackend_la_OBJECTS) $(libxdbbackend_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list xdb-fill$(EXEEXT): $(xdb_fill_OBJECTS) $(xdb_fill_DEPENDENCIES) @rm -f xdb-fill$(EXEEXT) $(AM_V_CXXLD)$(xdb_fill_LINK) $(xdb_fill_OBJECTS) $(xdb_fill_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxdbbackend_la-xdbbackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxdbbackend_la-xtdb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdb-fill.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtdb.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< libxdbbackend_la-xdbbackend.lo: xdbbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxdbbackend_la_CXXFLAGS) $(CXXFLAGS) -MT libxdbbackend_la-xdbbackend.lo -MD -MP -MF $(DEPDIR)/libxdbbackend_la-xdbbackend.Tpo -c -o libxdbbackend_la-xdbbackend.lo `test -f 'xdbbackend.cc' || echo '$(srcdir)/'`xdbbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libxdbbackend_la-xdbbackend.Tpo $(DEPDIR)/libxdbbackend_la-xdbbackend.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='xdbbackend.cc' object='libxdbbackend_la-xdbbackend.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxdbbackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libxdbbackend_la-xdbbackend.lo `test -f 'xdbbackend.cc' || echo '$(srcdir)/'`xdbbackend.cc libxdbbackend_la-xtdb.lo: xtdb.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxdbbackend_la_CXXFLAGS) $(CXXFLAGS) -MT libxdbbackend_la-xtdb.lo -MD -MP -MF $(DEPDIR)/libxdbbackend_la-xtdb.Tpo -c -o libxdbbackend_la-xtdb.lo `test -f 'xtdb.cc' || echo '$(srcdir)/'`xtdb.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libxdbbackend_la-xtdb.Tpo $(DEPDIR)/libxdbbackend_la-xtdb.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='xtdb.cc' object='libxdbbackend_la-xtdb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxdbbackend_la_CXXFLAGS) $(CXXFLAGS) -c -o libxdbbackend_la-xtdb.lo `test -f 'xtdb.cc' || echo '$(srcdir)/'`xtdb.cc mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libLTLIBRARIES clean-libtool ctags \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-libLTLIBRARIES \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/modules/xdbbackend/xtdb.cc0000644000014601777760000000344312136555572020607 0ustar00jenkinsnogroup00000000000000#include "xtdb.hh" #include "pdns/lock.hh" #include #include #include #include #include #include #include #include "pdns/namespaces.hh" TDB_CONTEXT *XTDBWrapper::s_db; int XTDBWrapper::s_usecount; pthread_mutex_t XTDBWrapper::s_lock=PTHREAD_MUTEX_INITIALIZER; XTDBWrapper::XTDBWrapper(const string &fname) { Lock l(&s_lock); if(!s_db) { s_db = tdb_open(const_cast(fname.c_str()), 5213331, TDB_NOLOCK, O_RDWR | O_CREAT , 0600); if(!s_db) throw XDBException("Unable to open database: "+string(strerror(errno))); } s_usecount++; } XTDBWrapper::~XTDBWrapper() { if(!--s_usecount) { tdb_close(s_db); cerr<<"closed"<(key.c_str()),key.size()+1}; TDB_DATA vdatum; { //Lock l(&s_lock); vdatum=tdb_fetch(s_db,kdatum); } if(!vdatum.dptr) return false; value.assign(vdatum.dptr,vdatum.dsize); free(vdatum.dptr); return true; } void XTDBWrapper::put(const string &key, const string &value) { TDB_DATA kdatum={const_cast(key.c_str()),key.size()+1}; TDB_DATA vdatum={const_cast(value.c_str()),value.size()}; if(tdb_store(s_db, kdatum, vdatum,TDB_REPLACE)<0) throw XDBException("Error storing key: "+string(strerror(errno))); } void XTDBWrapper::del(const string &key) { } #ifdef TESTDRIVER main() { XDBWrapper *xdb=new XTDBWrapper("wuh"); xdb->put("ahu","toffe gast"); xdb->append("ahu",", echt waar!"); string tst; xdb->get("ahu",tst); cout<<"Database zegt over ahu: '"<append("ahu"," Toch niet!"); xdb->get("ahu",tst); cout<<"Database zegt over ahu: '"<get(qdomain, d_answer); // think about lowercasing here /* if(arg().mustDo("query-logging")) { if(ret) L< #include class XTDBWrapper : public XDBWrapper { public: XTDBWrapper(const string &filename); ~XTDBWrapper(); bool get(const string &key, string &value); void del(const string &key); void put(const string &key, const string &value); private: static TDB_CONTEXT *s_db; static int s_usecount; static pthread_mutex_t s_lock; }; pdns-3.3/modules/xdbbackend/xdb.hh0000644000014601777760000000106612136555572020434 0ustar00jenkinsnogroup00000000000000#ifndef XDB_HH #define XDB_HH #include using std::string; class XDBException { public: XDBException(const string &ex) : what(ex){} string what; }; class XDBWrapper { public: virtual ~XDBWrapper(){} virtual bool get(const string &key, string &value)=0; virtual void del(const string &key)=0; virtual void put(const string &key, const string &value)=0; virtual void append(const string &key, const string &value) { string newKey; get(key,newKey); put(key,newKey+value); } typedef enum {ReadOnly, ReadWrite} Mode; }; #endif pdns-3.3/modules/xdbbackend/Makefile.am0000644000014601777760000000054512136555572021373 0ustar00jenkinsnogroup00000000000000AM_CPPFLAGS=@THREADFLAGS@ EXTRA_DIST=OBJECTFILES OBJECTLIBS bin_PROGRAMS=xdb-fill lib_LTLIBRARIES = libxdbbackend.la libxdbbackend_la_SOURCES=xdbbackend.cc xtdb.cc xtdb.hh xdb.hh xgdbm.hh libxdbbackend_la_LDFLAGS=-module -avoid-version -ltdb libxdbbackend_la_CXXFLAGS = $(AM_CXXFLAGS) xdb_fill_SOURCES=xdb-fill.cc xtdb.cc xtdb.hh xdb_fill_LDFLAGS=-ltdb pdns-3.3/modules/xdbbackend/xdb-fill.cc0000644000014601777760000000530012136555572021341 0ustar00jenkinsnogroup00000000000000#include "pdns/utility.hh" #include "xgdbm.hh" #include "xtdb.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include #include #include string stringerror() { return strerror(errno); } string escape(const string &name) { string a; for(string::const_iterator i=name.begin();i!=name.end();++i) if(*i=='|' || *i=='\\'){ a+='\\'; a+=*i; } else a+=*i; return a; } XDBWrapper *db; maparecords; void doAList(int domain_id, const string &qname, const string &qtype, const string &content, int ttl) { if(qtype!="A") return; else arecords[qname]=content; } void doInsert(int domain_id, const string &qname, const string &qtype, const string &content, int ttl) { static string lastname; static string writestr; if(!lastname.empty() && lastname!=qname) { db->append(lastname,writestr); writestr=""; } string rcontent(content); if(qtype=="NS") { rcontent+="@"; map::const_iterator i=arecords.find(content); if(i!=arecords.end()) rcontent+=i->second; } ostringstream ostr; ostr<. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand `-c -o'. Remove `-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file `INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; esac ofile= cfile= eat= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we strip `-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use `[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pdns-3.3/config.guess0000755000014601777760000012763712165464024016127 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. timestamp='2009-12-30' # This file 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, 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. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: pdns-3.3/codedocs/0000755000014601777760000000000012165464054015355 5ustar00jenkinsnogroup00000000000000pdns-3.3/codedocs/doxygen.conf0000644000014601777760000014134312136555572017713 0ustar00jenkinsnogroup00000000000000# Doxyfile 1.4.0 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = ahudns # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ./ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, # Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, # Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, # Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, # Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # This tag can be used to specify the encoding used in the generated output. # The encoding is not always determined by the language that is chosen, # but also whether or not the output is meant for Windows or non-Windows users. # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES # forces the Windows encoding (this is the default for the Windows binary), # whereas setting the tag to NO uses a Unix-style encoding (the default for # all platforms other than Windows). USE_WINDOWS_ENCODING = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the progam writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ../ # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm FILE_PATTERNS = *.cc \ *.hh # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = ../ # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = *.hh # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that a graph may be further truncated if the graph's # image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH # and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), # the graph is not depth-constrained. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO pdns-3.3/codedocs/Makefile.in0000644000014601777760000002665112165464026017433 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = codedocs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign codedocs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign codedocs/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ distclean distclean-generic distclean-libtool distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am codedocs: . doxygen doxygen.conf # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/codedocs/Makefile0000644000014601777760000003127712165464050017023 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # codedocs/Makefile. Generated from Makefile.in by configure. # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. pkgdatadir = $(datadir)/pdns pkgincludedir = $(includedir)/pdns pkglibdir = $(libdir)/pdns pkglibexecdir = $(libexecdir)/pdns am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = x86_64-unknown-linux-gnu host_triplet = x86_64-unknown-linux-gnu subdir = codedocs DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run aclocal-1.11 AMTAR = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run tar AM_DEFAULT_VERBOSITY = 0 AR = ar AUTOCONF = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run autoconf AUTOHEADER = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run autoheader AUTOMAKE = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run automake-1.11 AWK = mawk BOOST_CPPFLAGS = BOOST_LDPATH = BOOST_PROGRAM_OPTIONS_LDFLAGS = BOOST_PROGRAM_OPTIONS_LDPATH = BOOST_PROGRAM_OPTIONS_LIBS = -lboost_program_options-mt BOOST_ROOT = BOOST_SERIALIZATION_LDFLAGS = BOOST_SERIALIZATION_LDPATH = BOOST_SERIALIZATION_LIBS = -lboost_serialization-mt BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = BOOST_UNIT_TEST_FRAMEWORK_LDPATH = BOOST_UNIT_TEST_FRAMEWORK_LIBS = -lboost_unit_test_framework-mt BOTAN110_CFLAGS = BOTAN110_LIBS = BOTAN18_CFLAGS = BOTAN18_LIBS = CC = ccache gcc CCDEPMODE = depmode=gcc3 CDB_CFLAGS = CDB_LIBS = -lcdb CFLAGS = -g -O2 CPP = ccache gcc -E CPPFLAGS = CXX = ccache g++ CXXCPP = ccache g++ -E CXXDEPMODE = depmode=gcc3 CXXFLAGS = -D_GNU_SOURCE -Wall -O2 CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H DEPDIR = .deps DISTCHECK_CONFIGURE_FLAGS = '--with-boost=' DIST_HOST = jenkins@autotest.powerdns.com DSYMUTIL = DUMPBIN = DYNLINKFLAGS = -rdynamic ECHO_C = ECHO_N = -n ECHO_T = EGREP = /bin/grep -E EXEEXT = FGREP = /bin/grep -F GREP = /bin/grep INSTALL = /usr/bin/install -c INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = $(install_sh) -c -s LD = /usr/bin/ld -m elf_x86_64 LDFLAGS = -lrt LEX = flex LEXLIB = -lfl LEX_OUTPUT_ROOT = lex.yy LIBCRYPT = -lcrypt LIBCURL_CFLAGS = LIBCURL_LIBS = -lcurl LIBDL = -ldl LIBLDAP = ldap_r LIBOBJS = LIBOPENDBX = opendbx LIBS = -lz -lcrypt LIBTOOL = $(SHELL) $(top_builddir)/libtool LIPO = LN_S = ln -s LTLIBOBJS = LUA_CFLAGS = -I/usr/include/lua5.1 LUA_LIBS = -llua5.1 MAKEINFO = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/missing --run makeinfo MKDIR_P = /bin/mkdir -p MYSQL_inc = -I/usr/include/mysql MYSQL_lib = -rdynamic -L/usr/lib/mysql -lmysqlclient NM = /usr/bin/nm -B NMEDIT = OBJDUMP = objdump OBJEXT = o ORACLE_CFLAGS = ORACLE_LIBS = OTOOL = OTOOL64 = PACKAGE = pdns PACKAGE_BUGREPORT = PACKAGE_NAME = pdns PACKAGE_STRING = pdns 3.3 PACKAGE_TARNAME = pdns PACKAGE_URL = PACKAGE_VERSION = 3.3 PATH_SEPARATOR = : PGSQL_incdir = /usr/include/postgresql PGSQL_lib = PKG_CONFIG = /usr/bin/pkg-config PKG_CONFIG_LIBDIR = PKG_CONFIG_PATH = RANLIB = ranlib REMOTEBACKEND_HTTP = yes SED = /bin/sed SET_MAKE = SHELL = /bin/bash SQLITE3_CFLAGS = SQLITE3_LIBS = -lsqlite3 STRIP = strip THREADFLAGS = -pthread UNIXODBC_incdir = UNIXODBC_lib = VERSION = 3.3 YACC = bison -y YFLAGS = abs_builddir = /var/lib/jenkins/jobs/auth-git/workspace/codedocs abs_srcdir = /var/lib/jenkins/jobs/auth-git/workspace/codedocs abs_top_builddir = /var/lib/jenkins/jobs/auth-git/workspace abs_top_srcdir = /var/lib/jenkins/jobs/auth-git/workspace ac_ct_CC = ccache gcc ac_ct_CXX = ac_ct_DUMPBIN = am__include = include am__leading_dot = . am__quote = am__tar = tar --format=ustar -chf - "$$tardir" am__untar = tar -xf - bindir = ${exec_prefix}/bin build = x86_64-unknown-linux-gnu build_alias = build_cpu = x86_64 build_os = linux-gnu build_vendor = unknown builddir = . datadir = ${datarootdir} datarootdir = ${prefix}/share docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} dvidir = ${docdir} exec_prefix = ${prefix} host = x86_64-unknown-linux-gnu host_alias = host_cpu = x86_64 host_os = linux-gnu host_vendor = unknown htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info install_sh = ${SHELL} /var/lib/jenkins/jobs/auth-git/workspace/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale localstatedir = ${prefix}/var lt_ECHO = echo mandir = ${datarootdir}/man mkdir_p = /bin/mkdir -p moduledirs = geobackend gmysqlbackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend pipebackend remotebackend tinydnsbackend randombackend pipebackend modulelibs = -lmysqlclient -lpq -lssl -lcrypto -lresolv -lnsl -lsqlite3 -lldap_r -llber -llua5.1 -lmysqlclient -lz -lopendbx -lcdb moduleobjects = ../modules/geobackend/geobackend.o ../modules/geobackend/ippreftree.o ../modules/gmysqlbackend/gmysqlbackend.o ../modules/gmysqlbackend/smysql.o ../modules/gpgsqlbackend/gpgsqlbackend.o ../modules/gpgsqlbackend/spgsql.o ../modules/gsqlite3backend/gsqlite3backend.o ../modules/ldapbackend/ldapbackend.o ../modules/ldapbackend/powerldap.o ../modules/luabackend/luabackend.o ../modules/luabackend/minimal.o ../modules/luabackend/reload.o ../modules/luabackend/lua_functions.o ../modules/luabackend/master.o ../modules/luabackend/private.o ../modules/luabackend/slave.o ../modules/luabackend/supermaster.o ../modules/luabackend/dnssec.o ../modules/mydnsbackend/mydnsbackend.o ../modules/opendbxbackend/odbxbackend.o ../modules/opendbxbackend/odbxprivate.o ../modules/pipebackend/coprocess.o ../modules/pipebackend/pipebackend.o ../modules/remotebackend/remotebackend.o ../modules/remotebackend/unixconnector.o ../modules/remotebackend/httpconnector.o ../modules/remotebackend/pipeconnector.o ../modules/tinydnsbackend/tinydnsbackend.o ../modules/tinydnsbackend/cdb.o ../modules/randombackend/randombackend.o oldincludedir = /usr/include pdfdir = ${docdir} prefix = /usr/local program_transform_name = s,x,x, programdescend = pdns psdir = ${docdir} sbindir = ${exec_prefix}/sbin sharedstatedir = ${prefix}/com socketdir = /var/run srcdir = . sysconfdir = ${prefix}/etc target_alias = top_build_prefix = ../ top_builddir = .. top_srcdir = .. all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign codedocs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign codedocs/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ distclean distclean-generic distclean-libtool distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am codedocs: . doxygen doxygen.conf # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/codedocs/Makefile.am0000644000014601777760000000004212136555572017411 0ustar00jenkinsnogroup00000000000000codedocs: . doxygen doxygen.conf pdns-3.3/Makefile.in0000644000014601777760000007371212165464030015643 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @TOOLS_TRUE@am__append_1 = pdns/docs/dnsreplay.8 pdns/docs/dnsscope.8 pdns/docs/dnswasher.8 subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING INSTALL NEWS TODO \ compile config.guess config.sub depcomp install-sh ltmain.sh \ missing ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" man8dir = $(mandir)/man8 NROFF = nroff MANS = $(man1_MANS) $(man8_MANS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = modules codedocs @programdescend@ DIST_SUBDIRS = modules codedocs pdns pdns/ext/rapidjson EXTRA_DIST = TODO README HACKING INSTALL debian-pdns/* pdns.spec \ codedocs/Makefile codedocs/doxygen.conf contrib/powerdns.solaris.init.d \ contrib/systemd-pdns.service contrib/systemd-pdns-recursor.service \ bootstrap build-scripts/semistaticg++ pdns/docs/dnstcpbench.1 ACLOCAL_AMFLAGS = -I m4 man8_MANS = pdns/docs/pdns_control.8 pdns/docs/pdnssec.8 \ pdns/docs/pdns_server.8 pdns/docs/zone2ldap.8 \ pdns/docs/zone2sql.8 $(am__append_1) @TOOLS_TRUE@man1_MANS = pdns/docs/dnstcpbench.1 all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-man1: $(man1_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } install-man8: $(man8_MANS) @$(NORMAL_INSTALL) test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \ done; } uninstall-man8: @$(NORMAL_UNINSTALL) @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man8dir)" && rm -f $$files; } # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(MANS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-exec-local install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man1 install-man8 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man1 uninstall-man8 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-exec-local \ install-html install-html-am install-info install-info-am \ install-man install-man1 install-man8 install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-recursive uninstall uninstall-am uninstall-man \ uninstall-man1 uninstall-man8 pdns/docs/dnstcpbench.1: cd pdns/docs && $(MAKE) dnstcpbench.1 install-exec-local: -@chmod +x pdns/pdns -@chmod +x pdns/precursor @echo "***********************************************************" @echo @echo init.d startup scripts have been made for you in pdns/pdns @echo and in pdns/precursor @echo You may want to copy these to /etc/init.d or equivalent @echo @echo "***********************************************************" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/aclocal.m40000644000014601777760000012522612165464023015436 0ustar00jenkinsnogroup00000000000000# 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. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, [m4_warning([this file was generated for autoconf 2.67. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # 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]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 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. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have 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_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], [pkg_failed=yes]) 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 AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [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])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [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 .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # 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. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 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. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # 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. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 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. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 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. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 # 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. # serial 5 # AM_PROG_LEX # ----------- # Autoconf leaves LEX=: if lex or flex can't be found. Change that to a # "missing" invocation, for better error output. AC_DEFUN([AM_PROG_LEX], [AC_PREREQ(2.50)dnl AC_REQUIRE([AM_MISSING_HAS_RUN])dnl AC_REQUIRE([AC_PROG_LEX])dnl if test "$LEX" = :; then LEX=${am_missing_run}flex fi]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 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. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # 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. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 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. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # 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. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 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. # serial 1 # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 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. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 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. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/boost.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) pdns-3.3/NEWS0000644000014601777760000000011212136555572014267 0ustar00jenkinsnogroup00000000000000For news, please see http://www.powerdns.com and http://wiki.powerdns.com pdns-3.3/debian-pdns/0000755000014601777760000000000012165464053015755 5ustar00jenkinsnogroup00000000000000pdns-3.3/debian-pdns/doc-base0000644000014601777760000000052612136555572017365 0ustar00jenkinsnogroup00000000000000Document: pdns Title: PowerDNS manual Author: PowerDNS B.V. Section: Apps/System Abstract: PowerDNS manual This is the complete manual for PowerDNS, documenting both how to install and configure it as well as how to write new backend modules. Format: html Index: /usr/share/doc/pdns/html/index.html Files: /usr/share/doc/pdns/html/*.html pdns-3.3/debian-pdns/changelog0000644000014601777760000002153512165464014017632 0ustar00jenkinsnogroup00000000000000pdns (3.3-1) unstable; urgency=medium * fill in the blanks -- peter van dijk Mon, 27 May 2013 16:00:00 +0200 pdns (3.2-1) unstable; urgency=medium * fill in the blanks -- peter van dijk Tue, 15 Jan 2013 15:00:00 +0100 pdns (3.2-rc4-1) unstable; urgency=medium * fill in the blanks -- peter van dijk Wed, 9 Jan 2013 21:00:00 +0100 pdns (3.2-rc3-1) unstable; urgency=medium * fill in the blanks -- peter van dijk Sat, 22 Dec 2012 21:00:00 +0100 pdns (3.2-rc2-1) unstable; urgency=medium * fill in the blanks -- peter van dijk Wed, 19 Dec 2012 12:00:00 +0100 pdns (3.2-rc1-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 8 Nov 2012 09:23:33 +0100 pdns (3.2-pre-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 7 Oct 2012 09:23:33 +0100 pdns (3.1-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 3 May 2012 09:23:33 +0100 pdns (3.1-rc3-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 28 Apr 2012 09:23:33 +0100 pdns (3.1-rc2-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 5 Apr 2012 09:23:33 +0100 pdns (3.1-rc1-1) unstable; urgency=medium * fill in the blanks -- bert hubert Wed, 21 Mar 2012 09:23:33 +0100 pdns (3.1-pre-1) unstable; urgency=medium * fill in the blanks -- bert hubert Wed, 28 Sep 2011 09:23:33 +0100 pdns (3.0-1) unstable; urgency=medium * fill in the blanks -- bert hubert Tue, 19 Jul 2011 09:23:33 +0100 pdns (3.0-rc3-1) unstable; urgency=medium * fill in the blanks -- bert hubert Fri, 15 Jul 2011 09:23:33 +0100 pdns (3.0-rc2-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 16 Apr 2011 23:23:33 +0100 pdns (3.0-rc1-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 3 Apr 2011 23:23:33 +0100 pdns (3.0.pre-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 9 Jan 2011 23:23:33 +0100 pdns (2.9.22-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sat, 25 Jan 2009 23:23:33 +0100 pdns (2.9.22-rc4-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sat, 26 Dec 2008 23:23:33 +0100 pdns (2.9.22-rc3-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sat, 6 Dec 2008 23:23:33 +0100 pdns (2.9.22-rc2-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 29 Nov 2008 23:23:33 +0100 pdns (2.9.22-rc1-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 16 Nov 2008 23:23:33 +0100 pdns (2.9.22-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 3 Aug 2008 23:23:33 +0100 pdns (2.9.21-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sat, 21 Apr 2006 23:23:33 +0100 pdns (2.9.20-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sat, 14 Jan 2006 23:23:33 +0100 pdns (2.9.19-2) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 29 Oct 2005 23:23:33 +0100 pdns (2.9.19-1) unstable; urgency=medium * fill in the blanks -- bert hubert Sun, 11 Sep 2005 23:23:33 +0100 pdns (2.9.18-2) unstable; urgency=medium * fill in the blanks -- bert hubert Wed, 20 Jul 2005 23:23:33 +0100 pdns (2.9.18-1) unstable; urgency=medium * fill in the blanks -- bert hubert Thu, 14 Jun 2005 23:23:33 +0100 pdns (2.9.17-1) unstable; urgency=medium * fill in the blanks -- Wichert Akkerman Sat, 13 Sep 2004 23:23:33 +0100 pdns (2.9.16-1) unstable; urgency=medium * fill in the blanks -- Wichert Akkerman Sat, 17 Jan 2004 23:23:33 +0100 pdns (2.9.15-1) unstable; urgency=medium * fill in the blanks -- Wichert Akkerman Sat, 17 Jan 2004 23:23:33 +0100 pdns (2.9.14-1) unstable; urgency=medium * New upstream version. Postgres support rewritten to use the C interface instead of the deprectaed libpqpp -- Wichert Akkerman Fri, 16 Jan 2004 23:23:33 +0100 pdns (2.9.13-3) unstable; urgency=medium * Fix pdns postinst so pdns is properly restart on upgrade -- Wichert Akkerman Sat, 10 Jan 2004 17:21:18 +0100 pdns (2.9.13-2) unstable; urgency=critical * Fix a bug in calculation of early timestamps: 1<<31-1 is not the same as (1<<31)-1. This made all pdns servers consume all possible CPU when UNIX time went through 2^30 two hours ago. -- Wichert Akkerman Sat, 10 Jan 2004 16:53:09 +0100 pdns (2.9.13-1) unstable; urgency=low * New upstream release * Stop using my debian.org email address * Change init scripts to conform to Debian policy -- Wichert Akkerman Thu, 25 Dec 2003 13:33:40 +0100 pdns (2.9.12-1) unstable; urgency=low * New upstream release * Fix dependency generation. Closes: Bug#210256 * Check if pdns is installed in init script. Closes: Bug#217402 * Create a SQLite backend package * Add versioned dpkg-dev Build-Depends so ${dpkg:Version} works properly -- Wichert Akkerman Mon, 27 Oct 2003 18:52:53 +0100 pdns (2.9.11-2) unstable; urgency=low * Remove automake build-depends and bootstrap rule from debian/rules. This makes pdns a bit more portable across Debian releases. Closes: Bug#205990 * Try to remove the /etc/powerdns directory on purge. Closes: Bug#209051 * Use libmysqlclient-dev instead of libmysqlclient10-dev -- Wichert Akkerman Tue, 9 Sep 2003 14:59:46 +0200 pdns (2.9.11-1) unstable; urgency=low * New upstream release * Do not include zone2ldap in pdns package. Closes: Bug#198613 * The gdbm-dev seems to have changed its name, update Build-Depends accordingly. Closes: Bug#199595 -- Wichert Akkerman Mon, 14 Jul 2003 13:52:47 +0200 pdns (2.9.8-1) unstable; urgency=low * New upstream release. Closes: Bug#187781 -- Wichert Akkerman Mon, 5 May 2003 13:43:16 +0200 pdns (2.9.7-1) unstable; urgency=low * New upstream release. Closes: Bug#185730 -- Wichert Akkerman Fri, 21 Mar 2003 12:53:00 +0100 pdns (2.9.6-2) unstable; urgency=low * Enable the recursing nameserver * Change order of things in clean target so debian/files is properly removed. Closes: Bug#181994 -- Wichert Akkerman Sun, 23 Feb 2003 12:34:57 +0100 pdns (2.9.6-1) unstable; urgency=low * New upstream release, adding a new LDAP backend -- Wichert Akkerman Sun, 16 Feb 2003 14:49:08 +0100 pdns (2.9.5-1) unstable; urgency=low * fill in the blanks -- Wichert Akkerman Mon, 3 Feb 2003 20:16:16 +0100 pdns (2.9.4-1) unstable; urgency=low * fill in the blanks -- Wichert Akkerman Sat, 21 Dec 2002 20:16:16 +0100 pdns (2.9.3a-1) unstable; urgency=low * New upstream release; fixes a problem in zone2sql -- Wichert Akkerman Sat, 21 Dec 2002 20:16:16 +0100 pdns (2.9.3-1) unstable; urgency=low * New upstream release. Yes, the packaging changes yet again to reflect changes made upstream. The packaging of SQL backends should be more sane now and we don't expect to change them again. -- Wichert Akkerman Sat, 21 Dec 2002 18:18:40 +0100 pdns (2.9.2-3) unstable; urgency=low * Compile pgmysql and xdb backend with -fPIC. Real fix is to swithc to using libtool for all backends, which will happen in the next upstream release. -- Wichert Akkerman Mon, 16 Dec 2002 13:43:52 +0100 pdns (2.9.2-2) unstable; urgency=low * Add Build-Depends on libgdbmg1-dev, which is needed by the pipe backend -- Wichert Akkerman Mon, 16 Dec 2002 11:18:11 +0100 pdns (2.9.2-1) unstable; urgency=low * New upstream release * bind backend fully merged in the main pdns package now * Add new pipe, pgmysql and xdb backends -- Wichert Akkerman Fri, 13 Dec 2002 16:39:29 +0100 pdns (2.9-1) unstable; urgency=low * Initial packaging -- Wichert Akkerman Sun, 1 Dec 2002 15:04:52 +0100 pdns-3.3/debian-pdns/copyright0000644000014601777760000000163612136555572017723 0ustar00jenkinsnogroup00000000000000This is the Debian prepackaged version of pDNS, the PowerDNS nameserver. pDNS can be downloaded from http://www.powerdns.com/ Copyright and license: Copyright 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. Additionally, the license of this program contains a special exception which allows to distribute the program in binary form when it is linked against OpenSSL. 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. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL pdns-3.3/debian-pdns/rules0000755000014601777760000001607012165455411017037 0ustar00jenkinsnogroup00000000000000#!/usr/bin/make -f tmpdir := $(shell pwd)/debian-pdns/tmp be_tmpdir := $(shell pwd)/debian-pdns/tmp-backend tools_tmpdir:= $(shell pwd)/debian-pdns/tmp-tools backends := opendbx ldap pipe gmysql gpgsql gsqlite3 debs := opendbx ldap pipe pgsql sqlite sqlite3 binary-doc: -make -C pdns/docs html/index.html rm -rf "$(tmpdir)" install -d -m 755 -o root -g root \ "$(tmpdir)"/usr/share/doc/pdns/html set -e ; for i in pdns/docs/html/* ; do \ install -p -m 644 -o root -g root "$$i" \ "$(tmpdir)"/usr/share/doc/pdns/html/ ; \ done install -d -m 755 -o root -g root \ "$(tmpdir)"/usr/share/doc/pdns-doc install -p -m 644 -o root -g root debian-pdns/changelog \ "$(tmpdir)"/usr/share/doc/pdns-doc/changelog.Debian gzip -9 "$(tmpdir)"/usr/share/doc/pdns-doc/* install -p -m 644 -o root -g root debian-pdns/copyright \ "$(tmpdir)"/usr/share/doc/pdns-doc/ install -d -m 755 -o root -g root "$(tmpdir)"/usr/share/doc-base install -p -m 644 -o root -g root debian-pdns/doc-base \ "$(tmpdir)"/usr/share/doc-base/pdns install -d -m 755 -o root -g root "$(tmpdir)"/DEBIAN install -p -m 755 -o root -g root debian-pdns/pdns-doc.prerm \ "$(tmpdir)"/DEBIAN/prerm install -p -m 755 -o root -g root debian-pdns/pdns-doc.postinst \ "$(tmpdir)"/DEBIAN/postinst dpkg-gencontrol -fdebian-pdns/files -cdebian-pdns/control -ldebian-pdns/changelog -isp -ppdns-doc -P"$(tmpdir)" dpkg --build "$(tmpdir)" .. build-static stamp-build-static: ./configure \ CXX=$(shell pwd)/build-scripts/semistaticg++ \ PKG_CONFIG_PATH=/opt/botan-1.10/lib/pkgconfig/ \ --prefix=/usr \ --libexecdir='$${prefix}/lib' \ --libdir='$${prefix}/lib/powerdns' \ --sysconfdir=/etc/powerdns \ --infodir='$${datadir}/info' \ --mandir='$${datadir}/man' \ --with-pgsql-lib=/opt/postgresql/lib --with-pgsql-includes=/opt/postgresql/include \ --with-modules="gmysql gpgsql pipe gsqlite3 lua geo tinydns mydns opendbx remote" \ --with-dynmodules="" \ --enable-botan1.10 --enable-cryptopp \ --enable-static-binaries \ --enable-tools make -j4 touch stamp-build-static build stamp-build: configure ./configure \ --prefix=/usr \ --libexecdir='$${prefix}/lib' \ --libdir='$${prefix}/lib/powerdns' \ --sysconfdir=/etc/powerdns \ --infodir='$${datadir}/info' \ --mandir='$${datadir}/man' \ --with-dynmodules="$(backends)" \ --with-modules="geo" make touch stamp-build binary-main-prepare: rm -f debian-pdns/substvars rm -rf "$(tmpdir)" "$(tmpdir)"-* rm -rf "$(tools_tmpdir)" "$(tools_tmpdir)"-* install -d -m 755 -o root -g root "$(tmpdir)" install -d -m 755 -o root -g root "$(tools_tmpdir)" make DESTDIR="$(tmpdir)" install rm -f "$(tmpdir)"/usr/bin/binpatch rm -f "$(tmpdir)"/usr/bin/zone2ldap rm -rf "$(tmpdir)"/usr/lib rm -f "$(tmpdir)"/usr/share/man/man8/zone2ldap.8 strip --remove-section=.comment --remove-section=.note \ --strip-unneeded \ "$(tmpdir)"/usr/bin/zone2sql \ "$(tmpdir)"/usr/sbin/pdns_server \ "$(tmpdir)"/usr/bin/pdns_control mv "$(tmpdir)"/etc/powerdns/pdns.conf-dist "$(tmpdir)"/etc/powerdns/pdns.conf install -d -m 755 -o root -g root "$(tmpdir)"/etc/init.d install -p -m 755 -o root -g root pdns/pdns \ "$(tmpdir)"/etc/init.d/pdns install -d -m 755 -o root -g root \ "$(tmpdir)"/usr/share/doc/pdns install -p -m 644 -o root -g root debian-pdns/changelog \ "$(tmpdir)"/usr/share/doc/pdns/changelog.Debian gzip -9 "$(tmpdir)"/usr/share/doc/pdns/c* install -p -m 644 -o root -g root debian-pdns/copyright \ "$(tmpdir)"/usr/share/doc/pdns/ install -d -m 755 -o root -g root "$(tmpdir)"/DEBIAN install -p -m 755 -o root -g root debian-pdns/pdns.prerm \ "$(tmpdir)"/DEBIAN/prerm install -p -m 755 -o root -g root debian-pdns/pdns.postrm \ "$(tmpdir)"/DEBIAN/postrm install -p -m 755 -o root -g root debian-pdns/pdns.postinst \ "$(tmpdir)"/DEBIAN/postinst install -p -m 644 -o root -g root debian-pdns/pdns.conffiles \ "$(tmpdir)"/DEBIAN/conffiles install -d -m 755 -o root -g root \ "$(tools_tmpdir)"/usr/bin install -d -m 755 -o root -g root \ "$(tools_tmpdir)"/usr/share/man/man8 install -d -m 755 -o root -g root \ "$(tools_tmpdir)"/usr/share/man/man1 install -d -m 755 -o root -g root \ "$(tools_tmpdir)"/usr/share/doc/pdns-tools install -p -m 644 -o root -g root debian-pdns/changelog \ "$(tools_tmpdir)"/usr/share/doc/pdns-tools/changelog.Debian gzip -9 "$(tools_tmpdir)"/usr/share/doc/pdns-tools/c* install -p -m 644 -o root -g root debian-pdns/copyright \ "$(tools_tmpdir)"/usr/share/doc/pdns-tools/ install -d -m 755 -o root -g root "$(tools_tmpdir)"/DEBIAN #FIXME: shell loops hide errors for prog in dnsbulktest dnsreplay dnsscan dnsscope dnstcpbench dnswasher nproxy nsec3dig ; do \ mv "$(tmpdir)"/usr/bin/$$prog "$(tools_tmpdir)"/usr/bin ; \ [ -e "$(tmpdir)"/usr/share/man/man8/"$$prog".8 ] && \ mv "$(tmpdir)"/usr/share/man/man8/"$$prog".8 "$(tools_tmpdir)"/usr/share/man/man8/ ; \ [ -e "$(tmpdir)"/usr/share/man/man1/"$$prog".1 ] && \ mv "$(tmpdir)"/usr/share/man/man1/"$$prog".1 "$(tools_tmpdir)"/usr/share/man/man1/ ; \ strip --remove-section=.comment --remove-section=.note \ --strip-unneeded \ "$(tools_tmpdir)"/usr/bin/"$$prog" ; \ done binary-main: stamp-build binary-main-prepare dpkg-shlibdeps -Tdebian-pdns/substvars "$(tmpdir)"/usr/bin/zone2sql \ "$(tmpdir)"/usr/sbin/pdns_server \ "$(tmpdir)"/usr/bin/pdns_control dpkg-gencontrol -fdebian-pdns/files -cdebian-pdns/control -ldebian-pdns/changelog -isp -ppdns -P"$(tmpdir)" dpkg --build "$(tmpdir)" .. binary-static: stamp-build-static binary-main-prepare dpkg-gencontrol -fdebian-pdns/files -cdebian-pdns/control -ldebian-pdns/changelog -isp -ppdns-static -P"$(tmpdir)" dpkg-gencontrol -fdebian-pdns/files -cdebian-pdns/control -ldebian-pdns/changelog -isp -ppdns-tools -P"$(tools_tmpdir)" dpkg --build "$(tmpdir)" .. dpkg --build "$(tools_tmpdir)" .. binary-backend: stamp-build rm -rf "$(tmpdir)" install -d -m 755 -o root -g root "$(tmpdir)" make DESTDIR="$(tmpdir)" install chmod 644 "$(tmpdir)"/usr/lib/powerdns/* set -e ; for be in $(debs) ; do \ rm -f debian-pdns/substvars ; \ rm -rf "$(be_tmpdir)" ; \ pkg=pdns-backend-$$be ; \ \ for file in $$(cd "$(tmpdir)" ; find . -name "*$$be*") ; do \ install -d -m 755 -o root -g root "$(be_tmpdir)"/$$(dirname "$$file") ; \ mv "$(tmpdir)"/"$$file" "$(be_tmpdir)"/"$$file" ; \ done ; \ \ install -d -m 755 -o root -g root "$(be_tmpdir)"/usr/share/doc ; \ ln -s pdns "$(be_tmpdir)"/usr/share/doc/$$pkg ; \ \ install -d -m 755 -o root -g root "$(be_tmpdir)"/DEBIAN ; \ dpkg-shlibdeps -Tdebian-pdns/substvars "$(be_tmpdir)"/usr/lib/powerdns/*.so ; \ dpkg-gencontrol -fdebian-pdns/files -cdebian-pdns/control -ldebian-pdns/changelog -isp -p$$pkg -P"$(be_tmpdir)" ; \ dpkg --build "$(be_tmpdir)" .. ; \ done binary: binary-indep binary-arch binary-indep: binary-doc binary-arch: binary-main binary-backend clean: -make distclean -make -C pdns/docs clean rm -f debian-pdns/files debian-pdns/substvars stamp-build stamp-build-static rm -rf "$(tmpdir)" "$(be_tmpdir)" .PHONY: clean build binary binary-arch binary-indep .PHONY: binary-doc binary-main binary-backend pdns-3.3/debian-pdns/pdns.conffiles0000644000014601777760000000005112136555572020614 0ustar00jenkinsnogroup00000000000000/etc/powerdns/pdns.conf /etc/init.d/pdns pdns-3.3/debian-pdns/control0000644000014601777760000000751512162515035017362 0ustar00jenkinsnogroup00000000000000Source: pdns Section: net Priority: extra Standards-Version: 3.5.8 Maintainer: bert hubert Build-Depends: autoconf, libtool, flex, bison, docbook-utils, libmysqlclient-dev, postgresql-dev | libpq-dev, tdb-dev, libgdbm-dev, libldap2-dev, libsqlite3-dev, dpkg-dev (>= 1.10.17), libboost-dev (>=1.34), libboost-program-options-dev, libboost-serialization-dev, pkg-config, ragel, libbotan1.10-dev, liblua5.1-dev Package: pdns Architecture: any Depends: ${shlibs:Depends} Recommends: pdns-doc Suggests: pdns-backend Description: extremely powerful and versatile nameserver PowerDNS is a versatile nameserver which supports a large number of different backends ranging from simple zonefiles to relational databases and load balancing/failover algorithms. Package: pdns-static Architecture: any Recommends: pdns-doc Conflicts: pdns-server Description: static version of pDNS PowerDNS is a versatile nameserver which supports a large number of different backends ranging from simple zonefiles to relational databases and load balancing/failover algorithms. . This package contains a statically compiled version of pDNS which can be used on older Debian releases for which no dynamic version is available. Package: pdns-tools Architecture: any Recommends: pdns-doc Conflicts: pdns-server Description: static version of pDNS tools PowerDNS is a versatile nameserver which supports a large number of different backends ranging from simple zonefiles to relational databases and load balancing/failover algorithms. . This package contains a collection of tools based on the core PowerDNS libraries. Package: pdns-doc Section: doc Architecture: all Description: PowerDNS manual This is the complete manual for PowerDNS, documenting both how to install and configure it as well as how to write new backend modules. Package: pdns-backend-pipe Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: pipe/coprocess backend for pDNS This package contains the pipe backend for the PowerDNS nameserver. This allows PowerDNS to retrieve domain info from a process that accepts questions on stdin and returns answers on stdout. Package: pdns-backend-ldap Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: LDAP backend for pDNS This package contains a LDAP backend for the PowerDNS nameserver. Package: pdns-backend-opendbx Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: OpenDBX backend for pDNS This package contains a OpenDBX backend for the PowerDNS nameserver. Package: pdns-backend-mysql Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: MySQL backend for pDNS This package contains a MySQL backend for the PowerDNS nameserver. Package: pdns-backend-pgsql Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: Generic PostgreSQL backend for pDNS This package contains a generic PostgreSQL backend for the PowerDNS nameserver. It has configurable SQL statements. Package: pdns-backend-sqlite Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: SQLite backend for pDNS This package contains a generic SQLite backend for SQLite. Package: pdns-backend-xdb Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: XDB/tdb/gdb backend for pDNS This package contains a table backend for PowerDNS. Currently includes TDB, the Trivial Database or Tridgell Database. Package: pdns-backend-oracle Architecture: any Depends: pdns (= ${dpkg:Version}), ${shlibs:Depends} Provides: pdns-backend Description: Oracle backend for pDNS This package contains a generic Oracle backend for PowerDNS. pdns-3.3/debian-pdns/shlibs.local0000644000014601777760000000004312136555572020257 0ustar00jenkinsnogroup00000000000000libmysqlbackend 0 libbindbackend 0 pdns-3.3/debian-pdns/pdns.postrm0000755000014601777760000000022712136555572020200 0ustar00jenkinsnogroup00000000000000#!/bin/sh set -e update_init() { update-rc.d pdns remove > /dev/null } if [ "$1" = "purge" ] ; then update_init rmdir /etc/powerdns || true fi pdns-3.3/debian-pdns/pdns.postinst0000755000014601777760000000047212136555572020541 0ustar00jenkinsnogroup00000000000000#!/bin/sh set -e update_init() { if [ -z "$2" ] ; then update-rc.d pdns defaults 15 85 > /dev/null fi } update_pdns() { if [ -n "$2" ] ; then invoke-rc.d pdns start else invoke-rc.d pdns restart fi } if [ "$1" = "configure" -o "$1" = "abort-upgrade" ] ; then update_init "$@" update_pdns "$@" fi pdns-3.3/debian-pdns/pdns.prerm0000755000014601777760000000023712136555572020002 0ustar00jenkinsnogroup00000000000000#!/bin/sh set -e if [ "$1" = "remove" ] ; then if command -v invoke-rc.d >/dev/null 2>&1; then invoke-rc.d pdns stop else /etc/init.d/pdns stop fi fi pdns-3.3/debian-pdns/pdns-doc.prerm0000755000014601777760000000025012136555572020540 0ustar00jenkinsnogroup00000000000000#!/bin/sh set -e update_docbase() { if command -v install-docs >/dev/null 2>&1 ; then install-docs -r pdns fi } if [ "$1" = "remove" ] ; then update_docbase fi pdns-3.3/debian-pdns/pdns-doc.postinst0000755000014601777760000000033312136555572021300 0ustar00jenkinsnogroup00000000000000#!/bin/sh set -e update_docbase() { if command -v install-docs >/dev/null 2>&1 ; then install-docs -i /usr/share/doc-base/pdns fi } if [ "$1" = "configure" -o "$1" = "abort-upgrade" ] ; then update_docbase fi pdns-3.3/config.sub0000755000014601777760000010344512165464024015561 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. timestamp='2010-01-22' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, 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. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; # This must be matched before tile*. tilegx*) basic_machine=tilegx-unknown os=-linux-gnu ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: pdns-3.3/INSTALL0000644000014601777760000000017712136555572014634 0ustar00jenkinsnogroup00000000000000See README. Especially helpful is the 'pdns' init.d script in pdns/pdns http://doc.powerdns.com is also a good place to start pdns-3.3/config.h.in0000644000014601777760000001265112165464024015617 0ustar00jenkinsnogroup00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Skip gcc locking */ #undef GCC_SKIP_LOCKING /* Defined if the requested minimum BOOST version is satisfied */ #undef HAVE_BOOST /* Define to 1 if you have */ #undef HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP /* Define to 1 if you have */ #undef HAVE_BOOST_FOREACH_HPP /* Define to 1 if you have */ #undef HAVE_BOOST_PROGRAM_OPTIONS_HPP /* Define to 1 if you have */ #undef HAVE_BOOST_TEST_UNIT_TEST_HPP /* If we have botan 1.10 */ #undef HAVE_BOTAN110 /* If we have botan 1.8 */ #undef HAVE_BOTAN18 /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* If the host operating system understands IPv6 */ #undef HAVE_IPV6 /* Define to 1 if you have the header file. */ #undef HAVE_LBER_H /* Define to 1 if you have the header file. */ #undef HAVE_LDAP_H /* Define to 1 if you have ldap_initialize */ #undef HAVE_LDAP_INITIALIZE /* Define to 1 if you have ldap_sasl_bind */ #undef HAVE_LDAP_SASL_BIND /* Define to 1 if you have the `crypt' library (-lcrypt). */ #undef HAVE_LIBCRYPT /* If we have libcurl */ #undef HAVE_LIBCURL /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Have -lldap */ #undef HAVE_LIBLDAP /* Have -lldap_r */ #undef HAVE_LIBLDAP_R /* Have -lopendbx */ #undef HAVE_LIBOPENDBX /* Define to 1 if you have the `polarssl' library (-lpolarssl). */ #undef HAVE_LIBPOLARSSL /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* liblua */ #undef HAVE_LUA /* lua.h */ #undef HAVE_LUA_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the `mktime' function. */ #undef HAVE_MKTIME /* Define to 1 if you have the header file. */ #undef HAVE_ODBX_H /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* If we have sqlite3 */ #undef HAVE_SQLITE3 /* 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 `strcasestr' function. */ #undef HAVE_STRCASESTR /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* If your OS is so broken that it needs an additional prototype */ #undef NEED_INET_NTOP_PROTO /* If POSIX typedefs need to be defined */ #undef NEED_POSIX_TYPEDEF /* If host OS misses RTLD_NOW */ #undef NEED_RTLD_NOW /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* If we want HTTP connector */ #undef REMOTEBACKEND_HTTP /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* If verbose logging should be enabled */ #undef VERBOSELOG /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER /* Define to `unsigned int' if does not define. */ #undef size_t pdns-3.3/README0000644000014601777760000000530112142513445014443 0ustar00jenkinsnogroup00000000000000PowerDNS is copyright Ⓒ 2012-2013 by PowerDNS.COM BV & lots of contributors, using the GNU GPLv2 license. All documentation can be found on http://doc.powerdns.com/ This file may lag behind at times. For most recent updates, always check http://doc.powerdns.com/changelog.html and http://wiki.powerdns.com Another good place to look for information is: http://doc.powerdns.com/compiling-powerdns.html To file bugs, head towards: https://github.com/PowerDNS/pdns/issues But please check if the issue is already reported there first. SOURCE CODE / GIT ----------------- Source code is available on GitHub: $ git clone https://github.com/PowerDNS/pdns.git This repository contains the sources both for the PowerDNS Recursor and for PowerDNS Authoritative Server, and both can be built from this repository. Both are released separately as .tar.gz, .deb and .rpm however! COMPILING Authoritative Server ------------------------------ PowerDNS Authoritative Server 3.0 and beyond depend on Boost. On Debian 7.0, the following is useful: apt-get install autoconf automake bison flex g++ git libboost-all-dev libtool make pkg-config ragel To compile a very clean version, use: $ ./configure --with-modules="" --without-lua $ make # make install This generates a PowerDNS Authoritative Server binary with no modules, except the bind backend, built in. When ./configure is run without --with-modules, the gmysql module is built-in by default and the pipe-backend is compiled for runtime loading. To add multiple modules, try: $ ./configure --with-modules="gmysql gpgsql" See http://doc.powerdns.com/compiling-powerdns.html for more details. Please don't use the 'mysql' backend, it is deprecated. Use the 'gmysql' one! COMPILING THE RECURSOR ---------------------- Either use ./configure --enable-recursor or explicitly do 'make pdns_recursor'. Releases are built by first running dist-recursor and compiling from the pdns-recursor-x.y subdirectory. SOLARIS NOTES ------------- You need gcc 3.x, preferably 3.2! The 'Sunpro' compiler is currently not supported (patches are welcome if not too intrusive). If you encounter problems with the Solaris make, gmake is advised. FREEBSD NOTES ------------- You need to compile using gmake - regular make only appears to work, but doesn't in fact. Use gmake, not make. MAC OS X NOTES -------------- PowerDNS Authoritative Server is available through Homebrew: $ brew install pdns If you want to compile yourself, the dependencies can be installed using Homebrew: $ brew install boost lua pkg-config ragel For PostgreSQL support: $ brew install postgresql For MySQL support: $ brew install mariadb LINUX NOTES ----------- None really. pdns-3.3/TODO0000644000014601777760000000201012136555572014257 0ustar00jenkinsnogroup00000000000000THIS IS NOT UP TO DATE AND CONTAINS RANDOM RAMBLING --------------------------------------------------- Also see http://wiki.powerdns.com/trac/wiki/TodoList Older stuff below: * new zone is AXFRed, written to disk successfully probably? unsure * the old SOA record remains in place bugs: pdns.conf-dist contains old descriptions dynmessenger.cc unused variable warning Things we will not do but hope other people will: - Ports to NetBSD, OpenBSD, AIX webserver has problems with 'top-100 queries' instead of top-10. Projects we will be working on, but would like help for: Big things: - new plan Like in the old days but with a twist - additional processing is done on a best-effort basis by a non-rd packet sent to syncres. This means we can stay lazy for far longer! TODO: learn syncres to load its roots from disk too or at completime get a way to nuke the cache/parts of the cache - Add support for TSIG Small things, great for coders new to PowerDNS: - remove 'handle' from UeberBackend and BindBackend pdns-3.3/m4/0000755000014601777760000000000012165464053014111 5ustar00jenkinsnogroup00000000000000pdns-3.3/m4/ltversion.m40000644000014601777760000000127712165464021016402 0ustar00jenkinsnogroup00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # 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. # Generated from ltversion.in. # serial 3017 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.2.6b]) m4_define([LT_PACKAGE_REVISION], [1.3017]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.2.6b' macro_revision='1.3017' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) pdns-3.3/m4/ltoptions.m40000644000014601777760000002724212165464021016410 0ustar00jenkinsnogroup00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # 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. # serial 6 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [0], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) pdns-3.3/m4/lt~obsolete.m40000644000014601777760000001311312165464021016717 0ustar00jenkinsnogroup00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # 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. # serial 4 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) pdns-3.3/m4/libtool.m40000644000014601777760000077464712165464021016043 0ustar00jenkinsnogroup00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # 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. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 56 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl _LT_PROG_ECHO_BACKSLASH case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\[$]0 --fallback-echo"')dnl " lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` ;; esac _LT_OUTPUT_LIBTOOL_INIT ]) # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) cat >"$CONFIG_LT" <<_LTEOF #! $SHELL # Generated by $as_me. # Run this file to recreate a libtool stub with the current configuration. lt_cl_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2008 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. if test "$no_create" != yes; then lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) fi ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_XSI_SHELLFNS sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(whole_archive_flag_spec, $1)='' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX # ----------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl AC_LINK_IFELSE(AC_LANG_PROGRAM,[ lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) $1 AC_DIVERT_POP ])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. m4_defun([_LT_PROG_ECHO_BACKSLASH], [_LT_SHELL_INIT([ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac ECHO=${lt_ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF [$]* _LT_EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(lt_ECHO) ]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that does not interpret backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [AC_CHECK_TOOL(AR, ar, false) test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1]) AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line __oline__ "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method == "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC*) # IBM XL 8.0 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl*) # IBM XL C 8.0/Fortran 10.1 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Sun\ F*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' ;; linux* | k*bsd*-gnu) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE(int foo(void) {}, _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' ) LDFLAGS="$save_LDFLAGS" else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_MSG_CHECKING([whether -lc should be explicitly linked in]) $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then _LT_TAGVAR(archive_cmds_need_lc, $1)=no else _LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [fix_srcfile_path], [1], [Fix the shell variable $srcfile for the compiler]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_PROG_CXX # ------------ # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ # compiler, we have our own version here. m4_defun([_LT_PROG_CXX], [ pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) AC_PROG_CXX if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_CXX dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_CXX], []) # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [AC_REQUIRE([_LT_PROG_CXX])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=echo else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_PROG_F77 # ------------ # Since AC_PROG_F77 is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_F77], [ pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) AC_PROG_F77 if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_F77 dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_F77], []) # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_REQUIRE([_LT_PROG_F77])dnl AC_LANG_PUSH(Fortran 77) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${F77-"f77"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_PROG_FC # ----------- # Since AC_PROG_FC is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_FC], [ pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) AC_PROG_FC if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_FC dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_FC], []) # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_REQUIRE([_LT_PROG_FC])dnl AC_LANG_PUSH(Fortran) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${FC-"f95"} compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC="$lt_save_CC" ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC= CC=${RC-"windres"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC="$lt_save_CC" ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_XSI_SHELLFNS # --------------------- # Bourne and XSI compatible variants of some useful shell functions. m4_defun([_LT_PROG_XSI_SHELLFNS], [case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $[*] )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } dnl func_dirname_and_basename dnl A portable version of this function is already defined in general.m4sh dnl so there is no need for it here. # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[[^=]]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$[@]"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]+=\$[2]" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]=\$$[1]\$[2]" } _LT_EOF ;; esac ]) pdns-3.3/m4/boost.m40000644000014601777760000013170412150635706015506 0ustar00jenkinsnogroup00000000000000# boost.m4: Locate Boost headers and libraries for autoconf-based projects. # Copyright (C) 2007, 2008, 2009, 2010, 2011 Benoit Sigoure # # 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 3 of the License, or # (at your option) any later version. # # Additional permission under section 7 of the GNU General Public # License, version 3 ("GPLv3"): # # If you convey this file as part of a work that contains a # configuration script generated by Autoconf, you may do so under # terms of your choice. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . m4_define([_BOOST_SERIAL], [m4_translit([ # serial 18 ], [# ], [])]) # Original sources can be found at http://github.com/tsuna/boost.m4 # You can fetch the latest version of the script by doing: # wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4 # ------ # # README # # ------ # # This file provides several macros to use the various Boost libraries. # The first macro is BOOST_REQUIRE. It will simply check if it's possible to # find the Boost headers of a given (optional) minimum version and it will # define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to # your configure so that users can specify non standard locations. # If the user's environment contains BOOST_ROOT and --with-boost was not # specified, --with-boost=$BOOST_ROOT is implicitly used. # For more README and documentation, go to http://github.com/tsuna/boost.m4 # Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry, # simply read the README, it will show you what to do step by step. m4_pattern_forbid([^_?(BOOST|Boost)_]) # _BOOST_SED_CPP(SED-PROGRAM, PROGRAM, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # -------------------------------------------------------- # Same as AC_EGREP_CPP, but leave the result in conftest.i. # # SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded # in double-quotes, so escape your double quotes. # # It could be useful to turn this into a macro which extracts the # value of any macro. m4_define([_BOOST_SED_CPP], [AC_LANG_PREPROC_REQUIRE()dnl AC_REQUIRE([AC_PROG_SED])dnl AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])]) AS_IF([dnl eval is necessary to expand ac_cpp. dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. dnl Beware of Windows end-of-lines, for instance if we are running dnl some Windows programs under Wine. In that case, boost/version.hpp dnl is certainly using "\r\n", but the regular Unix shell will only dnl strip `\n' with backquotes, not the `\r'. This results in dnl boost_cv_lib_version='1_37\r' for instance, which breaks dnl everything else. dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | tr -d '\r' | $SED -n -e "$1" >conftest.i 2>&1], [$3], [$4]) rm -rf conftest* ])# AC_EGREP_CPP # BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND]) # ----------------------------------------------- # Look for Boost. If version is given, it must either be a literal of the form # "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a # variable "$var". # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with # the required version, it does not check for any of the Boost libraries. # On # success, defines HAVE_BOOST. On failure, calls the optional # ACTION-IF-NOT-FOUND action if one was supplied. # Otherwise aborts with an error message. AC_DEFUN([BOOST_REQUIRE], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_PROG_GREP])dnl echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD boost_save_IFS=$IFS boost_version_req=$1 IFS=. set x $boost_version_req 0 0 0 IFS=$boost_save_IFS shift boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"` boost_version_req_string=$[1].$[2].$[3] AC_ARG_WITH([boost], [AS_HELP_STRING([--with-boost=DIR], [prefix of Boost $1 @<:@guess@:>@])])dnl AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl # If BOOST_ROOT is set and the user has not provided a value to # --with-boost, then treat BOOST_ROOT as if it the user supplied it. if test x"$BOOST_ROOT" != x; then if test x"$with_boost" = x; then AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT]) with_boost=$BOOST_ROOT else AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost]) fi fi AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl boost_save_CPPFLAGS=$CPPFLAGS AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string], [boost_cv_inc_path], [boost_cv_inc_path=no AC_LANG_PUSH([C++])dnl m4_pattern_allow([^BOOST_VERSION$])dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include #if !defined BOOST_VERSION # error BOOST_VERSION is not defined #elif BOOST_VERSION < $boost_version_req # error Boost headers version < $boost_version_req #endif ]])]) # If the user provided a value to --with-boost, use it and only it. case $with_boost in #( ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \ /usr/include C:/Boost/include;; #( *) set x "$with_boost/include" "$with_boost";; esac shift for boost_dir do # Without --layout=system, Boost (or at least some versions) installs # itself in /include/boost-. This inner loop helps to # find headers in such directories. # # Any ${boost_dir}/boost-x_xx directories are searched in reverse version # order followed by ${boost_dir}. The final '.' is a sentinel for # searching $boost_dir" itself. Entries are whitespace separated. # # I didn't indent this loop on purpose (to avoid over-indented code) boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \ && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \ && echo .` for boost_inc in $boost_layout_system_search_list do if test x"$boost_inc" != x.; then boost_inc="$boost_dir/$boost_inc" else boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list fi if test x"$boost_inc" != x; then # We are going to check whether the version of Boost installed # in $boost_inc is usable by running a compilation that # #includes it. But if we pass a -I/some/path in which Boost # is not installed, the compiler will just skip this -I and # use other locations (either from CPPFLAGS, or from its list # of system include directories). As a result we would use # header installed on the machine instead of the /some/path # specified by the user. So in that precise case (trying # $boost_inc), make sure the version.hpp exists. # # Use test -e as there can be symlinks. test -e "$boost_inc/boost/version.hpp" || continue CPPFLAGS="$CPPFLAGS -I$boost_inc" fi AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no]) if test x"$boost_cv_inc_path" = xyes; then if test x"$boost_inc" != x; then boost_cv_inc_path=$boost_inc fi break 2 fi done done AC_LANG_POP([C++])dnl ]) case $boost_cv_inc_path in #( no) boost_errmsg="cannot find Boost headers version >= $boost_version_req_string" m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])], [AC_MSG_NOTICE([$boost_errmsg])]) $2 ;;#( yes) BOOST_CPPFLAGS= ;;#( *) AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl ;; esac if test x"$boost_cv_inc_path" != xno; then AC_DEFINE([HAVE_BOOST], [1], [Defined if the requested minimum BOOST version is satisfied]) AC_CACHE_CHECK([for Boost's header version], [boost_cv_lib_version], [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;q;}], [#include boost-lib-version = BOOST_LIB_VERSION], [boost_cv_lib_version=`cat conftest.i`])]) # e.g. "134" for 1_34_1 or "135" for 1_35 boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'` case $boost_major_version in #( '' | *[[!0-9]]*) AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version]) ;; esac fi CPPFLAGS=$boost_save_CPPFLAGS ])# BOOST_REQUIRE # BOOST_STATIC() # -------------- # Add the "--enable-static-boost" configure argument. If this argument is given # on the command line, static versions of the libraries will be looked up. AC_DEFUN([BOOST_STATIC], [AC_ARG_ENABLE([static-boost], [AS_HELP_STRING([--enable-static-boost], [Prefer the static boost libraries over the shared ones [no]])], [enable_static_boost=yes], [enable_static_boost=no])])# BOOST_STATIC # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND]) # -------------------------------------------------------------------------- # Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for # some parts of the Boost library which are only made of headers and don't # require linking (such as Boost.Foreach). # # Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be # found in the first place, in which case by default a notice is issued to the # user. Presumably if we haven't died already it's because it's OK to not have # Boost, which is why only a notice is issued instead of a hard error. # # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_ in # case of success # (where HEADER-NAME is written LIKE_THIS, e.g., # HAVE_BOOST_FOREACH_HPP). AC_DEFUN([BOOST_FIND_HEADER], [AC_REQUIRE([BOOST_REQUIRE])dnl if test x"$boost_cv_inc_path" = xno; then m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])]) else AC_LANG_PUSH([C++])dnl boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" AC_CHECK_HEADER([$1], [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1], [Define to 1 if you have <$1>])])], [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])]) CPPFLAGS=$boost_save_CPPFLAGS AC_LANG_POP([C++])dnl fi ])# BOOST_FIND_HEADER # BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], # [CXX-PROLOGUE]) # ------------------------------------------------------------------------- # Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for # libboost_thread). Check that HEADER-NAME works and check that # libboost_LIB-NAME can link with the code CXX-TEST. The optional argument # CXX-PROLOGUE can be used to include some C++ code before the `main' # function. # # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above). # # Boost libraries typically come compiled with several flavors (with different # runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one # or more of the following letters: sgdpn (in that order). s = static # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build, # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n' # must always be used along with `p'). Additionally, PREFERRED-RT-OPT can # start with `mt-' to indicate that there is a preference for multi-thread # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp # ... If you want to make sure you have a specific version of Boost # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro. AC_DEFUN([BOOST_FIND_LIB], [AC_REQUIRE([BOOST_REQUIRE])dnl AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl AC_REQUIRE([BOOST_STATIC])dnl AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl if test x"$boost_cv_inc_path" = xno; then AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library]) else dnl The else branch is huge and wasn't intended on purpose. AC_LANG_PUSH([C++])dnl AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl BOOST_FIND_HEADER([$3]) boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" # Now let's try to find the library. The algorithm is as follows: first look # for a given library name according to the user's PREFERRED-RT-OPT. For each # library name, we prefer to use the ones that carry the tag (toolset name). # Each library is searched through the various standard paths were Boost is # usually installed. If we can't find the standard variants, we try to # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist # but there's -obviously- libboost_threads-mt.dylib). AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib], [Boost_lib=no case "$2" in #( mt | mt-) boost_mt=-mt; boost_rtopt=;; #( mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #( *) boost_mt=; boost_rtopt=$2;; esac if test $enable_static_boost = yes; then boost_rtopt="s$boost_rtopt" fi # Find the proper debug variant depending on what we've been asked to find. case $boost_rtopt in #( *d*) boost_rt_d=$boost_rtopt;; #( *[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn') boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( *) boost_rt_d='-d';; esac # If the PREFERRED-RT-OPT are not empty, prepend a `-'. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" $boost_guess_use_mt && boost_mt=-mt # Look for the abs path the static archive. # $libext is computed by Libtool but let's make sure it's non empty. test -z "$libext" && AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?]) boost_save_ac_objext=$ac_objext # Generate the test file. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3> $5], [$4])]) dnl Optimization hacks: compiling C++ is slow, especially with Boost. What dnl we're trying to do here is guess the right combination of link flags dnl (LIBS / LDFLAGS) to use a given library. This can take several dnl iterations before it succeeds and is thus *very* slow. So what we do dnl instead is that we compile the code first (and thus get an object file, dnl typically conftest.o). Then we try various combinations of link flags dnl until we succeed to link conftest.o in an executable. The problem is dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always dnl remove all the temporary files including conftest.o. So the trick here dnl is to temporarily change the value of ac_objext so that conftest.o is dnl preserved accross tests. This is obviously fragile and I will burn in dnl hell for not respecting Autoconf's documented interfaces, but in the dnl mean time, it optimizes the macro by a factor of 5 to 30. dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left dnl empty because the test file is generated only once above (before we dnl start the for loops). AC_COMPILE_IFELSE([], [ac_objext=do_not_rm_me_plz], [AC_MSG_ERROR([cannot compile a test that uses Boost $1])]) ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to ident the 6 nested for loops, only the 2 innermost ones # matter. for boost_tag_ in -$boost_cv_lib_tag ''; do for boost_ver_ in -$boost_cv_lib_version ''; do for boost_mt_ in $boost_mt -mt ''; do for boost_rtopt_ in $boost_rtopt '' -d; do for boost_lib in \ boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \ boost_$1$boost_tag_$boost_mt_$boost_ver_ \ boost_$1$boost_tag_$boost_ver_ do # Avoid testing twice the same lib case $boost_failed_libs in #( *@$boost_lib@*) continue;; esac # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. boost_tmp_lib=$with_boost test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} for boost_ldpath in "$boost_tmp_lib/lib" '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ "$with_boost" C:/Boost/lib /lib* do test -n "$boost_ldpath" -a ! -e "$boost_ldpath" && continue boost_save_LDFLAGS=$LDFLAGS # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$Boost_lib_LIBS" || continue;; #( *) # No: use -lboost_foo to find the shared library. Boost_lib_LIBS="-l$boost_lib";; esac boost_save_LIBS=$LIBS LIBS="$Boost_lib_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" dnl First argument of AC_LINK_IFELSE left empty because the test file is dnl generated only once above (before we start the for loops). _BOOST_AC_LINK_IFELSE([], [Boost_lib=yes], [Boost_lib=no]) ac_objext=$boost_save_ac_objext LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$Boost_lib" = xyes; then # Check or used cached result of whether or not using -R or -rpath makes sense. # Some implementations of ld, such as for Mac OSX, require -rpath but # -R is the flag known to work on other systems. # https://github.com/tsuna/boost.m4/issues/19 AC_CACHE_VAL([boost_cv_rpath_link_ldflag], [for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do test x"$boost_ldpath" != x && LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" LIBS="$boost_save_LIBS $Boost_lib_LIBS" _BOOST_AC_LINK_IFELSE([], [boost_rpath_link_ldflag_found=yes break], [boost_rpath_link_ldflag_found=no]) done AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"], [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])]) LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS ]) test x"$boost_ldpath" != x && Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" Boost_lib_LDPATH="$boost_ldpath" break 6 else boost_failed_libs="$boost_failed_libs@$boost_lib@" fi done done done done done done rm -f conftest.$ac_objext ]) case $Boost_lib in #( no) _AC_MSG_LOG_CONFTEST AC_MSG_ERROR([cannot find the flags to link with Boost $1]) ;; esac AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl CPPFLAGS=$boost_save_CPPFLAGS AS_VAR_POPDEF([Boost_lib])dnl AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl AS_VAR_POPDEF([Boost_lib_LDPATH])dnl AS_VAR_POPDEF([Boost_lib_LIBS])dnl AC_LANG_POP([C++])dnl fi ])# BOOST_FIND_LIB # --------------------------------------- # # Checks for the various Boost libraries. # # --------------------------------------- # # List of boost libraries: http://www.boost.org/libs/libraries.htm # The page http://beta.boost.org/doc/libs is useful: it gives the first release # version of each library (among other things). # BOOST_DEFUN(LIBRARY, CODE) # -------------------------- # Define BOOST_ as a macro that runs CODE. # # Use indir to avoid the warning on underquoted macro name given to AC_DEFUN. m4_define([BOOST_DEFUN], [m4_indir([AC_DEFUN], m4_toupper([BOOST_$1]), [m4_pushdef([BOOST_Library], [$1])dnl $2 m4_popdef([BOOST_Library])dnl ]) ]) # BOOST_ARRAY() # ------------- # Look for Boost.Array BOOST_DEFUN([Array], [BOOST_FIND_HEADER([boost/array.hpp])]) # BOOST_ASIO() # ------------ # Look for Boost.Asio (new in Boost 1.35). BOOST_DEFUN([Asio], [AC_REQUIRE([BOOST_SYSTEM])dnl BOOST_FIND_HEADER([boost/asio.hpp])]) # BOOST_BIND() # ------------ # Look for Boost.Bind BOOST_DEFUN([Bind], [BOOST_FIND_HEADER([boost/bind.hpp])]) # BOOST_CHRONO() # ------------------ # Look for Boost.Chrono BOOST_DEFUN([Chrono], [# Do we have to check for Boost.System? This link-time dependency was # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([chrono], [$1], [boost/chrono.hpp], [boost::chrono::thread_clock d;]) if test $enable_static_boost = yes && test $boost_major_version -ge 135; then AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"]) fi LIBS=$boost_filesystem_save_LIBS LDFLAGS=$boost_filesystem_save_LDFLAGS ])# BOOST_CHRONO # BOOST_CONVERSION() # ------------------ # Look for Boost.Conversion (cast / lexical_cast) BOOST_DEFUN([Conversion], [BOOST_FIND_HEADER([boost/cast.hpp]) BOOST_FIND_HEADER([boost/lexical_cast.hpp]) ])# BOOST_CONVERSION # BOOST_CRC() # ----------- # Look for Boost.CRC BOOST_DEFUN([CRC], [BOOST_FIND_HEADER([boost/crc.hpp]) ])# BOOST_CRC # BOOST_DATE_TIME([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Date_Time], [BOOST_FIND_LIB([date_time], [$1], [boost/date_time/posix_time/posix_time.hpp], [boost::posix_time::ptime t;]) ])# BOOST_DATE_TIME # BOOST_FILESYSTEM([PREFERRED-RT-OPT]) # ------------------------------------ # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. # Do not check for boost/filesystem.hpp because this file was introduced in # 1.34. BOOST_DEFUN([Filesystem], [# Do we have to check for Boost.System? This link-time dependency was # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([filesystem], [$1], [boost/filesystem/path.hpp], [boost::filesystem::path p;]) if test $enable_static_boost = yes && test $boost_major_version -ge 135; then AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"]) fi LIBS=$boost_filesystem_save_LIBS LDFLAGS=$boost_filesystem_save_LDFLAGS ])# BOOST_FILESYSTEM # BOOST_FOREACH() # --------------- # Look for Boost.Foreach BOOST_DEFUN([Foreach], [BOOST_FIND_HEADER([boost/foreach.hpp])]) # BOOST_FORMAT() # -------------- # Look for Boost.Format # Note: we can't check for boost/format/format_fwd.hpp because the header isn't # standalone. It can't be compiled because it triggers the following error: # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std' # does not name a type BOOST_DEFUN([Format], [BOOST_FIND_HEADER([boost/format.hpp])]) # BOOST_FUNCTION() # ---------------- # Look for Boost.Function BOOST_DEFUN([Function], [BOOST_FIND_HEADER([boost/function.hpp])]) # BOOST_GEOMETRY() # ---------------- # Look for Boost.Geometry (new since 1.47.0). BOOST_DEFUN([Geometry], [BOOST_FIND_HEADER([boost/geometry.hpp]) ])# BOOST_GEOMETRY # BOOST_GRAPH([PREFERRED-RT-OPT]) # ------------------------------- # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Graph], [BOOST_FIND_LIB([graph], [$1], [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;]) ])# BOOST_GRAPH # BOOST_IOSTREAMS([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([IOStreams], [BOOST_FIND_LIB([iostreams], [$1], [boost/iostreams/device/file_descriptor.hpp], [boost::iostreams::file_descriptor fd; fd.close();]) ])# BOOST_IOSTREAMS # BOOST_HASH() # ------------ # Look for Boost.Functional/Hash BOOST_DEFUN([Hash], [BOOST_FIND_HEADER([boost/functional/hash.hpp])]) # BOOST_LAMBDA() # -------------- # Look for Boost.Lambda BOOST_DEFUN([Lambda], [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])]) # BOOST_LOG([PREFERRED-RT-OPT]) # ----------------------------- # Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Log], [BOOST_FIND_LIB([log], [$1], [boost/log/core/core.hpp], [boost::log::attribute a; a.get_value();]) ])# BOOST_LOG # BOOST_LOG_SETUP([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Log_Setup], [AC_REQUIRE([BOOST_LOG])dnl BOOST_FIND_LIB([log_setup], [$1], [boost/log/utility/init/from_settings.hpp], [boost::log::basic_settings bs; bs.empty();]) ])# BOOST_LOG_SETUP # BOOST_MATH() # ------------ # Look for Boost.Math # TODO: This library isn't header-only but it comes in multiple different # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99, # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1, # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the # right thing anyway. BOOST_DEFUN([Math], [BOOST_FIND_HEADER([boost/math/special_functions.hpp])]) # BOOST_MULTIARRAY() # ------------------ # Look for Boost.MultiArray BOOST_DEFUN([MultiArray], [BOOST_FIND_HEADER([boost/multi_array.hpp])]) # BOOST_NUMERIC_CONVERSION() # -------------------------- # Look for Boost.NumericConversion (policy-based numeric conversion) BOOST_DEFUN([Numeric_Conversion], [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp]) ])# BOOST_NUMERIC_CONVERSION # BOOST_OPTIONAL() # ---------------- # Look for Boost.Optional BOOST_DEFUN([Optional], [BOOST_FIND_HEADER([boost/optional.hpp])]) # BOOST_PREPROCESSOR() # -------------------- # Look for Boost.Preprocessor BOOST_DEFUN([Preprocessor], [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])]) # BOOST_UNORDERED() # ----------------- # Look for Boost.Unordered BOOST_DEFUN([Unordered], [BOOST_FIND_HEADER([boost/unordered_map.hpp])]) # BOOST_UUID() # ------------ # Look for Boost.Uuid BOOST_DEFUN([Uuid], [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])]) # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT]) # ----------------------------------------- # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Program_Options], [BOOST_FIND_LIB([program_options], [$1], [boost/program_options.hpp], [boost::program_options::options_description d("test");]) ])# BOOST_PROGRAM_OPTIONS # _BOOST_PYTHON_CONFIG(VARIABLE, FLAG) # ------------------------------------ # Save VARIABLE, and define it via `python-config --FLAG`. # Substitute BOOST_PYTHON_VARIABLE. m4_define([_BOOST_PYTHON_CONFIG], [AC_SUBST([BOOST_PYTHON_$1], [`python-config --$2 2>/dev/null`])dnl boost_python_save_$1=$$1 $1="$$1 $BOOST_PYTHON_$1"]) # BOOST_PYTHON([PREFERRED-RT-OPT]) # -------------------------------- # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Python], [_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes]) _BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags]) _BOOST_PYTHON_CONFIG([LIBS], [libs]) m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl BOOST_FIND_LIB([python], [$1], [boost/python.hpp], [], [BOOST_PYTHON_MODULE(empty) {}]) CPPFLAGS=$boost_python_save_CPPFLAGS LDFLAGS=$boost_python_save_LDFLAGS LIBS=$boost_python_save_LIBS ])# BOOST_PYTHON # BOOST_REF() # ----------- # Look for Boost.Ref BOOST_DEFUN([Ref], [BOOST_FIND_HEADER([boost/ref.hpp])]) # BOOST_REGEX([PREFERRED-RT-OPT]) # ------------------------------- # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Regex], [BOOST_FIND_LIB([regex], [$1], [boost/regex.hpp], [boost::regex exp("*"); boost::regex_match("foo", exp);]) ])# BOOST_REGEX # BOOST_SERIALIZATION([PREFERRED-RT-OPT]) # --------------------------------------- # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Serialization], [BOOST_FIND_LIB([serialization], [$1], [boost/archive/text_oarchive.hpp], [std::ostream* o = 0; // Cheap way to get an ostream... boost::archive::text_oarchive t(*o);]) ])# BOOST_SERIALIZATION # BOOST_SIGNALS([PREFERRED-RT-OPT]) # --------------------------------- # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Signals], [BOOST_FIND_LIB([signals], [$1], [boost/signal.hpp], [boost::signal s;]) ])# BOOST_SIGNALS # BOOST_SIGNALS2() # ---------------- # Look for Boost.Signals2 (new since 1.39.0). BOOST_DEFUN([Signals2], [BOOST_FIND_HEADER([boost/signals2.hpp]) ])# BOOST_SIGNALS2 # BOOST_SMART_PTR() # ----------------- # Look for Boost.SmartPtr BOOST_DEFUN([Smart_Ptr], [BOOST_FIND_HEADER([boost/scoped_ptr.hpp]) BOOST_FIND_HEADER([boost/shared_ptr.hpp]) ]) # BOOST_STATICASSERT() # -------------------- # Look for Boost.StaticAssert BOOST_DEFUN([StaticAssert], [BOOST_FIND_HEADER([boost/static_assert.hpp])]) # BOOST_STRING_ALGO() # ------------------- # Look for Boost.StringAlgo BOOST_DEFUN([String_Algo], [BOOST_FIND_HEADER([boost/algorithm/string.hpp]) ]) # BOOST_SYSTEM([PREFERRED-RT-OPT]) # -------------------------------- # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. This library was introduced in Boost # 1.35.0. BOOST_DEFUN([System], [BOOST_FIND_LIB([system], [$1], [boost/system/error_code.hpp], [boost::system::error_code e; e.clear();]) ])# BOOST_SYSTEM # BOOST_TEST([PREFERRED-RT-OPT]) # ------------------------------ # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Test], [m4_pattern_allow([^BOOST_CHECK$])dnl BOOST_FIND_LIB([unit_test_framework], [$1], [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);], [using boost::unit_test::test_suite; test_suite* init_unit_test_suite(int argc, char ** argv) { return NULL; }]) ])# BOOST_TEST # BOOST_THREADS([PREFERRED-RT-OPT]) # --------------------------------- # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. # FIXME: Provide an alias "BOOST_THREAD". BOOST_DEFUN([Threads], [dnl Having the pthread flag is required at least on GCC3 where dnl boost/thread.hpp would complain if we try to compile without dnl -pthread on GNU/Linux. AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl boost_threads_save_LIBS=$LIBS boost_threads_save_LDFLAGS=$LDFLAGS boost_threads_save_CPPFLAGS=$CPPFLAGS # Link-time dependency from thread to system was added as of 1.49.0. if test $boost_major_version -ge 149; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3, # boost/thread.hpp will trigger a #error if -pthread isn't used: # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support # is not turned on. Please set the correct command line options for # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag" # When compiling for the Windows platform, the threads library is named # differently. case $host_os in (*mingw*) BOOST_FIND_LIB([thread_win32], [$1], [boost/thread.hpp], [boost::thread t; boost::mutex m;]) BOOST_THREAD_LDFLAGS=$BOOST_THREAD_WIN32_LDFLAGS BOOST_THREAD_LDPATH=$BOOST_THREAD_WIN32_LDPATH BOOST_THREAD_LIBS=$BOOST_THREAD_WIN32_LIBS ;; (*) BOOST_FIND_LIB([thread], [$1], [boost/thread.hpp], [boost::thread t; boost::mutex m;]) ;; esac BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS" BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag" LIBS=$boost_threads_save_LIBS LDFLAGS=$boost_threads_save_LDFLAGS CPPFLAGS=$boost_threads_save_CPPFLAGS ])# BOOST_THREADS # BOOST_TOKENIZER() # ----------------- # Look for Boost.Tokenizer BOOST_DEFUN([Tokenizer], [BOOST_FIND_HEADER([boost/tokenizer.hpp])]) # BOOST_TRIBOOL() # --------------- # Look for Boost.Tribool BOOST_DEFUN([Tribool], [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp]) BOOST_FIND_HEADER([boost/logic/tribool.hpp]) ]) # BOOST_TUPLE() # ------------- # Look for Boost.Tuple BOOST_DEFUN([Tuple], [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])]) # BOOST_TYPETRAITS() # -------------------- # Look for Boost.TypeTraits BOOST_DEFUN([TypeTraits], [BOOST_FIND_HEADER([boost/type_traits.hpp])]) # BOOST_UTILITY() # --------------- # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom, # etc.) BOOST_DEFUN([Utility], [BOOST_FIND_HEADER([boost/utility.hpp])]) # BOOST_VARIANT() # --------------- # Look for Boost.Variant. BOOST_DEFUN([Variant], [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp]) BOOST_FIND_HEADER([boost/variant.hpp])]) # BOOST_POINTERCONTAINER() # ------------------------ # Look for Boost.PointerContainer BOOST_DEFUN([Pointer_Container], [BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp]) ])# BOOST_POINTERCONTAINER # BOOST_WAVE([PREFERRED-RT-OPT]) # ------------------------------ # NOTE: If you intend to use Wave/Spirit with thread support, make sure you # call BOOST_THREADS first. # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Wave], [AC_REQUIRE([BOOST_FILESYSTEM])dnl AC_REQUIRE([BOOST_DATE_TIME])dnl boost_wave_save_LIBS=$LIBS boost_wave_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \ $BOOST_THREAD_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \ $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS" BOOST_FIND_LIB([wave], [$1], [boost/wave.hpp], [boost::wave::token_id id; get_token_name(id);]) LIBS=$boost_wave_save_LIBS LDFLAGS=$boost_wave_save_LDFLAGS ])# BOOST_WAVE # BOOST_XPRESSIVE() # ----------------- # Look for Boost.Xpressive (new since 1.36.0). BOOST_DEFUN([Xpressive], [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])]) # ----------------- # # Internal helpers. # # ----------------- # # _BOOST_PTHREAD_FLAG() # --------------------- # Internal helper for BOOST_THREADS. Based on ACX_PTHREAD: # http://autoconf-archive.cryp.to/acx_pthread.html AC_DEFUN([_BOOST_PTHREAD_FLAG], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_LANG_PUSH([C++])dnl AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag], [ boost_cv_pthread_flag= # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # (none): in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -lpthreads: AIX (must check this before -lpthread) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads) # -pthreads: Solaris/GCC # -mthreads: MinGW32/GCC, Lynx/GCC # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # -lpthread: GNU Linux, etc. # --thread-safe: KAI C++ case $host_os in #( *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #( *) boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \ -pthreads -mthreads -lpthread --thread-safe -mt";; esac # Generate the test file. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0);])]) for boost_pthread_flag in '' $boost_pthread_flags; do boost_pthread_ok=false dnl Re-use the test file already generated. boost_pthreads__save_LIBS=$LIBS LIBS="$LIBS $boost_pthread_flag" AC_LINK_IFELSE([], [if grep ".*$boost_pthread_flag" conftest.err; then echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD else boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag fi]) LIBS=$boost_pthreads__save_LIBS $boost_pthread_ok && break done ]) AC_LANG_POP([C++])dnl ])# _BOOST_PTHREAD_FLAG # _BOOST_gcc_test(MAJOR, MINOR) # ----------------------------- # Internal helper for _BOOST_FIND_COMPILER_TAG. m4_define([_BOOST_gcc_test], ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl # _BOOST_FIND_COMPILER_TAG() # -------------------------- # Internal. When Boost is installed without --layout=system, each library # filename will hold a suffix that encodes the compiler used during the # build. The Boost build system seems to call this a `tag'. AC_DEFUN([_BOOST_FIND_COMPILER_TAG], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag], [boost_cv_lib_tag=unknown if test x$boost_cv_inc_path != xno; then AC_LANG_PUSH([C++])dnl # The following tests are mostly inspired by boost/config/auto_link.hpp # The list is sorted to most recent/common to oldest compiler (in order # to increase the likelihood of finding the right compiler with the # least number of compilation attempt). # Beware that some tests are sensible to the order (for instance, we must # look for MinGW before looking for GCC3). # I used one compilation test per compiler with a #error to recognize # each compiler so that it works even when cross-compiling (let me know # if you know a better approach). # Known missing tags (known from Boost's tools/build/v2/tools/common.jam): # como, edg, kcc, bck, mp, sw, tru, xlc # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines # the same defines as GCC's). for i in \ _BOOST_gcc_test(4, 8) \ _BOOST_gcc_test(4, 7) \ _BOOST_gcc_test(4, 6) \ _BOOST_gcc_test(4, 5) \ _BOOST_gcc_test(4, 4) \ _BOOST_gcc_test(4, 3) \ _BOOST_gcc_test(4, 2) \ _BOOST_gcc_test(4, 1) \ _BOOST_gcc_test(4, 0) \ "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \ && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \ _BOOST_gcc_test(3, 4) \ _BOOST_gcc_test(3, 3) \ "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \ "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \ _BOOST_gcc_test(3, 2) \ "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \ _BOOST_gcc_test(3, 1) \ _BOOST_gcc_test(3, 0) \ "defined __BORLANDC__ @ bcb" \ "defined __ICC && (defined __unix || defined __unix__) @ il" \ "defined __ICL @ iw" \ "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \ _BOOST_gcc_test(2, 95) \ "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \ "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \ "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \ "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8" do boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '` boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if $boost_tag_test /* OK */ #else # error $boost_tag_test #endif ]])], [boost_cv_lib_tag=$boost_tag; break], []) done AC_LANG_POP([C++])dnl case $boost_cv_lib_tag in #( # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed # to "gcc41" for instance. *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there. gcc*) boost_tag_x= case $host_os in #( darwin*) if test $boost_major_version -ge 136; then # The `x' added in r46793 of Boost. boost_tag_x=x fi;; esac # We can specify multiple tags in this variable because it's used by # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ... boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc" ;; #( unknown) AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]]) boost_cv_lib_tag= ;; esac fi])dnl end of AC_CACHE_CHECK ])# _BOOST_FIND_COMPILER_TAG # _BOOST_GUESS_WHETHER_TO_USE_MT() # -------------------------------- # Compile a small test to try to guess whether we should favor MT (Multi # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly. AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT], [# Check whether we do better use `mt' even though we weren't ask to. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if defined _REENTRANT || defined _MT || defined __MT__ /* use -mt */ #else # error MT not needed #endif ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false]) ]) # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # ------------------------------------------------------------------- # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile, # will break when Autoconf changes its internals. Requires that you manually # rm -f conftest.$ac_objext in between to really different tests, otherwise # you will try to link a conftest.o left behind by a previous test. # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this # macro). # # Don't use "break" in the actions, as it would short-circuit some code # this macro runs after the actions. m4_define([_BOOST_AC_LINK_IFELSE], [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && _AS_ECHO_LOG([re-using the existing conftest.$ac_objext]) AS_IF([_AC_DO_STDERR($ac_link) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough. }], [$2], [if $boost_use_source; then _AC_MSG_LOG_CONFTEST fi $3]) ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), dnl as it would interfere with the next link command. rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl ])# _BOOST_AC_LINK_IFELSE # Local Variables: # mode: autoconf # End: pdns-3.3/m4/ltsugar.m40000644000014601777760000001042412165464021016030 0ustar00jenkinsnogroup00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # 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. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) pdns-3.3/pdns/0000755000014601777760000000000012165464055014537 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/arguments.cc0000644000014601777760000002573012145356404017056 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "arguments.hh" #include #include #include #include "namespaces.hh" #include "logger.hh" #include #include #include #include const ArgvMap::param_t::const_iterator ArgvMap::begin() { return params.begin(); } const ArgvMap::param_t::const_iterator ArgvMap::end() { return params.end(); } string & ArgvMap::set(const string &var) { return params[var]; } bool ArgvMap::mustDo(const string &var) { return ((*this)[var]!="no") && ((*this)[var]!="off"); } vectorArgvMap::list() { vector ret; for(map::const_iterator i=params.begin();i!=params.end();++i) ret.push_back(i->first); return ret; } string ArgvMap::getHelp(const string &item) { return helpmap[item]; } string & ArgvMap::set(const string &var, const string &help) { helpmap[var]=help; d_typeMap[var]="Parameter"; return set(var); } void ArgvMap::setCmd(const string &var, const string &help) { helpmap[var]=help; d_typeMap[var]="Command"; set(var)="no"; } string & ArgvMap::setSwitch(const string &var, const string &help) { helpmap[var]=help; d_typeMap[var]="Switch"; return set(var); } bool ArgvMap::contains(const string &var, const string &val) { params_t::const_iterator param = params.find(var); if(param == params.end() || param->second.empty()) { return false; } vector parts; vector::const_iterator i; stringtok( parts, param->second, ", \t" ); for( i = parts.begin(); i != parts.end(); i++ ) { if( *i == val ) { return true; } } return false; } string ArgvMap::helpstring(string prefix) { if(prefix=="no") prefix=""; string help; for(map::const_iterator i=helpmap.begin(); i!=helpmap.end(); i++) { if(!prefix.empty() && i->first.find(prefix)) // only print items with prefix continue; help+=" --"; help+=i->first; string type=d_typeMap[i->first]; if(type=="Parameter") help+="=..."; else if(type=="Switch") { help+=" | --"+i->first+"=yes"; help+=" | --"+i->first+"=no"; } help+="\n\t"; help+=i->second; help+="\n"; } return help; } string ArgvMap::configstring() { string help; help="# Autogenerated configuration file template\n"; for(map::const_iterator i=helpmap.begin(); i!=helpmap.end(); i++) { if(d_typeMap[i->first]=="Command") continue; help+="#################################\n"; help+="# "; help+=i->first; help+="\t"; help+=i->second; help+="\n#\n"; help+="# "+i->first+"="+params[i->first]+"\n\n"; } return help; } const string & ArgvMap::operator[](const string &arg) { if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); return params[arg]; } #ifndef WIN32 mode_t ArgvMap::asMode(const string &arg) { mode_t mode; const char *cptr_orig; char *cptr_ret = NULL; if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); cptr_orig = params[arg].c_str(); mode = static_cast(strtol(cptr_orig, &cptr_ret, 8)); if (mode == 0 && cptr_ret == cptr_orig) throw ArgException("'" + arg + string("' contains invalid octal mode")); return mode; } gid_t ArgvMap::asGid(const string &arg) { gid_t gid; const char *cptr_orig; char *cptr_ret = NULL; if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); cptr_orig = params[arg].c_str(); gid = static_cast(strtol(cptr_orig, &cptr_ret, 0)); if (gid == 0 && cptr_ret == cptr_orig) { // try to resolve struct group *group = getgrnam(params[arg].c_str()); if (group == NULL) throw ArgException("'" + arg + string("' contains invalid group")); gid = group->gr_gid; } return gid; } uid_t ArgvMap::asUid(const string &arg) { uid_t uid; const char *cptr_orig; char *cptr_ret = NULL; if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); cptr_orig = params[arg].c_str(); uid = static_cast(strtol(cptr_orig, &cptr_ret, 0)); if (uid == 0 && cptr_ret == cptr_orig) { // try to resolve struct passwd *pwent = getpwnam(params[arg].c_str()); if (pwent == NULL) throw ArgException("'" + arg + string("' contains invalid group")); uid = pwent->pw_uid; } return uid; } #endif int ArgvMap::asNum(const string &arg) { int retval; const char *cptr_orig; char *cptr_ret = NULL; if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); // treat empty values as zeros if (params[arg].empty()) return 0; cptr_orig = params[arg].c_str(); retval = static_cast(strtol(cptr_orig, &cptr_ret, 0)); if (!retval && cptr_ret == cptr_orig) throw ArgException("'"+arg+string("' is not valid number")); return retval; } bool ArgvMap::isEmpty(const string &arg) { if(!parmIsset(arg)) return true; return params[arg].empty(); } double ArgvMap::asDouble(const string &arg) { double retval; const char *cptr_orig; char *cptr_ret = NULL; if(!parmIsset(arg)) throw ArgException(string("Undefined but needed argument: '")+arg+"'"); if (params[arg].empty()) return 0.0; cptr_orig = params[arg].c_str(); retval = strtod(cptr_orig, &cptr_ret); if (retval == 0 && cptr_ret == cptr_orig) throw ArgException("'"+arg+string("' is not valid double")); return retval; } ArgvMap::ArgvMap() { } bool ArgvMap::parmIsset(const string &var) { return (params.find(var)!=params.end()); } void ArgvMap::parseOne(const string &arg, const string &parseOnly, bool lax) { string var, val; string::size_type pos; if(!arg.find("--") &&(pos=arg.find("="))!=string::npos) // this is a --port=25 case { var=arg.substr(2,pos-2); val=arg.substr(pos+1); } else if(!arg.find("--") && (arg.find("=")==string::npos)) // this is a --daemon case { var=arg.substr(2); val=""; } else if(arg[0]=='-') { var=arg.substr(1); val=""; } else { // command d_cmds.push_back(arg); } if(var!="" && (parseOnly.empty() || var==parseOnly)) { pos=val.find_first_not_of(" \t"); // strip leading whitespace if(pos && pos!=string::npos) val=val.substr(pos); if(parmIsset(var)) params[var]=val; else if(!lax) throw ArgException("Trying to set unexisting parameter '"+var+"'"); } } const vector&ArgvMap::getCommands() { return d_cmds; } void ArgvMap::parse(int &argc, char **argv, bool lax) { d_cmds.clear(); for(int n=1;nd_name[0] == '.') continue; // skip any dots if (boost::ends_with(ent->d_name, ".conf")) { // ensure it's readable file snprintf(namebuf, sizeof namebuf, "%s/%s", params["include-dir"].c_str(), ent->d_name); if (stat(namebuf, &st) || !S_ISREG(st.st_mode)) { L << Logger::Error << namebuf << " is not a file" << std::endl; throw ArgException(std::string(namebuf) + " does not exist!"); } if (!file(namebuf, lax, true)) L << Logger::Warning << namebuf << " could not be read - skipping" << std::endl; } } } return true; } pdns-3.3/pdns/tcpreceiver.cc0000644000014601777760000007356412165337676017410 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include "dnssecinfra.hh" #include "dnsseckeeper.hh" #include #include "base32.hh" #include #include #include #include #include #include "tcpreceiver.hh" #include "sstuff.hh" #include #include #include #include "base64.hh" #include "ueberbackend.hh" #include "dnspacket.hh" #include "nameserver.hh" #include "distributor.hh" #include "lock.hh" #include "logger.hh" #include "arguments.hh" #include "packethandler.hh" #include "statbag.hh" #include "resolver.hh" #include "communicator.hh" #include "namespaces.hh" #include "signingpipe.hh" extern PacketCache PC; extern StatBag S; /** \file tcpreceiver.cc \brief This file implements the tcpreceiver that receives and answers questions over TCP/IP */ pthread_mutex_t TCPNameserver::s_plock = PTHREAD_MUTEX_INITIALIZER; Semaphore *TCPNameserver::d_connectionroom_sem; PacketHandler *TCPNameserver::s_P; int TCPNameserver::s_timeout; NetmaskGroup TCPNameserver::d_ng; void TCPNameserver::go() { L<(this)); } void *TCPNameserver::launcher(void *data) { static_cast(data)->thread(); return 0; } // throws AhuException if things didn't go according to plan, returns 0 if really 0 bytes were read int readnWithTimeout(int fd, void* buffer, unsigned int n, bool throwOnEOF=true) { unsigned int bytes=n; char *ptr = (char*)buffer; int ret; while(bytes) { ret=read(fd, ptr, bytes); if(ret < 0) { if(errno==EAGAIN) { ret=waitForData(fd, 5); if(ret < 0) throw NetworkError("Waiting for data read"); if(!ret) throw NetworkError("Timeout reading data"); continue; } else throw NetworkError("Reading data: "+stringerror()); } if(!ret) { if(!throwOnEOF && n == bytes) return 0; else throw NetworkError("Did not fulfill read from TCP due to EOF"); } ptr += ret; bytes -= ret; } return n; } // ditto void writenWithTimeout(int fd, const void *buffer, unsigned int n) { unsigned int bytes=n; const char *ptr = (char*)buffer; int ret; while(bytes) { ret=write(fd, ptr, bytes); if(ret < 0) { if(errno==EAGAIN) { ret=waitForRWData(fd, false, 5, 0); if(ret < 0) throw NetworkError("Waiting for data write"); if(!ret) throw NetworkError("Timeout writing data"); continue; } else throw NetworkError("Writing data: "+stringerror()); } if(!ret) { throw NetworkError("Did not fulfill TCP write due to EOF"); } ptr += ret; bytes -= ret; } } void connectWithTimeout(int fd, struct sockaddr* remote, size_t socklen) { int err; Utility::socklen_t len=sizeof(err); #ifndef WIN32 if((err=connect(fd, remote, socklen))<0 && errno!=EINPROGRESS) #else if((err=connect(clisock, remote, socklen))<0 && WSAGetLastError() != WSAEWOULDBLOCK ) #endif // WIN32 throw NetworkError("connect: "+stringerror()); if(!err) goto done; err=waitForRWData(fd, false, 5, 0); if(err == 0) throw NetworkError("Timeout connecting to remote"); if(err < 0) throw NetworkError("Error connecting to remote"); if(getsockopt(fd, SOL_SOCKET,SO_ERROR,(char *)&err,&len)<0) throw NetworkError("Error connecting to remote: "+stringerror()); // Solaris if(err) throw NetworkError("Error connecting to remote: "+string(strerror(err))); done: ; } void TCPNameserver::sendPacket(shared_ptr p, int outsock) { uint16_t len=htons(p->getString().length()); string buffer((const char*)&len, 2); buffer.append(p->getString()); writenWithTimeout(outsock, buffer.c_str(), buffer.length()); } void TCPNameserver::getQuestion(int fd, char *mesg, int pktlen, const ComboAddress &remote) try { readnWithTimeout(fd, mesg, pktlen); } catch(NetworkError& ae) { throw NetworkError("Error reading DNS data from TCP client "+remote.toString()+": "+ae.what()); } static void proxyQuestion(shared_ptr packet) { int sock=socket(AF_INET, SOCK_STREAM, 0); Utility::setCloseOnExec(sock); if(sock < 0) throw NetworkError("Error making TCP connection socket to recursor: "+stringerror()); Utility::setNonBlocking(sock); ServiceTuple st; st.port=53; parseService(::arg()["recursor"],st); try { ComboAddress recursor(st.host, st.port); connectWithTimeout(sock, (struct sockaddr*)&recursor, recursor.getSocklen()); const string &buffer=packet->getString(); uint16_t len=htons(buffer.length()), slen; writenWithTimeout(sock, &len, 2); writenWithTimeout(sock, buffer.c_str(), buffer.length()); readnWithTimeout(sock, &len, 2); len=ntohs(len); char answer[len]; readnWithTimeout(sock, answer, len); slen=htons(len); writenWithTimeout(packet->getSocket(), &slen, 2); writenWithTimeout(packet->getSocket(), answer, len); } catch(NetworkError& ae) { close(sock); throw NetworkError("While proxying a question to recursor "+st.host+": " +ae.what()); } close(sock); return; } void *TCPNameserver::doConnection(void *data) { shared_ptr packet; // Fix gcc-4.0 error (on AMD64) int fd=(int)(long)data; // gotta love C (generates a harmless warning on opteron) pthread_detach(pthread_self()); Utility::setNonBlocking(fd); try { char mesg[512]; DLOG(L<<"TCP Connection accepted on fd "<511) { L<(new DNSPacket); packet->setRemote(&remote); packet->d_tcp=true; packet->setSocket(fd); if(packet->parse(mesg, pktlen)<0) break; if(packet->qtype.getCode()==QType::AXFR || packet->qtype.getCode()==QType::IXFR ) { if(doAXFR(packet->qdomain, packet, fd)) S.inc("tcp-answers"); continue; } shared_ptr reply; shared_ptr cached= shared_ptr(new DNSPacket); if(logDNSQueries) { string remote; if(packet->hasEDNSSubnet()) remote = packet->getRemote() + "<-" + packet->getRealRemote().toString(); else remote = packet->getRemote(); L << Logger::Notice<<"TCP Remote "<< remote <<" wants '" << packet->qdomain<<"|"<qtype.getName() << "', do = " <d_dnssecOk <<", bufsize = "<< packet->getMaxReplyLen()<<": "; } if(!packet->d.rd && packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question? if(logDNSQueries) L<<"packetcache HIT"<setRemote(&packet->d_remote); cached->d.id=packet->d.id; cached->d.rd=packet->d.rd; // copy in recursion desired bit cached->commitD(); // commit d to the packet inlined sendPacket(cached, fd); // presigned, don't do it again S.inc("tcp-answers"); continue; } if(logDNSQueries) L<<"packetcache MISS"<(s_P->questionOrRecurse(packet.get(), &shouldRecurse)); // we really need to ask the backend :-) if(shouldRecurse) { proxyQuestion(packet); continue; } } if(!reply) // unable to write an answer? break; S.inc("tcp-answers"); sendPacket(reply, fd); } } catch(DBException &e) { Lock l(&s_plock); delete s_P; s_P = 0; L<post(); Utility::closesocket(fd); return 0; } // call this method with s_plock held! bool TCPNameserver::canDoAXFR(shared_ptr q) { if(::arg().mustDo("disable-axfr")) return false; if(q->d_havetsig) { // if you have one, it must be good TSIGRecordContent trc; string keyname, secret; if(!checkForCorrectTSIG(q.get(), s_P->getBackend(), &keyname, &secret, &trc)) return false; DNSSECKeeper dk; if(!dk.TSIGGrantsAccess(q->qdomain, keyname, trc.d_algoName)) { L<qdomain<<"' denied: key with name '"<qdomain<<"' allowed: TSIG signed request with authorized key '"<d_remote )) { L<qdomain<<"' allowed: client IP "<getRemote()<<" is in allow-axfr-ips"<getBackend()->getSOA(q->qdomain,sd)) { // cerr<<"got backend and SOA"< acl; B->getDomainMetadata(q->qdomain, "ALLOW-AXFR-FROM", acl); for (vector::const_iterator i = acl.begin(); i != acl.end(); ++i) { // cerr<<"matching against "<<*i< nsset; B->lookup(QType(QType::NS),q->qdomain); while(B->get(rr)) nsset.insert(rr.content); for(set::const_iterator j=nsset.begin();j!=nsset.end();++j) { vector nsips=fns.lookup(*j, B); for(vector::const_iterator k=nsips.begin();k!=nsips.end();++k) { // cerr<<"got "<<*k<<" from AUTO-NS"<getRemote()) { // cerr<<"got AUTO-NS hit"<qdomain<<"' allowed: client IP "<getRemote()<<" is in NSset"<d_remote )) { L<qdomain<<"' allowed: client IP "<getRemote()<<" is in per-domain ACL"<qdomain, q->getRemote())) { // we just notified this ip L<qdomain<<"' from recently notified slave "<getRemote()<qdomain<<"' denied: client IP "<getRemote()<<" has no permission"< d_set; unsigned int d_ttl; bool d_auth; }; DNSResourceRecord makeDNSRRFromSOAData(const SOAData& sd) { DNSResourceRecord soa; soa.qname= sd.qname; soa.qtype=QType::SOA; soa.content=serializeSOAData(sd); soa.ttl=sd.ttl; soa.domain_id=sd.domain_id; soa.auth = true; soa.d_place=DNSResourceRecord::ANSWER; return soa; } shared_ptr getFreshAXFRPacket(shared_ptr q) { shared_ptr ret = shared_ptr(q->replyPacket()); ret->setCompress(false); ret->d_dnssecOk=false; // RFC 5936, 2.2.5 ret->d_tcp = true; return ret; } } /** do the actual zone transfer. Return 0 in case of error, 1 in case of success */ int TCPNameserver::doAXFR(const string &target, shared_ptr q, int outsock) { bool noAXFRBecauseOfNSEC3Narrow=false; NSEC3PARAMRecordContent ns3pr; bool narrow; bool NSEC3Zone=false; DNSSECKeeper dk; dk.clearCaches(target); bool securedZone = dk.isSecuredZone(target); bool presignedZone = dk.isPresigned(target); if(dk.getNSEC3PARAM(target, &ns3pr, &narrow)) { NSEC3Zone=true; if(narrow) { L< outpacket= getFreshAXFRPacket(q); if(q->d_dnssecOk) outpacket->d_dnssecOk=true; // RFC 5936, 2.2.5 'SHOULD' if(noAXFRBecauseOfNSEC3Narrow) { L<getRemote()<setRcode(RCode::Refused); // FIXME: should actually figure out if we are auth over a zone, and send out 9 if we aren't sendPacket(outpacket,outsock); return 0; } L<getRemote()<getBackend()->getSOA(target, sd) || !canDoAXFR(q)) { L<setRcode(9); // 'NOTAUTH' sendPacket(outpacket,outsock); return 0; } } UeberBackend db; sd.db=(DNSBackend *)-1; // force uncached answer if(!db.getSOA(target, sd)) { L<setRcode(9); // 'NOTAUTH' sendPacket(outpacket,outsock); return 0; } if(!sd.db || sd.db==(DNSBackend *)-1) { L<setRcode(RCode::ServFail); sendPacket(outpacket,outsock); return 0; } TSIGRecordContent trc; string tsigkeyname, tsigsecret; q->getTSIGDetails(&trc, &tsigkeyname, 0); if(!tsigkeyname.empty()) { string tsig64, algorithm; Lock l(&s_plock); s_P->getBackend()->getTSIGKey(tsigkeyname, &algorithm, &tsig64); B64Decode(tsig64, tsigsecret); } UeberBackend signatureDB; // SOA *must* go out first, our signing pipe might reorder DLOG(L<<"Sending out SOA"<addRecord(soa); editSOA(dk, sd.qname, outpacket.get()); if(securedZone) { set authSet; authSet.insert(target); addRRSigs(dk, signatureDB, authSet, outpacket->getRRS()); } if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac); // first answer is 'normal' sendPacket(outpacket, outsock); trc.d_mac = outpacket->d_trc.d_mac; outpacket = getFreshAXFRPacket(q); ChunkedSigningPipe csp(target, securedZone, "", ::arg().asNum("signing-threads")); typedef map nsecxrepo_t; nsecxrepo_t nsecxrepo; // this is where the DNSKEYs go in DNSSECKeeper::keyset_t keys = dk.getKeys(target); DNSResourceRecord rr; rr.qname = target; rr.ttl = sd.default_ttl; rr.auth = 1; // please sign! BOOST_FOREACH(const DNSSECKeeper::keyset_t::value_type& value, keys) { rr.qtype = QType(QType::DNSKEY); rr.content = value.first.getDNSKEY().getZoneRepresentation(); string keyname = NSEC3Zone ? hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname) : labelReverse(rr.qname); NSECXEntry& ne = nsecxrepo[keyname]; ne.d_set.insert(rr.qtype.getCode()); ne.d_ttl = sd.default_ttl; csp.submit(rr); } if(::arg().mustDo("experimental-direct-dnskey")) { sd.db->lookup(QType(QType::DNSKEY), target, NULL, sd.domain_id); while(sd.db->get(rr)) { rr.ttl = sd.default_ttl; csp.submit(rr); } } uint8_t flags; if(NSEC3Zone) { // now stuff in the NSEC3PARAM flags = ns3pr.d_flags; rr.qtype = QType(QType::NSEC3PARAM); ns3pr.d_flags = 0; rr.content = ns3pr.getZoneRepresentation(); ns3pr.d_flags = flags; string keyname = hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname); NSECXEntry& ne = nsecxrepo[keyname]; ne.d_set.insert(rr.qtype.getCode()); csp.submit(rr); } // now start list zone if(!(sd.db->list(target, sd.domain_id))) { L<setRcode(2); // 'SERVFAIL' sendPacket(outpacket,outsock); return 0; } /* now write all other records */ string keyname; set ns3rrs; DTime dt; dt.set(); int records=0; while(sd.db->get(rr)) { if (rr.qtype.getCode() == QType::RRSIG) { RRSIGRecordContent rrc(rr.content); if(presignedZone && rrc.d_type == QType::NSEC3) ns3rrs.insert(fromBase32Hex(makeRelative(rr.qname, target))); continue; } // only skip the DNSKEY if direct-dnskey is enabled, to avoid changing behaviour // when it is not enabled. if(::arg().mustDo("experimental-direct-dnskey") && rr.qtype.getCode() == QType::DNSKEY) continue; records++; if(securedZone && (rr.auth || rr.qtype.getCode() == QType::NS)) { if (NSEC3Zone || rr.qtype.getCode()) { keyname = NSEC3Zone ? hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname) : labelReverse(rr.qname); NSECXEntry& ne = nsecxrepo[keyname]; ne.d_ttl = sd.default_ttl; ne.d_auth = (ne.d_auth || rr.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags)))); if (rr.qtype.getCode()) { ne.d_set.insert(rr.qtype.getCode()); } } } if (!rr.qtype.getCode()) continue; // skip empty non-terminals if(rr.qtype.getCode() == QType::SOA) continue; // skip SOA - would indicate end of AXFR if(csp.submit(rr)) { for(;;) { outpacket->getRRS() = csp.getChunk(); if(!outpacket->getRRS().empty()) { if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac, true); sendPacket(outpacket, outsock); trc.d_mac=outpacket->d_trc.d_mac; outpacket=getFreshAXFRPacket(q); } else break; } } } unsigned int udiff=dt.udiffNoReset(); /* cerr<<"Starting NSEC: "<second.d_auth && (!presignedZone || !ns3pr.d_flags || ns3rrs.count(iter->first))) { NSEC3RecordContent n3rc; n3rc.d_set = iter->second.d_set; if (n3rc.d_set.size() && (n3rc.d_set.size() != 1 || !n3rc.d_set.count(QType::NS))) n3rc.d_set.insert(QType::RRSIG); n3rc.d_salt=ns3pr.d_salt; n3rc.d_flags = ns3pr.d_flags; n3rc.d_iterations = ns3pr.d_iterations; n3rc.d_algorithm = 1; // SHA1, fixed in PowerDNS for now nsecxrepo_t::const_iterator inext = iter; inext++; if(inext == nsecxrepo.end()) inext = nsecxrepo.begin(); while((!inext->second.d_auth || (presignedZone && ns3pr.d_flags && !ns3rrs.count(inext->first))) && inext != iter) { inext++; if(inext == nsecxrepo.end()) inext = nsecxrepo.begin(); } n3rc.d_nexthash = inext->first; rr.qname = dotConcat(toLower(toBase32Hex(iter->first)), sd.qname); rr.ttl = sd.default_ttl; rr.content = n3rc.getZoneRepresentation(); rr.qtype = QType::NSEC3; rr.d_place = DNSResourceRecord::ANSWER; rr.auth=true; if(csp.submit(rr)) { for(;;) { outpacket->getRRS() = csp.getChunk(); if(!outpacket->getRRS().empty()) { if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac, true); sendPacket(outpacket, outsock); trc.d_mac=outpacket->d_trc.d_mac; outpacket=getFreshAXFRPacket(q); } else break; } } } } } else for(nsecxrepo_t::const_iterator iter = nsecxrepo.begin(); iter != nsecxrepo.end(); ++iter) { NSECRecordContent nrc; nrc.d_set = iter->second.d_set; nrc.d_set.insert(QType::RRSIG); nrc.d_set.insert(QType::NSEC); if(boost::next(iter) != nsecxrepo.end()) { nrc.d_next = labelReverse(boost::next(iter)->first); } else nrc.d_next=labelReverse(nsecxrepo.begin()->first); rr.qname = labelReverse(iter->first); rr.ttl = sd.default_ttl; rr.content = nrc.getZoneRepresentation(); rr.qtype = QType::NSEC; rr.d_place = DNSResourceRecord::ANSWER; rr.auth=true; if(csp.submit(rr)) { for(;;) { outpacket->getRRS() = csp.getChunk(); if(!outpacket->getRRS().empty()) { if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac, true); sendPacket(outpacket, outsock); trc.d_mac=outpacket->d_trc.d_mac; outpacket=getFreshAXFRPacket(q); } else break; } } } } udiff=dt.udiffNoReset(); /* cerr<<"Flushing pipe: "<getRRS() = csp.getChunk(true); // flush the pipe if(!outpacket->getRRS().empty()) { if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac, true); // first answer is 'normal' sendPacket(outpacket, outsock); trc.d_mac=outpacket->d_trc.d_mac; outpacket=getFreshAXFRPacket(q); } else break; } udiff=dt.udiffNoReset(); if(securedZone) L<addRecord(soa); editSOA(dk, sd.qname, outpacket.get()); if(!tsigkeyname.empty()) outpacket->setTSIGDetails(trc, tsigkeyname, tsigsecret, trc.d_mac, true); sendPacket(outpacket, outsock); DLOG(L<<"last packet - close"<getRemote()<<" finished"<locals; stringtok(locals,::arg()["local-address"]," ,"); vectorlocals6; stringtok(locals6,::arg()["local-ipv6"]," ,"); if(locals.empty() && locals6.empty()) throw AhuException("No local address specified"); vector parts; stringtok( parts, ::arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist? for( vector::const_iterator i = parts.begin(); i != parts.end(); ++i ) { d_ng.addMask( *i ); } #ifndef WIN32 signal(SIGPIPE,SIG_IGN); #endif // WIN32 for(vector::const_iterator laddr=locals.begin();laddr!=locals.end();++laddr) { int s=socket(AF_INET,SOCK_STREAM,0); if(s<0) throw AhuException("Unable to acquire TCP socket: "+stringerror()); Utility::setCloseOnExec(s); ComboAddress local(*laddr, ::arg().asNum("local-port")); int tmp=1; if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { L<::const_iterator laddr=locals6.begin();laddr!=locals6.end();++laddr) { int s=socket(AF_INET6,SOCK_STREAM,0); if(s<0) throw AhuException("Unable to acquire TCPv6 socket: "+stringerror()); Utility::setCloseOnExec(s); ComboAddress local(*laddr, ::arg().asNum("local-port")); int tmp=1; if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { L<wait(); // blocks if no connections are available int room; d_connectionroom_sem->getValue( &room); if(room<1) L<(fd))) { L<post(); } } } } } } catch(AhuException &AE) { L< #include "dnsparser.hh" #include "iputils.hh" #undef L #include #include #include #include #include #include #include "mplexer.hh" #include "statbag.hh" #include "namespaces.hh" using namespace ::boost::multi_index; #include "namespaces.hh" namespace po = boost::program_options; po::variables_map g_vm; StatBag S; int main(int argc, char** argv) try { if(argc!=3) { cerr<<"Syntax: notify ip:port domain"< outpacket; DNSPacketWriter pw(outpacket, argv[2], QType::SOA, 1, Opcode::Notify); pw.getHeader()->id = random(); if(send(sock, &outpacket[0], outpacket.size(), 0) < 0) { throw runtime_error("Unable to send notify to PowerDNS: "+stringerror()); } char buffer[1500]; int len=recv(sock, buffer, sizeof(buffer),0); if(len < 0) throw runtime_error("Unable to receive notification response from PowerDNS: "+stringerror()); string packet(buffer, len); MOADNSParser mdp(packet); cerr<<"Received notification response with code: "< #include #include "namespaces.hh" PcapPacketReader::PcapPacketReader(const string& fname) : d_fname(fname) { d_fp=fopen(fname.c_str(),"r"); if(!d_fp) unixDie("Unable to open file"); int flags=fcntl(fileno(d_fp),F_GETFL,0); fcntl(fileno(d_fp), F_SETFL,flags&(~O_NONBLOCK)); // bsd needs this in stdin (??) checkedFread(&d_pfh); if(d_pfh.magic != 2712847316UL) throw runtime_error((format("PCAP file %s has bad magic %x, should be %x") % fname % d_pfh.magic % 2712847316UL).str()); if( d_pfh.linktype==1) { d_skipMediaHeader=sizeof(struct ether_header); } else if(d_pfh.linktype==113) { d_skipMediaHeader=16; } else throw runtime_error((format("Unsupported link type %d") % d_pfh.linktype).str()); d_runts = d_oversized = d_correctpackets = d_nonetheripudp = 0; } PcapPacketReader::~PcapPacketReader() { fclose(d_fp); } void PcapPacketReader::checkedFreadSize(void* ptr, size_t size) { int ret=fread(ptr, 1, size, d_fp); if(ret < 0) unixDie( (format("Error reading %d bytes from %s") % size % d_fname).str()); if(!ret) throw EofException(); if((size_t)ret != size) throw EofException((format("Incomplete read from '%s', got only %d bytes") % d_fname % ret).str()); } bool PcapPacketReader::getUDPPacket() try { for(;;) { checkedFread(&d_pheader); if(!d_pheader.caplen) continue; if(d_pheader.caplen > sizeof(d_buffer)) { d_oversized++; throw runtime_error((format("Can't handle a %d byte packet, have space for %d") % d_pheader.caplen % sizeof(d_buffer)).str()); } checkedFreadSize(d_buffer, d_pheader.caplen); if(d_pheader.caplen!=d_pheader.len) { d_runts++; continue; } d_ether=reinterpret_cast(d_buffer); d_lcc=reinterpret_cast(d_buffer); d_ip=reinterpret_cast(d_buffer + d_skipMediaHeader); uint16_t contentCode=0; if(d_pfh.linktype==1) contentCode=ntohs(d_ether->ether_type); else if(d_pfh.linktype==113) contentCode=ntohs(d_lcc->lcc_protocol); if(contentCode==0x0800 && d_ip->ip_p==17) { // udp d_udp=reinterpret_cast(d_buffer + d_skipMediaHeader + 4 * d_ip->ip_hl); d_payload = (unsigned char*)d_udp + sizeof(struct udphdr); d_len = ntohs(d_udp->uh_ulen) - sizeof(struct udphdr); d_correctpackets++; return true; } else { d_nonetheripudp++; } } } catch(EofException) { return false; } PcapPacketWriter::PcapPacketWriter(const string& fname, PcapPacketReader& ppr) : d_fname(fname), d_ppr(ppr) { d_fp=fopen(fname.c_str(),"w"); if(!d_fp) unixDie("Unable to open file"); int flags=fcntl(fileno(d_fp),F_GETFL,0); fcntl(fileno(d_fp), F_SETFL,flags&(~O_NONBLOCK)); // bsd needs this in stdin (??) fwrite(&ppr.d_pfh, 1, sizeof(ppr.d_pfh), d_fp); } void PcapPacketWriter::write() { fwrite(&d_ppr.d_pheader, 1, sizeof(d_ppr.d_pheader), d_fp); fwrite(d_ppr.d_buffer, 1, d_ppr.d_pheader.caplen, d_fp); } PcapPacketWriter::~PcapPacketWriter() { fclose(d_fp); } pdns-3.3/pdns/ueberbackend.hh0000644000014601777760000001341012136555572017474 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef UEBERBACKEND_HH #define UEBERBACKEND_HH #include #include #include #include #include #include #ifndef WIN32 #include #include #include #include #include #include #include #include #endif // WIN32 #include #include "dnspacket.hh" #include "dnsbackend.hh" #include "namespaces.hh" class BackendReporter; /** This is a very magic backend that allows us to load modules dynamically, and query them in order. This is persistent over all UeberBackend instantiations across multiple threads. The UeberBackend is transparent for exceptions, which should fall straight through. */ class UeberBackend : public DNSBackend, public boost::noncopyable { public: UeberBackend(const string &pname="default"); ~UeberBackend(); typedef DNSBackend *BackendMaker(); //!< typedef for functions returning pointers to new backends bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db); /** contains BackendReporter objects, which contain maker functions and information about weather a module has already been reported to existing instances of the UeberBackend */ // static vectorbackendmakers; /** Tracks all created UeberBackend instances for us. We use this vector to notify existing threads of new modules */ static vectorinstances; static pthread_mutex_t instances_lock; static bool loadmodule(const string &name); /** Thread function that listens on our unix domain socket for commands, for example instructions to load new modules */ static void *DynListener(void *); static void go(void); /** This contains all registered backends. The DynListener modifies this list for us when new modules are loaded */ vector backends; void die(); void cleanup(); //! the very magic handle for UeberBackend questions class handle { public: bool get(DNSResourceRecord &r); handle(); ~handle(); //! The UeberBackend class where this handle belongs to UeberBackend *parent; //! The current real backend, which is answering questions DNSBackend *d_hinterBackend; //! Index of the current backend within the backends vector unsigned int i; //! DNSPacket who asked this question DNSPacket *pkt_p; string qname; QType qtype; private: static AtomicCounter instances; }; void lookup(const QType &, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1); bool getSOA(const string &domain, SOAData &sd, DNSPacket *p=0); bool list(const string &target, int domain_id); bool get(DNSResourceRecord &r); void getAllDomains(vector *domains); static DNSBackend *maker(const map &); static void closeDynListener(); static void setStatus(const string &st); void getUnfreshSlaveInfos(vector* domains); void getUpdatedMasters(vector* domains); bool getDomainInfo(const string &domain, DomainInfo &di); int addDomainKey(const string& name, const KeyData& key); bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys); bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); bool removeDomainKey(const string& name, unsigned int id); bool activateDomainKey(const string& name, unsigned int id); bool deactivateDomainKey(const string& name, unsigned int id); bool getTSIGKey(const string& name, string* algorithm, string* content); void alsoNotifies(const string &domain, set *ips); void rediscover(string* status=0); void reload(); private: DNSResourceRecord lastrr; pthread_t tid; handle d_handle; bool d_negcached; bool d_cached; struct Question { QType qtype; string qname; int zoneId; }d_question; vector d_answers; vector::const_iterator d_cachehandleiter; int cacheHas(const Question &q, vector &rrs); void addNegCache(const Question &q); void addCache(const Question &q, const vector &rrs); static pthread_mutex_t d_mut; static pthread_cond_t d_cond; static sem_t d_dynserialize; static bool d_go; static int s_s; static string s_status; int d_ancount; bool stale; int domain_id; }; /** Class used to report new backends. It stores a maker function, and a flag that indicates that this module has been reported */ class BackendReporter { public: BackendReporter(UeberBackend::BackendMaker *p) { maker=p; reported=false; }; mapd_parameters; UeberBackend::BackendMaker *maker; //!< function to make this backend bool reported; //!< if this backend has been reported to running UeberBackend threads private: }; #endif pdns-3.3/pdns/rec_channel_rec.cc0000644000014601777760000004305112136555572020146 0ustar00jenkinsnogroup00000000000000#include "utility.hh" #include "rec_channel.hh" #include #include #include #include "misc.hh" #include "recursor_cache.hh" #include "syncres.hh" #include #include #include #include #include #include #include #include #include #include "logger.hh" #include "dnsparser.hh" #include "arguments.hh" #ifndef WIN32 #include #include #endif #include "namespaces.hh" #include "namespaces.hh" map d_get32bitpointers; map d_get64bitpointers; map > d_get32bitmembers; void addGetStat(const string& name, const uint32_t* place) { d_get32bitpointers[name]=place; } void addGetStat(const string& name, const uint64_t* place) { d_get64bitpointers[name]=place; } void addGetStat(const string& name, function f ) { d_get32bitmembers[name]=f; } optional get(const string& name) { optional ret; if(d_get32bitpointers.count(name)) return *d_get32bitpointers.find(name)->second; if(d_get64bitpointers.count(name)) return *d_get64bitpointers.find(name)->second; if(d_get32bitmembers.count(name)) return d_get32bitmembers.find(name)->second(); return ret; } map getAllStatsMap() { map ret; pair the32bits; pair the64bits; pair > the32bitmembers; BOOST_FOREACH(the32bits, d_get32bitpointers) { ret.insert(make_pair(the32bits.first, lexical_cast(*the32bits.second))); } BOOST_FOREACH(the64bits, d_get64bitpointers) { ret.insert(make_pair(the64bits.first, lexical_cast(*the64bits.second))); } BOOST_FOREACH(the32bitmembers, d_get32bitmembers) { ret.insert(make_pair(the32bitmembers.first, lexical_cast(the32bitmembers.second()))); } return ret; } string getAllStats() { typedef map varmap_t; varmap_t varmap = getAllStatsMap(); string ret; BOOST_FOREACH(varmap_t::value_type& tup, varmap) { ret += tup.first + "\t" + tup.second +"\n"; } return ret; } template string doGet(T begin, T end) { string ret; for(T i=begin; i != end; ++i) { optional num=get(*i); if(num) ret+=lexical_cast(*num)+"\n"; else ret+="UNKNOWN\n"; } return ret; } template string doGetParameter(T begin, T end) { string ret; string parm; using boost::replace_all; for(T i=begin; i != end; ++i) { if(::arg().parmIsset(*i)) { parm=::arg()[*i]; replace_all(parm, "\\", "\\\\"); replace_all(parm, "\"", "\\\""); replace_all(parm, "\n", "\\n"); ret += *i +"=\""+ parm +"\"\n"; } else ret += *i +" not known\n"; } return ret; } static uint64_t dumpNegCache(SyncRes::negcache_t& negcache, int fd) { FILE* fp=fdopen(dup(fd), "w"); if(!fp) { // dup probably failed return 0; } fprintf(fp, "; negcache dump from thread follows\n;\n"); time_t now = time(0); typedef SyncRes::negcache_t::nth_index<1>::type sequence_t; sequence_t& sidx=negcache.get<1>(); uint64_t count=0; BOOST_FOREACH(const NegCacheEntry& neg, sidx) { ++count; fprintf(fp, "%s IN %s %d VIA %s\n", neg.d_name.c_str(), neg.d_qtype.getName().c_str(), (unsigned int) (neg.d_ttd - now), neg.d_qname.c_str()); } fclose(fp); return count; } static uint64_t* pleaseDump(int fd) { return new uint64_t(t_RC->doDump(fd) + dumpNegCache(t_sstorage->negcache, fd)); } static uint64_t* pleaseDumpNSSpeeds(int fd) { return new uint64_t(t_RC->doDumpNSSpeeds(fd)); } template string doDumpNSSpeeds(T begin, T end) { T i=begin; string fname; if(i!=end) fname=*i; int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660); if(fd < 0) return "Error opening dump file for writing: "+string(strerror(errno))+"\n"; uint64_t total = 0; try { total = broadcastAccFunction(boost::bind(pleaseDumpNSSpeeds, fd)); } catch(...){} close(fd); return "dumped "+lexical_cast(total)+" records\n"; } template string doDumpCache(T begin, T end) { T i=begin; string fname; if(i!=end) fname=*i; int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660); if(fd < 0) return "Error opening dump file for writing: "+string(strerror(errno))+"\n"; uint64_t total = 0; try { total = broadcastAccFunction(boost::bind(pleaseDump, fd)); } catch(...){} close(fd); return "dumped "+lexical_cast(total)+" records\n"; } template string doDumpEDNSStatus(T begin, T end) { T i=begin; string fname; if(i!=end) fname=*i; int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660); if(fd < 0) return "Error opening dump file for writing: "+string(strerror(errno))+"\n"; SyncRes::doEDNSDumpAndClose(fd); return "done\n"; } uint64_t* pleaseWipeCache(const std::string& canon) { // clear packet cache too return new uint64_t(t_RC->doWipeCache(canon) + t_packetCache->doWipePacketCache(canon)); } uint64_t* pleaseWipeAndCountNegCache(const std::string& canon) { uint64_t res = t_sstorage->negcache.count(tie(canon)); pair range=t_sstorage->negcache.equal_range(tie(canon)); t_sstorage->negcache.erase(range.first, range.second); return new uint64_t(res); } template string doWipeCache(T begin, T end) { int count=0, countNeg=0; for(T i=begin; i != end; ++i) { string canon=toCanonic("", *i); count+= broadcastAccFunction(boost::bind(pleaseWipeCache, canon)); countNeg+=broadcastAccFunction(boost::bind(pleaseWipeAndCountNegCache, canon)); } return "wiped "+lexical_cast(count)+" records, "+lexical_cast(countNeg)+" negative records\n"; } #ifndef WIN32 static uint64_t getSysTimeMsec() { struct rusage ru; getrusage(RUSAGE_SELF, &ru); return (ru.ru_stime.tv_sec*1000ULL + ru.ru_stime.tv_usec/1000); } static uint64_t getUserTimeMsec() { struct rusage ru; getrusage(RUSAGE_SELF, &ru); return (ru.ru_utime.tv_sec*1000ULL + ru.ru_utime.tv_usec/1000); } #endif static uint64_t calculateUptime() { return time(0) - g_stats.startupTime; } static string* pleaseGetCurrentQueries() { ostringstream ostr; ostr << MT->d_waiters.size() <<" currently outstanding questions\n"; boost::format fmt("%1% %|40t|%2% %|47t|%3% %|63t|%4% %|68t|%5%\n"); ostr << (fmt % "qname" % "qtype" % "remote" % "tcp" % "chained"); int n=0; for(MT_t::waiters_t::iterator mthread=MT->d_waiters.begin(); mthread!=MT->d_waiters.end() && n < 100; ++mthread, ++n) { const PacketID& pident = mthread->key; ostr << (fmt % pident.domain % DNSRecordContent::NumberToType(pident.type) % pident.remote.toString() % (pident.sock ? 'Y' : 'n') % (pident.fd == -1 ? 'Y' : 'n') ); } ostr <<" - done\n"; return new string(ostr.str()); } static string doCurrentQueries() { return broadcastAccFunction(pleaseGetCurrentQueries); } uint64_t* pleaseGetThrottleSize() { return new uint64_t(t_sstorage->throttle.size()); } static uint64_t getThrottleSize() { return broadcastAccFunction(pleaseGetThrottleSize); } uint64_t* pleaseGetNegCacheSize() { uint64_t tmp=t_sstorage->negcache.size(); return new uint64_t(tmp); } uint64_t getNegCacheSize() { return broadcastAccFunction(pleaseGetNegCacheSize); } uint64_t* pleaseGetNsSpeedsSize() { return new uint64_t(t_sstorage->nsSpeeds.size()); } uint64_t getNsSpeedsSize() { return broadcastAccFunction(pleaseGetNsSpeedsSize); } uint64_t* pleaseGetConcurrentQueries() { return new uint64_t(MT->numProcesses()); } static uint64_t getConcurrentQueries() { return broadcastAccFunction(pleaseGetConcurrentQueries); } uint64_t* pleaseGetCacheSize() { return new uint64_t(t_RC->size()); } uint64_t* pleaseGetCacheBytes() { return new uint64_t(t_RC->bytes()); } uint64_t doGetCacheSize() { return broadcastAccFunction(pleaseGetCacheSize); } uint64_t doGetCacheBytes() { return broadcastAccFunction(pleaseGetCacheBytes); } uint64_t* pleaseGetCacheHits() { return new uint64_t(t_RC->cacheHits); } uint64_t doGetCacheHits() { return broadcastAccFunction(pleaseGetCacheHits); } uint64_t* pleaseGetCacheMisses() { return new uint64_t(t_RC->cacheMisses); } uint64_t doGetCacheMisses() { return broadcastAccFunction(pleaseGetCacheMisses); } uint64_t* pleaseGetPacketCacheSize() { return new uint64_t(t_packetCache->size()); } uint64_t* pleaseGetPacketCacheBytes() { return new uint64_t(t_packetCache->bytes()); } uint64_t doGetPacketCacheSize() { return broadcastAccFunction(pleaseGetPacketCacheSize); } uint64_t doGetPacketCacheBytes() { return broadcastAccFunction(pleaseGetPacketCacheBytes); } uint64_t* pleaseGetPacketCacheHits() { return new uint64_t(t_packetCache->d_hits); } uint64_t doGetPacketCacheHits() { return broadcastAccFunction(pleaseGetPacketCacheHits); } uint64_t* pleaseGetPacketCacheMisses() { return new uint64_t(t_packetCache->d_misses); } uint64_t doGetPacketCacheMisses() { return broadcastAccFunction(pleaseGetPacketCacheMisses); } uint64_t doGetMallocated() { // this turned out to be broken /* struct mallinfo mi = mallinfo(); return mi.uordblks; */ return 0; } RecursorControlParser::RecursorControlParser() { addGetStat("questions", &g_stats.qcounter); addGetStat("ipv6-questions", &g_stats.ipv6qcounter); addGetStat("tcp-questions", &g_stats.tcpqcounter); addGetStat("cache-hits", doGetCacheHits); addGetStat("cache-misses", doGetCacheMisses); addGetStat("cache-entries", doGetCacheSize); addGetStat("cache-bytes", doGetCacheBytes); addGetStat("packetcache-hits", doGetPacketCacheHits); addGetStat("packetcache-misses", doGetPacketCacheMisses); addGetStat("packetcache-entries", doGetPacketCacheSize); addGetStat("packetcache-bytes", doGetPacketCacheBytes); addGetStat("malloc-bytes", doGetMallocated); addGetStat("servfail-answers", &g_stats.servFails); addGetStat("nxdomain-answers", &g_stats.nxDomains); addGetStat("noerror-answers", &g_stats.noErrors); addGetStat("unauthorized-udp", &g_stats.unauthorizedUDP); addGetStat("unauthorized-tcp", &g_stats.unauthorizedTCP); addGetStat("tcp-client-overflow", &g_stats.tcpClientOverflow); addGetStat("client-parse-errors", &g_stats.clientParseError); addGetStat("server-parse-errors", &g_stats.serverParseError); addGetStat("answers0-1", &g_stats.answers0_1); addGetStat("answers1-10", &g_stats.answers1_10); addGetStat("answers10-100", &g_stats.answers10_100); addGetStat("answers100-1000", &g_stats.answers100_1000); addGetStat("answers-slow", &g_stats.answersSlow); addGetStat("qa-latency", &g_stats.avgLatencyUsec); addGetStat("unexpected-packets", &g_stats.unexpectedCount); addGetStat("case-mismatches", &g_stats.caseMismatchCount); addGetStat("spoof-prevents", &g_stats.spoofCount); addGetStat("nsset-invalidations", &g_stats.nsSetInvalidations); addGetStat("resource-limits", &g_stats.resourceLimits); addGetStat("over-capacity-drops", &g_stats.overCapacityDrops); addGetStat("no-packet-error", &g_stats.noPacketError); addGetStat("dlg-only-drops", &SyncRes::s_nodelegated); addGetStat("max-mthread-stack", &g_stats.maxMThreadStackUsage); addGetStat("negcache-entries", boost::bind(getNegCacheSize)); addGetStat("throttle-entries", boost::bind(getThrottleSize)); addGetStat("nsspeeds-entries", boost::bind(getNsSpeedsSize)); addGetStat("concurrent-queries", boost::bind(getConcurrentQueries)); addGetStat("outgoing-timeouts", &SyncRes::s_outgoingtimeouts); addGetStat("tcp-outqueries", &SyncRes::s_tcpoutqueries); addGetStat("all-outqueries", &SyncRes::s_outqueries); addGetStat("ipv6-outqueries", &g_stats.ipv6queries); addGetStat("throttled-outqueries", &SyncRes::s_throttledqueries); addGetStat("dont-outqueries", &SyncRes::s_dontqueries); addGetStat("throttled-out", &SyncRes::s_throttledqueries); addGetStat("unreachables", &SyncRes::s_unreachables); addGetStat("chain-resends", &g_stats.chainResends); addGetStat("tcp-clients", boost::bind(TCPConnection::getCurrentConnections)); addGetStat("edns-ping-matches", &g_stats.ednsPingMatches); addGetStat("edns-ping-mismatches", &g_stats.ednsPingMismatches); addGetStat("noping-outqueries", &g_stats.noPingOutQueries); addGetStat("noedns-outqueries", &g_stats.noEdnsOutQueries); addGetStat("uptime", calculateUptime); #ifndef WIN32 // addGetStat("query-rate", getQueryRate); addGetStat("user-msec", getUserTimeMsec); addGetStat("sys-msec", getSysTimeMsec); #endif } static void doExitGeneric(bool nicely) { L<* pleaseGetRemotes() { return new vector(t_remotes->remotes); } string doTopRemotes() { typedef map counts_t; counts_t counts; vector remotes=broadcastAccFunction >(pleaseGetRemotes); unsigned int total=0; for(RemoteKeeper::remotes_t::const_iterator i = remotes.begin(); i != remotes.end(); ++i) if(i->sin4.sin_family) { total++; counts[*i]++; } typedef std::multimap rcounts_t; rcounts_t rcounts; for(counts_t::const_iterator i=counts.begin(); i != counts.end(); ++i) rcounts.insert(make_pair(-i->second, i->first)); ostringstream ret; ret<<"Over last "<first/total) % i->second.toString(); return ret.str(); } static string* nopFunction() { return new string("pong\n"); } string RecursorControlParser::getAnswer(const string& question, RecursorControlParser::func_t** command) { *command=nop; vector words; stringtok(words, question); if(words.empty()) return "invalid command\n"; string cmd=toLower(words[0]); vector::const_iterator begin=words.begin()+1, end=words.end(); // should probably have a smart dispatcher here, like auth has if(cmd=="help") return "current-queries show currently active queries\n" "dump-cache dump cache contents to the named file\n" "dump-edns[status] dump EDNS status to the named file\n" "dump-nsspeeds dump nsspeeds statistics to the named file\n" "get [key1] [key2] .. get specific statistics\n" "get-all get all statistics\n" "get-parameter [key1] [key2] .. get configuration parameters\n" "help get this list\n" "ping check that all threads are alive\n" "quit stop the recursor daemon\n" "quit-nicely stop the recursor daemon nicely\n" "reload-acls reload ACLS\n" "reload-lua-script [filename] (re)load Lua script\n" "reload-zones reload all auth and forward zones\n" "trace-regex regex emit resolution trace for matching queries\n" "top-remotes show top remotes\n" "unload-lua-script unload Lua script\n" "wipe-cache domain0 [domain1] .. wipe domain data from cache\n"; if(cmd=="get-all") return getAllStats(); if(cmd=="get") return doGet(begin, end); if(cmd=="get-parameter") return doGetParameter(begin, end); if(cmd=="quit") { *command=&doExit; return "bye\n"; } if(cmd=="quit-nicely") { *command=&doExitNicely; return "bye nicely\n"; } if(cmd=="dump-cache") return doDumpCache(begin, end); if(cmd=="dump-ednsstatus" || cmd=="dump-edns") return doDumpEDNSStatus(begin, end); if(cmd=="dump-nsspeeds") return doDumpNSSpeeds(begin, end); if(cmd=="wipe-cache" || cmd=="flushname") return doWipeCache(begin, end); if(cmd=="reload-lua-script") return doQueueReloadLuaScript(begin, end); if(cmd=="trace-regex") return doTraceRegex(begin, end); if(cmd=="unload-lua-script") { vector empty; empty.push_back(string()); return doQueueReloadLuaScript(empty.begin(), empty.end()); } if(cmd=="reload-acls") { try { parseACLs(); } catch(std::exception& e) { L<(nopFunction); } if(cmd=="reload-zones") { return reloadAuthAndForwards(); } return "Unknown command '"+cmd+"', try 'help'\n"; } pdns-3.3/pdns/lua-pdns.cc0000644000014601777760000001567012147631274016601 0ustar00jenkinsnogroup00000000000000#include "lua-pdns.hh" // #include "syncres.hh" #include #include "config.h" #if !defined(HAVE_LUA) // stub implementation PowerDNSLua::PowerDNSLua(const std::string& fname) { throw runtime_error("Lua support disabled"); } PowerDNSLua::~PowerDNSLua() { } #else extern "C" { #undef L /* Include the Lua API header files. */ #include #include #include } #include #include #include #include #include #include "logger.hh" #include "namespaces.hh" bool netmaskMatchTable(lua_State* lua, const std::string& ip) { lua_pushnil(lua); /* first key */ while (lua_next(lua, 2) != 0) { string netmask=lua_tostring(lua, -1); Netmask nm(netmask); ComboAddress ca(ip); lua_pop(lua, 1); if(nm.match(ip)) return true; } return false; } static bool getFromTable(lua_State *lua, const std::string &key, std::string& value) { lua_pushstring(lua, key.c_str()); // 4 is now '1' lua_gettable(lua, -2); // replace by the first entry of our table we hope bool ret=false; if(!lua_isnil(lua, -1)) { value = lua_tostring(lua, -1); ret=true; } lua_pop(lua, 1); return ret; } static bool getFromTable(lua_State *lua, const std::string &key, uint32_t& value) { lua_pushstring(lua, key.c_str()); // 4 is now '1' lua_gettable(lua, -2); // replace by the first entry of our table we hope bool ret=false; if(!lua_isnil(lua, -1)) { value = (uint32_t)lua_tonumber(lua, -1); ret=true; } lua_pop(lua, 1); return ret; } void pushResourceRecordsTable(lua_State* lua, const vector& records) { // make a table of tables lua_newtable(lua); int pos=0; BOOST_FOREACH(const DNSResourceRecord& rr, records) { // row number, used by 'lua_settable' below lua_pushnumber(lua, ++pos); // "row" table lua_newtable(lua); lua_pushstring(lua, rr.qname.c_str()); lua_setfield(lua, -2, "qname"); // pushes value at the top of the stack to the table immediately below that (-1 = top, -2 is below) lua_pushstring(lua, rr.content.c_str()); lua_setfield(lua, -2, "content"); lua_pushnumber(lua, rr.qtype.getCode()); lua_setfield(lua, -2, "qtype"); lua_pushnumber(lua, rr.ttl); lua_setfield(lua, -2, "ttl"); lua_pushnumber(lua, rr.d_place); lua_setfield(lua, -2, "place"); lua_settable(lua, -3); // pushes the table we just built into the master table at position pushed above } } int getLuaTableLength(lua_State* lua, int depth) { #ifndef LUA_VERSION_NUM return luaL_getn(lua, 2); #elif LUA_VERSION_NUM < 502 return lua_objlen(lua, 2); #else return lua_rawlen(lua, 2); #endif } void popResourceRecordsTable(lua_State *lua, const string &query, vector& ret) { /* get the result */ DNSResourceRecord rr; rr.qname = query; rr.d_place = DNSResourceRecord::ANSWER; rr.ttl = 3600; // cerr<<"Lua stacksize "< DNSResourceRecord::ADDITIONAL) rr.d_place = DNSResourceRecord::ADDITIONAL; } /* removes 'value'; keeps 'key' for next iteration */ lua_pop(lua, 1); // table // cerr<<"Adding content '"<= 2) { string ip=lua_tostring(lua, 1); if(lua_istable(lua, 2)) { result = netmaskMatchTable(lua, ip); } else { for(int n=2 ; n <= lua_gettop(lua); ++n) { string netmask=lua_tostring(lua, n); Netmask nm(netmask); ComboAddress ca(ip); result = nm.match(ip); if(result) break; } } } lua_pushboolean(lua, result); return 1; } int getLocalAddressLua(lua_State* lua) { lua_getfield(lua, LUA_REGISTRYINDEX, "__PowerDNSLua"); PowerDNSLua* pl = (PowerDNSLua*)lua_touserdata(lua, -1); lua_pushstring(lua, pl->getLocal().toString().c_str()); return 1; } // called by lua to indicate that this answer is 'variable' and should not be cached int setVariableLua(lua_State* lua) { lua_getfield(lua, LUA_REGISTRYINDEX, "__PowerDNSLua"); PowerDNSLua* pl = (PowerDNSLua*)lua_touserdata(lua, -1); pl->setVariable(); return 0; } int logLua(lua_State *lua) { if(lua_gettop(lua) >= 1) { string message=lua_tostring(lua, 1); theL()<::const_iterator iter = QType::names.begin(); iter != QType::names.end(); ++iter) { lua_pushnumber(d_lua, iter->second); lua_setfield(d_lua, -2, iter->first.c_str()); } lua_pushnumber(d_lua, 0); lua_setfield(d_lua, -2, "NOERROR"); lua_pushnumber(d_lua, 1); lua_setfield(d_lua, -2, "FORMERR"); lua_pushnumber(d_lua, 2); lua_setfield(d_lua, -2, "SERVFAIL"); lua_pushnumber(d_lua, 3); lua_setfield(d_lua, -2, "NXDOMAIN"); lua_pushnumber(d_lua, 4); lua_setfield(d_lua, -2, "NOTIMP"); lua_pushnumber(d_lua, 5); lua_setfield(d_lua, -2, "REFUSED"); lua_setglobal(d_lua, "pdns"); lua_pushlightuserdata(d_lua, (void*)this); lua_setfield(d_lua, LUA_REGISTRYINDEX, "__PowerDNSLua"); } bool PowerDNSLua::getFromTable(const std::string& key, std::string& value) { return ::getFromTable(d_lua, key, value); } bool PowerDNSLua::getFromTable(const std::string& key, uint32_t& value) { return ::getFromTable(d_lua, key, value); } PowerDNSLua::~PowerDNSLua() { lua_close(d_lua); } #endif pdns-3.3/pdns/logger.hh0000644000014601777760000001063212136555572016344 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LOGGER_HH #define LOGGER_HH /* (C) 2002 POWERDNS.COM BV */ #include #include #include #include #include #include "config.h" #ifndef WIN32 # include #include #else # define WINDOWS_LEAN_AND_MEAN # include typedef int pthread_mutex_t; typedef int pthread_t; #endif // WIN32 #include "namespaces.hh" //! The Logger class can be used to log messages in various ways. class Logger { public: #ifndef WIN32 Logger(const string &, int facility=LOG_DAEMON); //!< pass the identification you wish to appear in the log //! The urgency of a log message enum Urgency {All=99999,NTLog=12345,Alert=LOG_ALERT, Critical=LOG_CRIT, Error=LOG_ERR, Warning=LOG_WARNING, Notice=LOG_NOTICE,Info=LOG_INFO, Debug=LOG_DEBUG, None=-1}; #else Logger( const string &, int facility = 0 ); //!< pass the identification you wish to appear in the log //! The urgency of a log message enum Urgency { All = 99999, NTLog = 12345, Alert = EVENTLOG_ERROR_TYPE, Critical= EVENTLOG_ERROR_TYPE, Error = EVENTLOG_ERROR_TYPE, Warning = EVENTLOG_WARNING_TYPE, Notice = EVENTLOG_INFORMATION_TYPE, Info = EVENTLOG_INFORMATION_TYPE, Debug = EVENTLOG_INFORMATION_TYPE, None = -1 }; void toNTLog( void ); private: //! Handle used to communicate with the event log. HANDLE m_eventLogHandle; //! Log file handle. FILE *m_pLogFile; //! Log current message to the NT log? map< pthread_t, bool > m_toNTLog; public: #endif // WIN32 /** Log a message. \param msg Message you wish to log \param Urgency Urgency of the message you wish to log */ void log(const string &msg, Urgency u=Notice); void setFacility(int f){d_facility=f;open();} //!< Choose logging facility void setFlag(int f){flags|=f;open();} //!< set a syslog flag void setName(const string &); //! set lower limit of urgency needed for console display. Messages of this urgency, and higher, will be displayed void toConsole(Urgency); void setLoglevel( Urgency ); //! Log to a file. void toFile( const string & filename ); void resetFlags(){flags=0;open();} //!< zero the flags /** Use this to stream to your log, like this: \code L<<"This is an informational message"<d_strings; map d_outputurgencies; void open(); string name; int flags; int d_facility; bool opened; Urgency d_loglevel; Urgency consoleUrgency; pthread_mutex_t lock; }; extern Logger &theL(const string &pname=""); #ifdef VERBOSELOG #define DLOG(x) x #else #define DLOG(x) #endif #endif pdns-3.3/pdns/dnsscan.cc0000644000014601777760000000431112164306474016475 0ustar00jenkinsnogroup00000000000000#include #include "statbag.hh" #include "dnspcap.hh" #include "sstuff.hh" #include "anadns.hh" // this is needed because boost multi_index also uses 'L', as do we (which is sad enough) #undef L #include #include #include #include #include #include #include #include #include "namespaces.hh" using namespace ::boost::multi_index; #include "namespaces.hh" StatBag S; int main(int argc, char** argv) try { Socket sock(InterNetwork, Datagram); /* IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1", argc > 3 ? atoi(argv[3]) : 5300); */ if(argc<2) { cerr<<"Syntax: dnsscan file1 [file2 ..] "< 256 || mdp.d_qclass!=1 ) { // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote); } for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { } } catch(MOADNSException &e) { cout<<"Error from remote "<ip_src)))<<": "< #include "dnsrecords.hh" #include #include "misc.hh" #include #include #include #include #include #include "dns.hh" #include "qtype.hh" #include "ahuexception.hh" #include "arguments.hh" #include "sstuff.hh" #include "syncres.hh" #include "dnswriter.hh" #include "dnsparser.hh" #include "logger.hh" #include "dns_random.hh" #include #include string dns0x20(const std::string& in) { string ret(in); string::size_type len=ret.size(); for(string::size_type pos = 0 ; pos < len; ++pos) { if(isalpha(in[pos]) && dns_random(2)) ret[pos]^=0x20; } // cerr<<"'"< '"< buf(new unsigned char[bufsize]); vector vpacket; // string mapped0x20=dns0x20(domain); DNSPacketWriter pw(vpacket, domain, type); pw.getHeader()->rd=sendRDQuery; pw.getHeader()->id=dns_random(0xffff); string ping; uint32_t nonce=dns_random(0xffffffff); ping.assign((char*) &nonce, 4); if(EDNS0Level && !doTCP) { DNSPacketWriter::optvect_t opts; if(EDNS0Level > 1) { opts.push_back(make_pair(5, ping)); } pw.addOpt(1200, 0, 0, opts); // 1200 bytes answer size pw.commit(); } lwr->d_rcode = 0; lwr->d_pingCorrect = false; lwr->d_haveEDNS = false; int ret; DTime dt; dt.setTimeval(*now); errno=0; if(!doTCP) { int queryfd; if(ip.sin4.sin_family==AF_INET6) g_stats.ipv6queries++; if((ret=asendto((const char*)&*vpacket.begin(), (int)vpacket.size(), 0, ip, pw.getHeader()->id, domain, type, &queryfd)) < 0) { return ret; // passes back the -2 EMFILE } // sleep until we see an answer to this, interface to mtasker ret=arecvfrom(reinterpret_cast(buf.get()), bufsize-1,0, ip, &len, pw.getHeader()->id, domain, type, queryfd, now); } else { try { Socket s((AddressFamily)ip.sin4.sin_family, Stream); s.setNonBlocking(); ComboAddress local = getQueryLocalAddress(ip.sin4.sin_family, 0); s.bind(local); ComboAddress remote = ip; remote.sin4.sin_port = htons(53); s.connect(remote); uint16_t tlen=htons(vpacket.size()); char *lenP=(char*)&tlen; const char *msgP=(const char*)&*vpacket.begin(); string packet=string(lenP, lenP+2)+string(msgP, msgP+vpacket.size()); ret=asendtcp(packet, &s); if(!(ret>0)) return ret; packet.clear(); ret=arecvtcp(packet, 2, &s); if(!(ret > 0)) return ret; memcpy(&tlen, packet.c_str(), 2); len=ntohs(tlen); // switch to the 'len' shared with the rest of the function ret=arecvtcp(packet, len, &s); if(!(ret > 0)) return ret; if(len > bufsize) { bufsize=len; scoped_array narray(new unsigned char[bufsize]); buf.swap(narray); } memcpy(buf.get(), packet.c_str(), len); ret=1; } catch(NetworkError& ne) { ret = -2; // OS limits error } } lwr->d_usec=dt.udiff(); *now=dt.getTimeval(); if(ret <= 0) // includes 'timeout' return ret; lwr->d_result.clear(); try { lwr->d_tcbit=0; MOADNSParser mdp((const char*)buf.get(), len); lwr->d_aabit=mdp.d_header.aa; lwr->d_tcbit=mdp.d_header.tc; lwr->d_rcode=mdp.d_header.rcode; if(mdp.d_header.rcode == RCode::FormErr && mdp.d_qname.empty() && mdp.d_qtype == 0 && mdp.d_qclass == 0) { return 1; // this is "success", the error is set in lwr->d_rcode } if(!pdns_iequals(domain, mdp.d_qname)) { if(!mdp.d_qname.empty() && domain.find((char)0) == string::npos) {// embedded nulls are too noisy, plus empty domains are too L<first.d_type; rr.qname=i->first.d_label; rr.ttl=i->first.d_ttl; rr.content=i->first.d_content->getZoneRepresentation(); // this should be the serialised form rr.d_place=(DNSResourceRecord::Place) i->first.d_place; lwr->d_result.push_back(rr); } EDNSOpts edo; if(EDNS0Level > 1 && getEDNSOpts(mdp, &edo)) { lwr->d_haveEDNS = true; for(vector >::const_iterator iter = edo.d_options.begin(); iter != edo.d_options.end(); ++iter) { if(iter->first == 5 || iter->first == 4) {// 'EDNS PING' if(iter->second == ping) { lwr->d_pingCorrect = true; } } } } return 1; } catch(std::exception &mde) { if(::arg().mustDo("log-common-errors")) L<d_rcode = RCode::FormErr; g_stats.serverParseError++; return 1; // success - oddly enough } catch(...) { L<d_rcode) lwr->d_rcode=RCode::ServFail; return -1; } pdns-3.3/pdns/lua-recursor.hh0000644000014601777760000000216612136555572017513 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_LUA_RECURSOR_HH #define PDNS_LUA_RECURSOR_HH #include "dns.hh" #include "iputils.hh" #include "lua-pdns.hh" class RecursorLua : public PowerDNSLua { public: explicit RecursorLua(const std::string& fname); // ~RecursorLua(); bool preresolve(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& res, int& ret, bool* variable); bool nxdomain(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector& res, int& ret, bool* variable); bool nodata(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector& res, int& ret, bool* variable); bool postresolve(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector& res, int& ret, bool* variable); private: bool passthrough(const string& func, const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable); }; #endif pdns-3.3/pdns/test-base32_cc.cc0000644000014601777760000000216412150644332017542 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include #include #include #include "base32.hh" BOOST_AUTO_TEST_SUITE(test_base32_cc) BOOST_AUTO_TEST_CASE(test_record_types) { typedef boost::tuple case_t; typedef std::list cases_t; // RFC test vectors cases_t cases = boost::assign::list_of (case_t(std::string(""), std::string(""))) (case_t(std::string("f"), std::string("CO======"))) (case_t(std::string("fo"), std::string("CPNG===="))) (case_t(std::string("foo"), std::string("CPNMU==="))) (case_t(std::string("foob"), std::string("CPNMUOG="))) (case_t(std::string("fooba"), std::string("CPNMUOJ1"))) (case_t(std::string("foobar"), std::string("CPNMUOJ1E8======"))) ; BOOST_FOREACH(const case_t& val, cases) { std::string res; res = toBase32Hex(val.get<0>()); BOOST_CHECK_EQUAL(res, val.get<1>()); res = fromBase32Hex(val.get<1>()); BOOST_CHECK_EQUAL(res, val.get<0>()); } }; BOOST_AUTO_TEST_SUITE_END(); pdns-3.3/pdns/iputils.hh0000644000014601777760000002272412165455411016554 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_IPUTILSHH #define PDNS_IPUTILSHH #include #ifndef WIN32 #include #include #include #endif // WIN32 #include #include #include #include "ahuexception.hh" #include "misc.hh" #include #include #include #include #include #include "namespaces.hh" union ComboAddress { struct sockaddr_in sin4; struct sockaddr_in6 sin6; bool operator==(const ComboAddress& rhs) const { if(boost::tie(sin4.sin_family, sin4.sin_port) != boost::tie(rhs.sin4.sin_family, rhs.sin4.sin_port)) return false; if(sin4.sin_family == AF_INET) return sin4.sin_addr.s_addr == rhs.sin4.sin_addr.s_addr; else return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16)==0; } bool operator<(const ComboAddress& rhs) const { if(boost::tie(sin4.sin_family, sin4.sin_port) < boost::tie(rhs.sin4.sin_family, rhs.sin4.sin_port)) return true; if(boost::tie(sin4.sin_family, sin4.sin_port) > boost::tie(rhs.sin4.sin_family, rhs.sin4.sin_port)) return false; if(sin4.sin_family == AF_INET) return sin4.sin_addr.s_addr < rhs.sin4.sin_addr.s_addr; else return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16) < 0; } bool operator>(const ComboAddress& rhs) const { if(boost::tie(sin4.sin_family, sin4.sin_port) > boost::tie(rhs.sin4.sin_family, rhs.sin4.sin_port)) return true; if(boost::tie(sin4.sin_family, sin4.sin_port) < boost::tie(rhs.sin4.sin_family, rhs.sin4.sin_port)) return false; if(sin4.sin_family == AF_INET) return sin4.sin_addr.s_addr > rhs.sin4.sin_addr.s_addr; else return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16) > 0; } struct addressOnlyLessThan: public std::binary_function { bool operator()(const ComboAddress& a, const ComboAddress& b) const { if(a.sin4.sin_family < b.sin4.sin_family) return true; if(a.sin4.sin_family > b.sin4.sin_family) return false; if(a.sin4.sin_family == AF_INET) return a.sin4.sin_addr.s_addr < b.sin4.sin_addr.s_addr; else return memcmp(&a.sin6.sin6_addr.s6_addr, &b.sin6.sin6_addr.s6_addr, 16) < 0; } }; socklen_t getSocklen() const { if(sin4.sin_family == AF_INET) return sizeof(sin4); else return sizeof(sin6); } ComboAddress() { sin4.sin_family=AF_INET; sin4.sin_addr.s_addr=0; sin4.sin_port=0; } // 'port' sets a default value in case 'str' does not set a port explicit ComboAddress(const string& str, uint16_t port=0) { memset(&sin6, 0, sizeof(sin6)); sin4.sin_family = AF_INET; sin4.sin_port = 0; if(makeIPv4sockaddr(str, &sin4)) { sin6.sin6_family = AF_INET6; if(makeIPv6sockaddr(str, &sin6) < 0) throw AhuException("Unable to convert presentation address '"+ str +"'"); } if(!sin4.sin_port) // 'str' overrides port! sin4.sin_port=htons(port); } bool isMappedIPv4() const { if(sin4.sin_family!=AF_INET6) return false; int n=0; const unsigned char*ptr = (unsigned char*) &sin6.sin6_addr.s6_addr; for(n=0; n < 10; ++n) if(ptr[n]) return false; for(; n < 12; ++n) if(ptr[n]!=0xff) return false; return true; } ComboAddress mapToIPv4() const { if(!isMappedIPv4()) throw AhuException("ComboAddress can't map non-mapped IPv6 address back to IPv4"); ComboAddress ret; ret.sin4.sin_family=AF_INET; ret.sin4.sin_port=sin4.sin_port; const unsigned char*ptr = (unsigned char*) &sin6.sin6_addr.s6_addr; ptr+=12; memcpy(&ret.sin4.sin_addr.s_addr, ptr, 4); return ret; } string toString() const { char host[1024]; getnameinfo((struct sockaddr*) this, getSocklen(), host, sizeof(host),0, 0, NI_NUMERICHOST); return host; } string toStringWithPort() const { if(sin4.sin_family==AF_INET) return toString() + ":" + boost::lexical_cast(ntohs(sin4.sin_port)); else return "["+toString() + "]:" + boost::lexical_cast(ntohs(sin4.sin_port)); } }; /** This exception is thrown by the Netmask class and by extension by the NetmaskGroup class */ class NetmaskException: public AhuException { public: NetmaskException(const string &a) : AhuException(a) {} }; inline ComboAddress makeComboAddress(const string& str) { ComboAddress address; address.sin4.sin_family=AF_INET; if(Utility::inet_pton(AF_INET, str.c_str(), &address.sin4.sin_addr) <= 0) { address.sin4.sin_family=AF_INET6; if(makeIPv6sockaddr(str, &address.sin6) < 0) throw NetmaskException("Unable to convert '"+str+"' to a netmask"); } return address; } /** This class represents a netmask and can be queried to see if a certain IP address is matched by this mask */ class Netmask { public: Netmask() { d_network.sin4.sin_family=0; // disable this doing anything useful } Netmask(const ComboAddress& network, uint8_t bits=0xff) { d_network = network; if(bits == 0xff) bits = (network.sin4.sin_family == AF_INET) ? 32 : 128; d_bits = bits; if(d_bits<32) d_mask=~(0xFFFFFFFF>>d_bits); else d_mask=0xFFFFFFFF; // not actually used for IPv6 } //! Constructor supplies the mask, which cannot be changed Netmask(const string &mask) { pair split=splitField(mask,'/'); d_network=makeComboAddress(split.first); if(!split.second.empty()) { d_bits = lexical_cast(split.second); if(d_bits<32) d_mask=~(0xFFFFFFFF>>d_bits); else d_mask=0xFFFFFFFF; } else if(d_network.sin4.sin_family==AF_INET) { d_bits = 32; d_mask = 0xFFFFFFFF; } else { d_bits=128; d_mask=0; // silence silly warning - d_mask is unused for IPv6 } } bool match(const ComboAddress& ip) const { return match(&ip); } //! If this IP address in socket address matches bool match(const ComboAddress *ip) const { if(d_network.sin4.sin_family != ip->sin4.sin_family) { return false; } if(d_network.sin4.sin_family == AF_INET) { return match4(htonl((unsigned int)ip->sin4.sin_addr.s_addr)); } if(d_network.sin6.sin6_family == AF_INET6) { uint8_t bytes=d_bits/8, n; const uint8_t *us=(const uint8_t*) &d_network.sin6.sin6_addr.s6_addr; const uint8_t *them=(const uint8_t*) &ip->sin6.sin6_addr.s6_addr; for(n=0; n < bytes; ++n) { if(us[n]!=them[n]) { return false; } } // still here, now match remaining bits uint8_t bits= d_bits % 8; uint8_t mask= ~(0xFF>>bits); return((us[n] & mask) == (them[n] & mask)); } return false; } //! If this ASCII IP address matches bool match(const string &ip) const { ComboAddress address=makeComboAddress(ip); return match(&address); } //! If this IP address in native format matches bool match4(uint32_t ip) const { return (ip & d_mask) == (ntohl(d_network.sin4.sin_addr.s_addr) & d_mask); } string toString() const { return d_network.toString()+"/"+boost::lexical_cast((unsigned int)d_bits); } string toStringNoMask() const { return d_network.toString(); } const ComboAddress& getNetwork() const { return d_network; } int getBits() const { return d_bits; } private: ComboAddress d_network; uint32_t d_mask; uint8_t d_bits; }; /** This class represents a group of supplemental Netmask classes. An IP address matchs if it is matched by zero or more of the Netmask classes within. */ class NetmaskGroup { public: //! If this IP address is matched by any of the classes within bool match(const ComboAddress *ip) { for(container_t::const_iterator i=d_masks.begin();i!=d_masks.end();++i) if(i->match(ip) || (ip->isMappedIPv4() && i->match(ip->mapToIPv4()) )) return true; return false; } bool match(const ComboAddress& ip) { return match(&ip); } //! Add this Netmask to the list of possible matches void addMask(const string &ip) { d_masks.push_back(Netmask(ip)); } bool empty() { return d_masks.empty(); } unsigned int size() { return (unsigned int)d_masks.size(); } string toString() const { ostringstream str; for(container_t::const_iterator iter = d_masks.begin(); iter != d_masks.end(); ++iter) { if(iter != d_masks.begin()) str <<", "; str<toString(); } return str.str(); } private: typedef vector container_t; container_t d_masks; }; #endif pdns-3.3/pdns/nsec3dig.cc0000644000014601777760000001511712136555572016555 0ustar00jenkinsnogroup00000000000000#include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "statbag.hh" #include "base32.hh" #include "dnssecinfra.hh" #include StatBag S; typedef std::pair nsec3; typedef set nsec3set; string nsec3Hash(const string &qname, const string &salt, unsigned int iters) { return toLower(toBase32Hex(hashQNameWithSalt(iters, salt, qname))); } void proveOrDeny(const nsec3set &nsec3s, const string &qname, const string &salt, unsigned int iters, set &proven, set &denied) { string hashed = nsec3Hash(qname, salt, iters); // cerr<<"proveOrDeny(.., '"< base && hashed < next) || (next < base && (hashed < next || hashed > base))) { denied.insert(qname); cout< 5 && strcmp(argv[5], "recurse")==0) { recurse=true; } vector packet; string qname=argv[3]; DNSPacketWriter pw(packet, qname, DNSRecordContent::TypeToNumber(argv[4])); if(recurse) { pw.getHeader()->rd=true; } pw.addOpt(2800, 0, EDNSOpts::DNSSECOK); pw.commit(); Socket sock(InterNetwork, Stream); ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); sock.connect(dest); uint16_t len; len = htons(packet.size()); if(sock.write((char *) &len, 2) != 2) throw AhuException("tcp write failed"); sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end())); if(sock.read((char *) &len, 2) != 2) throw AhuException("tcp read failed"); len=ntohs(len); char *creply = new char[len]; int n=0; int numread; while(n names; set namesseen; set namestocheck; nsec3set nsec3s; string nsec3salt; int nsec3iters = 0; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { if(i->first.d_type == QType::NSEC3) { // cerr<<"got nsec3 ["<first.d_label<<"]"<first.d_content->getZoneRepresentation()< (*(i->first.d_content)); // nsec3.insert(new nsec3() // cerr< parts; boost::split(parts, i->first.d_label, boost::is_any_of(".")); nsec3s.insert(make_pair(toLower(parts[0]), toLower(toBase32Hex(r.d_nexthash)))); nsec3salt = r.d_salt; nsec3iters = r.d_iterations; } else { // cerr<<"namesseen.insert('"<first.d_label<<"')"<first.d_label)); namesseen.insert(stripDot(i->first.d_label)); } if(i->first.d_type == QType::CNAME) { namesseen.insert(stripDot(i->first.d_content->getZoneRepresentation())); } cout<first.d_place-1<<"\t"<first.d_label<<"\tIN\t"<first.d_type); cout<<"\t"<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; } #if 0 cerr<<"got "<::const_iterator pos=names.begin(); pos != names.end(); ++pos) { cerr<<"name: "<<*pos< proven; set denied; namesseen.insert(stripDot(qname)); BOOST_FOREACH(string n, namesseen) { string shorter(n); do { namestocheck.insert(shorter); } while(chopOff(shorter)); } BOOST_FOREACH(string n, namestocheck) { proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied); proveOrDeny(nsec3s, "*."+n, nsec3salt, nsec3iters, proven, denied); } if(names.count(qname+".")) { cout<<"== qname found in names, investigating NSEC3s in case it's a wildcard"< #include #include #include #include #include #include #include "anadns.hh" #include "namespaces.hh" #include "namespaces.hh" StatBag S; struct tm* pdns_localtime_r(const uint32_t* then, struct tm* tm) { time_t t = *then; return localtime_r(&t, tm); } int32_t g_clientQuestions, g_clientResponses, g_serverQuestions, g_serverResponses, g_skipped; struct pdns_timeval g_lastanswerTime, g_lastquestionTime; void makeReport(const struct pdns_timeval& tv) { int64_t clientdiff = g_clientQuestions - g_clientResponses; int64_t serverdiff = g_serverQuestions - g_serverResponses; if(clientdiff > 5 && clientdiff > 0.02*g_clientQuestions) { char tmp[80]; struct tm tm=*pdns_localtime_r(&tv.tv_sec, &tm); strftime(tmp, sizeof(tmp) - 1, "%F %H:%M:%S", &tm); cout << tmp << ": Resolver dropped too many questions (" << g_clientQuestions <<" vs " << g_clientResponses << "), diff: " < 5 && serverdiff > 0.02*g_serverQuestions) { char tmp[80]; struct tm tm=*pdns_localtime_r(&tv.tv_sec, &tm); strftime(tmp, sizeof(tmp) - 1, "%F %H:%M:%S", &tm); cout << tmp << ": Auth server dropped too many questions (" << g_serverQuestions <<" vs " << g_serverResponses << "), diff: " < > queries_t; queries_t questions, answers; // unsigned int count = 50000; map, int> counts; while(pr.getUDPPacket()) { if((ntohs(pr.d_udp->uh_dport)==5300 || ntohs(pr.d_udp->uh_sport)==5300 || ntohs(pr.d_udp->uh_dport)==53 || ntohs(pr.d_udp->uh_sport)==53) && pr.d_len > 12) { try { MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); if(mdp.d_header.id==htons(4575)) { // cerr << ntohl(*(uint32_t*)&pr.d_ip->ip_src)< 1176897290 && pr.d_pheader.ts.tv_sec < 1176897310 ) // pw.write(); if(mdp.d_header.rd && !mdp.d_header.qr) { g_lastquestionTime=pr.d_pheader.ts; g_clientQuestions++; totalQueries++; counts[make_pair(mdp.d_qname, mdp.d_qtype)]++; questions.insert(make_pair(mdp.d_qname, mdp.d_qtype)); } else if(mdp.d_header.rd && mdp.d_header.qr) { g_lastanswerTime=pr.d_pheader.ts; g_clientResponses++; answers.insert(make_pair(mdp.d_qname, mdp.d_qtype)); } else if(!mdp.d_header.rd && !mdp.d_header.qr) { g_lastquestionTime=pr.d_pheader.ts; g_serverQuestions++; counts[make_pair(mdp.d_qname, mdp.d_qtype)]++; questions.insert(make_pair(mdp.d_qname, mdp.d_qtype)); totalQueries++; } else if(!mdp.d_header.rd && mdp.d_header.qr) { answers.insert(make_pair(mdp.d_qname, mdp.d_qtype)); g_serverResponses++; } if(pr.d_pheader.ts.tv_sec - lastreport.tv_sec > 5) { makeReport(pr.d_pheader.ts); lastreport = pr.d_pheader.ts; } } catch(MOADNSException& mde) { // cerr<<"error parsing packet: "< diff_t; diff_t diff; set_difference(questions.begin(), questions.end(), answers.begin(), answers.end(), back_inserter(diff)); cerr<first << "\t" << DNSRecordContent::NumberToType(i->second) << "\t"<< counts[make_pair(i->first, i->second)]<<"\n"; } diff.clear(); set_difference(answers.begin(), answers.end(), questions.begin(), questions.end(), back_inserter(diff)); cerr<first << "\t" <second) << "\t" << counts[make_pair(i->first, i->second)]<<"\n"; } } } catch(std::exception& e) { cerr<<"Fatal: "< #include "dnsparser.hh" #include "iputils.hh" #undef L #include #include #include #include #include #include #include #include #include #include #include #include "dnsrecords.hh" #include "mplexer.hh" #include "statbag.hh" #include "namespaces.hh" using namespace ::boost::multi_index; #include "namespaces.hh" namespace po = boost::program_options; po::variables_map g_vm; StatBag S; SelectFDMultiplexer g_fdm; int g_pdnssocket; bool g_verbose; struct NotificationInFlight { ComboAddress source; time_t resentTime; string domain; uint16_t origID, resentID; int origSocket; }; typedef map nifs_t; nifs_t g_nifs; void syslogFmt(const boost::format& fmt) { cerr<<"nproxy: "< packet; DNSPacketWriter pw(packet, mdp.d_qname, mdp.d_qtype); pw.getHeader()->id = mdp.d_header.id; pw.getHeader()->rd = mdp.d_header.rd; pw.getHeader()->qr = 1; pw.startRecord(mdp.d_qname, mdp.d_qtype); if(mdp.d_qtype == QType::TXT) { TXTRecordContent trc("\"OK\""); trc.toPacket(pw); } else if(mdp.d_qtype == QType::A) { ARecordContent arc("1.2.3.4"); arc.toPacket(pw); } pw.commit(); if(sendto(fd, &packet[0], packet.size(), 0, (struct sockaddr*)&nif.source, socklen) < 0) { syslogFmt(boost::format("Unable to send health check response to external nameserver %s - %s") % nif.source.toStringWithPort() % stringerror()); } return; } if(mdp.d_header.opcode != Opcode::Notify || mdp.d_qtype != QType::SOA) { syslogFmt(boost::format("Received non-notification packet for domain '%s' from external nameserver %s") % nif.domain % nif.source.toStringWithPort()); return; } syslogFmt(boost::format("External notification received for domain '%s' from %s") % nif.domain % nif.source.toStringWithPort()); vector outpacket; DNSPacketWriter pw(outpacket, mdp.d_qname, mdp.d_qtype, 1, Opcode::Notify); static uint16_t s_idpool; pw.getHeader()->id = nif.resentID = s_idpool++; if(send(g_pdnssocket, &outpacket[0], outpacket.size(), 0) < 0) { throw runtime_error("Unable to send notify to PowerDNS: "+stringerror()); } nif.resentTime=time(0); g_nifs[nif.resentID] = nif; } catch(std::exception &e) { syslogFmt(boost::format("Error parsing packet from external nameserver: %s") % e.what()); } void handleInsideUDPPacket(int fd, boost::any&) try { char buffer[1500]; struct NotificationInFlight nif; socklen_t socklen=sizeof(nif.source); int len=recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&nif.source, &socklen); if(!len) return; if(len < 0) throw runtime_error("reading packet from remote: "+stringerror()); string packet(buffer, len); MOADNSParser mdp(packet); // cerr<<"Inside notification response for: "<second.resentTime < limit) { syslogFmt(boost::format("Notification for domain '%s' was sent to inner nameserver, but no response within 10 seconds") % iter->second.domain); g_nifs.erase(iter++); } else ++iter; } } void daemonize(); int main(int argc, char** argv) try { reportAllTypes(); openlog("nproxy", LOG_NDELAY | LOG_PID, LOG_DAEMON); po::options_description desc("Allowed options"); desc.add_options() ("help,h", "produce help message") ("powerdns-address", po::value(), "IP address of PowerDNS server") ("chroot", po::value(), "chroot to this directory for additional security") ("setuid", po::value(), "setuid to this numerical user id") ("setgid", po::value(), "setgid to this numerical user id") ("origin-address", po::value()->default_value("::"), "Source address for notifications to PowerDNS") ("listen-address", po::value >(), "IP addresses to listen on") ("listen-port", po::value()->default_value(53), "Source port to listen on") ("daemon,d", po::value()->default_value(true), "operate in the background") ("verbose,v", "be verbose"); po::store(po::command_line_parser(argc, argv).options(desc).run(), g_vm); po::notify(g_vm); if (g_vm.count("help")) { cerr << desc << "\n"; return EXIT_SUCCESS; } if(!g_vm.count("powerdns-address")) { cerr<<"Mandatory setting 'powerdns-address' unset:\n"< addresses; if(g_vm.count("listen-address")) addresses=g_vm["listen-address"].as >(); else addresses.push_back("::"); // create sockets to listen on syslogFmt(boost::format("Starting up")); for(vector::const_iterator address = addresses.begin(); address != addresses.end(); ++address) { ComboAddress local(*address, g_vm["listen-port"].as()); int sock = socket(local.sin4.sin_family, SOCK_DGRAM, 0); if(sock < 0) throw runtime_error("Creating socket for incoming packets: "+stringerror()); if(::bind(sock,(sockaddr*) &local, local.getSocklen()) < 0) throw runtime_error("Binding socket for incoming packets to '"+ local.toStringWithPort()+"': "+stringerror()); g_fdm.addReadFD(sock, handleOutsideUDPPacket); // add to fdmultiplexer for each socket syslogFmt(boost::format("Listening for external notifications on address %s") % local.toStringWithPort()); } // create socket that talks to inner PowerDNS ComboAddress originAddress(g_vm["origin-address"].as(), 0); g_pdnssocket=socket(originAddress.sin4.sin_family, SOCK_DGRAM, 0); if(g_pdnssocket < 0) throw runtime_error("Creating socket for packets to PowerDNS: "+stringerror()); if(::bind(g_pdnssocket,(sockaddr*) &originAddress, originAddress.getSocklen()) < 0) throw runtime_error("Binding local address of inward socket to '"+ originAddress.toStringWithPort()+"': "+stringerror()); ComboAddress pdns(g_vm["powerdns-address"].as(), 53); if(connect(g_pdnssocket, (struct sockaddr*) &pdns, pdns.getSocklen()) < 0) throw runtime_error("Failed to connect PowerDNS socket to address "+pdns.toStringWithPort()+": "+stringerror()); syslogFmt(boost::format("Sending notifications from %s to internal address %s") % originAddress.toString() % pdns.toStringWithPort()); g_fdm.addReadFD(g_pdnssocket, handleInsideUDPPacket); if(g_vm.count("chroot")) { if(chroot(g_vm["chroot"].as().c_str()) < 0) throw runtime_error("while chrooting to "+g_vm["chroot"].as()); syslogFmt(boost::format("Changed root to directory '%s'") % g_vm["chroot"].as()); } if(g_vm.count("setgid")) { if(setgid(g_vm["setgid"].as()) < 0) throw runtime_error("while changing gid to "+g_vm["setgid"].as()); syslogFmt(boost::format("Changed gid to %d") % g_vm["setgid"].as()); if(setgroups(0, NULL) < 0) throw runtime_error("while dropping supplementary groups"); } if(g_vm.count("setuid")) { if(setuid(g_vm["setuid"].as()) < 0) throw runtime_error("while changing uid to "+g_vm["setuid"].as()); syslogFmt(boost::format("Changed uid to %d") % g_vm["setuid"].as()); } if(g_vm["daemon"].as()) { syslogFmt(boost::format("Daemonizing")); daemonize(); } syslogFmt(boost::format("Program operational")); // start loop struct timeval now; for(;;) { gettimeofday(&now, 0); g_fdm.run(&now); // check for notifications that have been outstanding for more than 10 seconds expireOldNotifications(); } } catch(boost::program_options::error& e) { syslogFmt(boost::format("Error parsing command line options: %s") % e.what()); } catch(std::exception& e) { syslogFmt(boost::format("Fatal: %s") % e.what()); } catch(AhuException& e) { syslogFmt(boost::format("Fatal: %s") % e.reason); } void daemonize(void) { if(fork()) exit(0); // bye bye setsid(); int i=open("/dev/null",O_RDWR); /* open stdin */ if(i < 0) cerr<<"Unable to open /dev/null: "< #include #include #include "namespaces.hh" /** The QType class is meant to deal easily with the different kind of resource types, like 'A', 'NS', * 'CNAME' etcetera. These types have both a name and a number. This class can seamlessly move between * them. Use it like this: \code QType t; t="CNAME"; cout< void serialize(Archive &ar, const unsigned int version) { ar & code; } const string getName() const; //!< Get a string representation of this type uint16_t getCode() const; //!< Get the integer representation of this type static int chartocode(const char *p); //!< convert a character string to a code // more solaris fun #undef DS enum typeenum {A=1,NS=2,CNAME=5,SOA=6, MR=9, PTR=12,HINFO=13,MX=15,TXT=16,RP=17,AFSDB=18, SIG=24, KEY=25,AAAA=28,LOC=29,SRV=33,NAPTR=35, KX=36, CERT=37, A6=38, OPT=41, DS=43, SSHFP=44, IPSECKEY=45, RRSIG=46, NSEC=47, DNSKEY=48, DHCID=49, NSEC3=50, NSEC3PARAM=51, TLSA=52, SPF=99, EUI48=108, EUI64=109, TSIG=250, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259, DLV=32769} types; typedef pair namenum; static vector names; inline bool operator==(const QType &comp) const { return(comp.code==code); } inline bool operator!=(const QType &comp) const { return(comp.code!=code); } inline bool operator==(QType::typeenum comp) const { return(comp==code); } inline bool operator!=(QType::typeenum comp) const { return(comp!=code); } private: static class init { public: void qtype_insert(const char* a, uint16_t num) { names.push_back(make_pair(string(a), num)); } init() { qtype_insert("A",1); qtype_insert("NS",2); qtype_insert("CNAME",5); qtype_insert("SOA",6); qtype_insert("MR",9); qtype_insert("PTR",12); qtype_insert("HINFO",13); qtype_insert("MINFO",14); qtype_insert("MX",15); qtype_insert("TXT",16); qtype_insert("RP",17); qtype_insert("AFSDB", 18); qtype_insert("SIG",24); qtype_insert("KEY",25); qtype_insert("AAAA",28); qtype_insert("LOC",29); qtype_insert("SRV",33); qtype_insert("NAPTR",35); qtype_insert("KX",36); qtype_insert("CERT", 37); qtype_insert("A6",38); qtype_insert("OPT",41); qtype_insert("DS", 43); qtype_insert("SSHFP", 44); qtype_insert("IPSECKEY", 45); qtype_insert("RRSIG", 46); qtype_insert("NSEC", 47); qtype_insert("DNSKEY", 48); qtype_insert("DHCID", 49); qtype_insert("NSEC3", 50); qtype_insert("NSEC3PARAM", 51); qtype_insert("TLSA",52); qtype_insert("SPF",99); qtype_insert("EUI48",108); qtype_insert("EUI64",109); // qtype_insert("TSIG", 250); qtype_insert("IXFR",251); qtype_insert("AXFR",252); qtype_insert("ANY",255); qtype_insert("URL",256); qtype_insert("MBOXFW",257); qtype_insert("CURL",258); qtype_insert("ADDR",259); qtype_insert("DLV",32769); } } initializer; uint16_t code; }; struct QClass { enum QClassEnum {IN=1, CHAOS=3}; }; #endif pdns-3.3/pdns/mastercommunicator.cc0000644000014601777760000001647112141714530020761 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include #include "communicator.hh" #include #include #include #include "dnsbackend.hh" #include "ueberbackend.hh" #include "packethandler.hh" #include "nameserver.hh" #include "resolver.hh" #include "logger.hh" #include "dns.hh" #include "arguments.hh" #include "session.hh" #include "packetcache.hh" #include #include "namespaces.hh" void CommunicatorClass::queueNotifyDomain(const string &domain, DNSBackend *B) { set ips; FindNS fns; DNSResourceRecord rr; set nsset; B->lookup(QType(QType::NS),domain); while(B->get(rr)) nsset.insert(rr.content); for(set::const_iterator j=nsset.begin();j!=nsset.end();++j) { vector nsips=fns.lookup(*j, B); if(nsips.empty()) L<::const_iterator k=nsips.begin();k!=nsips.end();++k) ips.insert(*k); } // make calls to d_nq.add(domain, ip); for(set::const_iterator j=ips.begin();j!=ips.end();++j) { L<alsoNotify; B->alsoNotifies(domain, &alsoNotify); for(set::const_iterator j=alsoNotify.begin();j!=alsoNotify.end();++j) { L<getDomainInfo(domain, di)) { L<setNotified(di.id, di.serial); return true; } void NotificationQueue::dump() { cerr<<"Waiting for notification responses: "<(P->getBackend()); vector cmdomains; B->getUpdatedMasters(&cmdomains); if(cmdomains.empty()) { if(d_masterschanged) L<1 ? "s" : "")<<" for which we are master need"<< (cmdomains.size()>1 ? "" : "s")<< " notifications"<::const_iterator i=cmdomains.begin();i!=cmdomains.end();++i) { extern PacketCache PC; PC.purge(i->zone); // fixes cvstrac ticket #30 queueNotifyDomain(i->zone,P->getBackend()); i->backend->setNotified(i->id,i->serial); } } time_t CommunicatorClass::doNotifications() { ComboAddress from; Utility::socklen_t fromlen=sizeof(from); char buffer[1500]; int size, sock; // receive incoming notifications on the nonblocking socket and take them off the list while(waitFor2Data(d_nsock4, d_nsock6, 0, 0, &sock) > 0) { size=recvfrom(sock,buffer,sizeof(buffer),0,(struct sockaddr *)&from,&fromlen); if(size < 0) break; DNSPacket p; p.setRemote(&from); if(p.parse(buffer,size)<0) { L< packet; DNSPacketWriter pw(packet, domain, QType::SOA, 1, Opcode::Notify); pw.getHeader()->id = id; pw.getHeader()->aa = true; if(sendto(sock, &packet[0], packet.size(), 0, (struct sockaddr*)(&remote), remote.getSocklen()) < 0) { throw ResolverException("Unable to send notify to "+remote.toStringWithPort()+": "+stringerror()); } } void CommunicatorClass::drillHole(const string &domain, const string &ip) { Lock l(&d_holelock); d_holes[make_pair(domain,ip)]=time(0); } bool CommunicatorClass::justNotified(const string &domain, const string &ip) { Lock l(&d_holelock); if(d_holes.find(make_pair(domain,ip))==d_holes.end()) // no hole return false; if(d_holes[make_pair(domain,ip)]>time(0)-900) // recent hole return true; // do we want to purge this? XXX FIXME return false; } void CommunicatorClass::makeNotifySockets() { d_nsock4 = makeQuerySocket(ComboAddress(::arg()["query-local-address"]), true); if(!::arg()["query-local-address6"].empty()) d_nsock6 = makeQuerySocket(ComboAddress(::arg()["query-local-address6"]), true); else d_nsock6 = -1; } void CommunicatorClass::notify(const string &domain, const string &ip) { d_nq.add(domain, ip); d_any_sem.post(); } pdns-3.3/pdns/dynlistener.cc0000644000014601777760000002642712155641611017413 0ustar00jenkinsnogroup00000000000000 /* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "misc.hh" #include "dns.hh" #include "arguments.hh" #include "dnsbackend.hh" #include "dynlistener.hh" #include "dnspacket.hh" #include "logger.hh" #include "statbag.hh" extern StatBag S; DynListener::g_funkdb_t DynListener::s_funcdb; DynListener::g_funk_t* DynListener::s_restfunc; DynListener::~DynListener() { if(!d_socketname.empty()) unlink(d_socketname.c_str()); } void DynListener::createSocketAndBind(int family, struct sockaddr*local, size_t len) { d_s=socket(family, SOCK_STREAM,0); Utility::setCloseOnExec(d_s); if(d_s < 0) { if (family == AF_UNIX) L<sun_path<<"', reason: "<toStringWithPort()<<"', reason: "<sun_path<<"', reason: "<toStringWithPort()<<"', reason: "<(-1),Utility::makeGidNumeric(arg()["setgid"]))<0) L< ips; stringtok(ips, ::arg()["tcp-control-range"], ", "); L<::const_iterator i = ips.begin(); i!= ips.end(); ++i) { d_tcprange.addMask(*i); if(i!=ips.begin()) L<(p); us->theListener(); L< mesg; mesg.resize(1024000); int len; ComboAddress remote; socklen_t remlen=remote.getSocklen(); if(d_nonlocal) { for(;;) { d_client=accept(d_s,(sockaddr*)&remote,&remlen); if(d_client<0) { if(errno!=EINTR) L< fp=boost::shared_ptr(fdopen(dup(d_client), "r"), fclose); if(d_tcp) { if(!fgets(&mesg[0], mesg.size(), fp.get())) { L< parameters; signal(SIGPIPE,SIG_IGN); for(int n=0;;++n) { // cerr<<"Reading new line, "<parts; stringtok(parts,line," "); if(parts.empty()) { sendLine("Empty line"); continue; } parts[0] = toUpper( parts[0] ); if(!s_funcdb.count(parts[0])) { if(parts[0] == "HELP") sendLine(getHelp()); else if(s_restfunc) sendLine((*s_restfunc)(parts,d_ppid)); else sendLine("Unknown command: '"+parts[0]+"'"); continue; } sendLine((*(s_funcdb[parts[0]].func))(parts,d_ppid)); } } catch(AhuException &AE) { L< funcs; string rest; // s_restfunc, when in guardian mode, is the function that // can pass commands on to the guarded instance // we just pass it HELP and merge it with our own list if(s_restfunc) { vector parts; parts.push_back("HELP"); rest=((*s_restfunc)(parts,d_ppid)); boost::split(funcs, rest, boost::is_any_of("\n")); } const boost::format fmter("%|-32| %||"); for(g_funkdb_t::const_iterator i=s_funcdb.begin();i!=s_funcdb.end();++i) { funcs.push_back(str(boost::format(fmter) % (toLower(i->first)+" "+i->second.args) % i->second.usage)); } sort(funcs.begin(), funcs.end()); // hack: this removes the duplicate quit method funcs.resize(unique(funcs.begin(), funcs.end()) - funcs.begin()); return boost::join(funcs, "\n"); } pdns-3.3/pdns/depcomp0000755000014601777760000002752512136555572016132 0ustar00jenkinsnogroup00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, 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. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. This file always lives in the current directory. # Also, the AIX compiler puts `$object:' at the start of each line; # $object doesn't have directory information. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" outname="$stripped.o" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; tru64) # The Tru64 AIX compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. tmpdepfile1="$object.d" tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` if test "$libtool" = yes; then "$@" -Wc,-MD else "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a space and a tab in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. test -z "$dashmflag" && dashmflag=-M ( IFS=" " case " $* " in *" --mode=compile "*) # this is libtool, let us make it quiet for arg do # cycle over the arguments case "$arg" in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) # X makedepend ( shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift;; -*) ;; *) set fnord "$@" "$arg"; shift;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tail +3 "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 pdns-3.3/pdns/sstuff.hh0000644000014601777760000001605512136555572016404 0ustar00jenkinsnogroup00000000000000#ifndef SSTUFF_HH #define SSTUFF_HH #include #include #include #include "iputils.hh" #include #include #ifndef WIN32 #include #include #include #include #include #endif #include #include #include #include #include #include "namespaces.hh" #include "namespaces.hh" class NetworkError : public runtime_error { public: NetworkError(const string& why="Network Error") : runtime_error(why.c_str()) {} NetworkError(const char *why="Network Error") : runtime_error(why) {} }; enum AddressFamily {InterNetwork=AF_INET, InterNetwork6 = AF_INET6}; //!< Supported address families enum SocketType {Datagram=SOCK_DGRAM,Stream=SOCK_STREAM}; //!< Supported socket families typedef int ProtocolType; //!< Supported protocol types //! Representation of a Socket and many of the Berkeley functions available class Socket : public boost::noncopyable { private: explicit Socket(int fd) { d_buflen=4096; d_buffer=new char[d_buflen]; d_socket=fd; } public: //! Construct a socket of specified AddressFamily and SocketType. Socket(AddressFamily af, SocketType st, ProtocolType pt=0) { d_family=af; if((d_socket=(int)socket(af,st, pt))<0) throw NetworkError(strerror(errno)); Utility::setCloseOnExec(d_socket); d_buflen=4096; d_buffer=new char[d_buflen]; } ~Socket() { Utility::closesocket(d_socket); delete[] d_buffer; } //! If the socket is capable of doing so, this function will wait for a connection Socket *accept() { struct sockaddr_in remote; socklen_t remlen=sizeof(remote); memset(&remote, 0, sizeof(remote)); int s=(int)::accept(d_socket,(sockaddr *)&remote, &remlen); if(s<0) { if(errno==EAGAIN) return 0; throw NetworkError("Accepting a connection: "+string(strerror(errno))); } return new Socket(s); } //! Set the socket to non-blocking void setNonBlocking() { Utility::setNonBlocking(d_socket); } //! Bind the socket to a specified endpoint void bind(const ComboAddress &local) { int tmp=1; if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) throw NetworkError(string("Setsockopt failed: ")+strerror(errno)); if(::bind(d_socket,(struct sockaddr *)&local, local.getSocklen())<0) throw NetworkError(strerror(errno)); } #if 0 //! Bind the socket to a specified endpoint void bind(const ComboAddress &ep) { ComboAddress local; memset(reinterpret_cast(&local),0,sizeof(local)); local.sin_family=d_family; local.sin_addr.s_addr=ep.address.byte; local.sin_port=htons(ep.port); bind(local); } #endif //! Connect the socket to a specified endpoint void connect(const ComboAddress &ep) { if(::connect(d_socket,(struct sockaddr *)&ep, ep.getSocklen()) < 0 && errno != EINPROGRESS) throw NetworkError(strerror(errno)); } //! For datagram sockets, receive a datagram and learn where it came from /** For datagram sockets, receive a datagram and learn where it came from \param dgram Will be filled with the datagram \param ep Will be filled with the origin of the datagram */ void recvFrom(string &dgram, ComboAddress &ep) { socklen_t remlen=sizeof(ep); int bytes; if((bytes=recvfrom(d_socket, d_buffer, d_buflen, 0, (sockaddr *)&ep , &remlen)) <0) throw NetworkError(strerror(errno)); dgram.assign(d_buffer,bytes); } bool recvFromAsync(string &dgram, ComboAddress &ep) { struct sockaddr_in remote; socklen_t remlen=sizeof(remote); int bytes; if((bytes=recvfrom(d_socket, d_buffer, d_buflen, 0, (sockaddr *)&remote, &remlen))<0) { if(errno!=EAGAIN) { throw NetworkError(strerror(errno)); } else { return false; } } dgram.assign(d_buffer,bytes); return true; } //! For datagram sockets, send a datagram to a destination /** For datagram sockets, send a datagram to a destination \param dgram The datagram \param ep The intended destination of the datagram */ void sendTo(const string &dgram, const ComboAddress &ep) { if(sendto(d_socket, dgram.c_str(), (int)dgram.size(), 0, (sockaddr *)&ep, ep.getSocklen())<0) throw NetworkError(strerror(errno)); } //! Write this data to the socket, taking care that all bytes are written out void writen(const string &data) { if(data.empty()) return; int toWrite=(int)data.length(); int res; const char *ptr=data.c_str(); do { res=::send(d_socket, ptr, toWrite, 0); if(res<0) throw NetworkError("Writing to a socket: "+string(strerror(errno))); if(!res) throw NetworkError("EOF on socket"); toWrite-=res; ptr+=res; }while(toWrite); } //! tries to write toWrite bytes from ptr to the socket /** tries to write toWrite bytes from ptr to the socket, but does not make sure they al get written out \param ptr Location to write from \param toWrite number of bytes to try */ unsigned int tryWrite(const char *ptr, int toWrite) { int res; res=::send(d_socket,ptr,toWrite,0); if(res==0) throw NetworkError("EOF on writing to a socket"); if(res>0) return res; if(errno==EAGAIN) return 0; throw NetworkError("Writing to a socket: "+string(strerror(errno))); } //! Writes toWrite bytes from ptr to the socket /** Writes toWrite bytes from ptr to the socket. Returns how many bytes were written */ unsigned int write(const char *ptr, int toWrite) { int res; res=::send(d_socket,ptr,toWrite,0); if(res<0) { throw NetworkError("Writing to a socket: "+string(strerror(errno))); } return res; } //! reads one character from the socket int getChar() { char c; int res=::recv(d_socket,&c,1,0); if(res) return c; return -1; } void getline(string &data) { data=""; int c; while((c=getChar())!=-1) { data+=(char)c; if(c=='\n') break; } } //! Reads a block of data from the socket to a string void read(string &data) { int res=::recv(d_socket,d_buffer,d_buflen,0); if(res<0) throw NetworkError("Reading from a socket: "+string(strerror(errno))); data.assign(d_buffer,res); } //! Reads a block of data from the socket to a block of memory int read(char *buffer, int bytes) { int res=::recv(d_socket,buffer,bytes,0); if(res<0) throw NetworkError("Reading from a socket: "+string(strerror(errno))); return res; } //! Sets the socket to listen with a default listen backlog of 10 bytes void listen(unsigned int length=10) { if(::listen(d_socket,length)<0) throw NetworkError("Setting socket to listen: "+string(strerror(errno))); } //! Returns the internal file descriptor of the socket int getHandle() const { return d_socket; } private: int d_socket; char *d_buffer; int d_buflen; int d_family; }; #endif pdns-3.3/pdns/ssqlite3.hh0000644000014601777760000000254612136555572016641 0ustar00jenkinsnogroup00000000000000 // // SQLite backend for PowerDNS // Copyright (C) 2003, Michel Stol // #ifndef SSQLITE3_HH #define SSQLITE3_HH #include #include "pdns/backends/gsql/ssql.hh" class SSQLite3 : public SSql { private: //! Pointer to the SQLite database instance. sqlite3 *m_pDB; //! Pointer to the SQLite virtual machine executing a query. sqlite3_stmt *m_pStmt; bool m_dolog; static int busyHandler(void*, int); protected: public: //! Constructor. SSQLite3( const std::string & database, bool creat=false ); //! Destructor. ~SSQLite3(); //! Performs a query and puts answers in result int doQuery( const std::string & query, result_t & result ); //! Performs a query, caller can retrieve answers with getRow int doQuery( const std::string & query ); //! Performs a command that does not return rows int doCommand( const std::string & query ) { result_t result; return doQuery(query, result); // 'result' is necessary to force doQuery to do the work, closing Debian bug 280359 } //! Returns a row from a result set. bool getRow( row_t & row ); //! Escapes the SQL query. std::string escape( const std::string & query ); void setLog(bool state); //! Used to create an backend specific exception message. SSqlException sPerrorException( const std::string & reason ); }; #endif // SSQLITE3_HH pdns-3.3/pdns/dnspacket.cc0000644000014601777760000003714612160606640017026 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2001 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include #include #include #include #include #include #include #include #include #include #include "dnsseckeeper.hh" #include "dns.hh" #include "dnsbackend.hh" #include "ahuexception.hh" #include "dnspacket.hh" #include "logger.hh" #include "arguments.hh" #include "dnswriter.hh" #include "dnsparser.hh" #include "dnsrecords.hh" #include "dnssecinfra.hh" #include "base64.hh" #include "ednssubnet.hh" bool DNSPacket::s_doEDNSSubnetProcessing; DNSPacket::DNSPacket() { d_wrapped=false; d_compress=true; d_tcp=false; d_wantsnsid=false; d_haveednssubnet = false; d_dnssecOk=false; } const string& DNSPacket::getString() { if(!d_wrapped) wrapup(); return d_rawpacket; } string DNSPacket::getRemote() const { return d_remote.toString(); } uint16_t DNSPacket::getRemotePort() const { return d_remote.sin4.sin_port; } DNSPacket::DNSPacket(const DNSPacket &orig) { DLOG(L<<"DNSPacket copy constructor called!"<::const_iterator i=d_rrs.begin();i!=d_rrs.end();++i) if(rr.qname==i->qname && rr.qtype==i->qtype && rr.content==i->content) { if(rr.qtype.getCode()!=QType::MX && rr.qtype.getCode()!=QType::SRV) return; if(rr.priority==i->priority) return; } d_rrs.push_back(rr); } static int rrcomp(const DNSResourceRecord &A, const DNSResourceRecord &B) { if(A.d_place < B.d_place) return 1; return 0; } vector DNSPacket::getAPRecords() { vector arrs; for(vector::iterator i=d_rrs.begin(); i!=d_rrs.end(); ++i) { if(i->d_place!=DNSResourceRecord::ADDITIONAL && (i->qtype.getCode()==QType::MX || i->qtype.getCode()==QType::NS || i->qtype.getCode()==QType::SRV)) { arrs.push_back(&*i); } } return arrs; } vector DNSPacket::getAnswerRecords() { vector arrs; for(vector::iterator i=d_rrs.begin(); i!=d_rrs.end(); ++i) { if(i->d_place!=DNSResourceRecord::ADDITIONAL) arrs.push_back(&*i); } return arrs; } void DNSPacket::setCompress(bool compress) { d_compress=compress; d_rawpacket.reserve(65000); d_rrs.reserve(200); } bool DNSPacket::couldBeCached() { return d_ednsping.empty() && !d_wantsnsid && qclass==QClass::IN; } unsigned int DNSPacket::getMinTTL() { unsigned int minttl = UINT_MAX; BOOST_FOREACH(DNSResourceRecord rr, d_rrs) { if (rr.ttl < minttl) minttl = rr.ttl; } return minttl; } /** Must be called before attempting to access getData(). This function stuffs all resource * records found in rrs into the data buffer. It also frees resource records queued for us. */ void DNSPacket::wrapup() { if(d_wrapped) { return; } DNSResourceRecord rr; vector::iterator pos; // we now need to order rrs so that the different sections come at the right place // we want a stable sort, based on the d_place field stable_sort(d_rrs.begin(),d_rrs.end(), rrcomp); static bool mustNotShuffle = ::arg().mustDo("no-shuffle"); if(!d_tcp && !mustNotShuffle) { shuffle(d_rrs); } d_wrapped=true; vector packet; DNSPacketWriter pw(packet, qdomain, qtype.getCode(), qclass); pw.getHeader()->rcode=d.rcode; pw.getHeader()->opcode = d.opcode; pw.getHeader()->aa=d.aa; pw.getHeader()->ra=d.ra; pw.getHeader()->qr=d.qr; pw.getHeader()->id=d.id; pw.getHeader()->rd=d.rd; pw.getHeader()->tc=d.tc; DNSPacketWriter::optvect_t opts; if(d_wantsnsid) { opts.push_back(make_pair(3, ::arg()["server-id"])); } if(!d_ednsping.empty()) { opts.push_back(make_pair(4, d_ednsping)); } if(!d_rrs.empty() || !opts.empty() || d_haveednssubnet || d_haveednssection) { try { uint8_t maxScopeMask=0; for(pos=d_rrs.begin(); pos < d_rrs.end(); ++pos) { maxScopeMask = max(maxScopeMask, pos->scopeMask); // this needs to deal with the 'prio' mismatch: if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) { pos->content = lexical_cast(pos->priority) + " " + pos->content; } if(!pos->content.empty() && pos->qtype.getCode()==QType::TXT && pos->content[0]!='"') { pos->content="\""+pos->content+"\""; } if(pos->content.empty()) // empty contents confuse the MOADNS setup pos->content="."; pw.startRecord(pos->qname, pos->qtype.getCode(), pos->ttl, pos->qclass, (DNSPacketWriter::Place)pos->d_place); shared_ptr drc(DNSRecordContent::mastermake(pos->qtype.getCode(), 1, pos->content)); drc->toPacket(pw); if(pw.size() + 20U > (d_tcp ? 65535 : getMaxReplyLen())) { // 20 = room for EDNS0 pw.rollback(); if(pos->d_place == DNSResourceRecord::ANSWER || pos->d_place == DNSResourceRecord::AUTHORITY) { pw.getHeader()->tc=1; } goto noCommit; } } // if(!pw.getHeader()->tc) // protect against double commit from addSignature if(!d_rrs.empty()) pw.commit(); noCommit:; if(d_haveednssubnet) { string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso); EDNSSubnetOpts eso = d_eso; eso.scope = Netmask(eso.source.getNetwork(), maxScopeMask); string opt = makeEDNSSubnetOptsString(eso); opts.push_back(make_pair(::arg().asNum("edns-subnet-option-number"), opt)); } if(!opts.empty() || d_haveednssection || d_dnssecOk) { pw.addOpt(2800, 0, d_dnssecOk ? EDNSOpts::DNSSECOK : 0, opts); pw.commit(); } } catch(std::exception& e) { L<setSocket(d_socket); r->d_anyLocal=d_anyLocal; r->setRemote(&d_remote); r->setAnswer(true); // this implies the allocation of the header r->setA(true); // and we are authoritative r->setRA(0); // no recursion available r->setRD(d.rd); // if you wanted to recurse, answer will say you wanted it r->setID(d.id); r->setOpcode(d.opcode); r->d_dt=d_dt; r->d.qdcount=1; r->d_tcp = d_tcp; r->qdomain = qdomain; r->qtype = qtype; r->qclass = qclass; r->d_maxreplylen = d_maxreplylen; r->d_ednsping = d_ednsping; r->d_wantsnsid = d_wantsnsid; r->d_dnssecOk = d_dnssecOk; r->d_eso = d_eso; r->d_haveednssubnet = d_haveednssubnet; r->d_haveednssection = d_haveednssection; if(!d_tsigkeyname.empty()) { r->d_tsigkeyname = d_tsigkeyname; r->d_tsigprevious = d_tsigprevious; r->d_trc = d_trc; r->d_tsigsecret = d_tsigsecret; r->d_tsigtimersonly = d_tsigtimersonly; } r->d_havetsig = d_havetsig; return r; } void DNSPacket::spoofQuestion(const DNSPacket *qd) { d_wrapped=true; // if we do this, don't later on wrapup int labellen; string::size_type i=sizeof(d); for(;;) { labellen = qd->d_rawpacket[i]; if(!labellen) break; i++; d_rawpacket.replace(i, labellen, qd->d_rawpacket, i, labellen); i = i + labellen; } } int DNSPacket::noparse(const char *mesg, int length) { d_rawpacket.assign(mesg,length); if(length < 12) { L << Logger::Warning << "Ignoring packet: too short from " << getRemote() << endl; return -1; } d_wantsnsid=false; d_ednsping.clear(); d_maxreplylen=512; memcpy((void *)&d,(const void *)d_rawpacket.c_str(),12); return 0; } void DNSPacket::setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly) { d_trc=tr; d_tsigkeyname = keyname; d_tsigsecret = secret; d_tsigprevious = previous; d_tsigtimersonly=timersonly; } bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, string* keyname, string* message) const { MOADNSParser mdp(d_rawpacket); if(!mdp.getTSIGPos()) return false; bool gotit=false; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { if(i->first.d_type == QType::TSIG) { *trc = *boost::dynamic_pointer_cast(i->first.d_content); gotit=true; *keyname = i->first.d_label; if(!keyname->empty()) keyname->resize(keyname->size()-1); // drop the trailing dot } } if(!gotit) return false; if(message) *message = makeTSIGMessageFromTSIGPacket(d_rawpacket, mdp.getTSIGPos(), *keyname, *trc, d_tsigprevious, false); // if you change rawpacket to getString it breaks! return true; } /** This function takes data from the network, possibly received with recvfrom, and parses it into our class. Results of calling this function multiple times on one packet are unknown. Returns -1 if the packet cannot be parsed. */ int DNSPacket::parse(const char *mesg, int length) try { d_rawpacket.assign(mesg,length); d_wrapped=true; if(length < 12) { L << Logger::Warning << "Ignoring packet: too short from " << getRemote() << endl; return -1; } MOADNSParser mdp(d_rawpacket); EDNSOpts edo; // ANY OPTION WHICH *MIGHT* BE SET DOWN BELOW SHOULD BE CLEARED FIRST! d_wantsnsid=false; d_dnssecOk=false; d_ednsping.clear(); d_havetsig = mdp.getTSIGPos(); d_haveednssubnet = false; d_haveednssection = false; if(getEDNSOpts(mdp, &edo)) { d_haveednssection=true; d_maxreplylen=std::min(edo.d_packetsize, (uint16_t)1680); // cerr< >::const_iterator iter = edo.d_options.begin(); iter != edo.d_options.end(); ++iter) { if(iter->first == 3) {// 'EDNS NSID' d_wantsnsid=1; } else if(iter->first == 5) {// 'EDNS PING' d_ednsping = iter->second; } else if(s_doEDNSSubnetProcessing && iter->first == ::arg().asNum("edns-subnet-option-number")) { // 'EDNS SUBNET' if(getEDNSSubnetOptsFromString(iter->second, &d_eso)) { //cerr<<"Parsed, source: "<first<<": "<second)<qdomain<<"' denied: TSIG (key '"<<*keyname<<"') time delta "<< abs(trc->d_time - now)<<" > 'fudge' "<d_fudge<getTSIGKey(*keyname, &trc->d_algoName, &secret64)) { L<qdomain<<"' denied: can't find TSIG key with name '"<<*keyname<<"' and algorithm '"<d_algoName<<"'"<d_algoName == "hmac-md5") trc->d_algoName += ".sig-alg.reg.int."; if (trc->d_algoName != "hmac-md5.sig-alg.reg.int.") { L<d_algoName << endl; return false; } B64Decode(secret64, *secret); bool result=calculateMD5HMAC(*secret, message) == trc->d_mac; if(!result) { L<qdomain<<"' denied: TSIG signature mismatch using '"<<*keyname<<"' and algorithm '"<d_algoName<<"'"< #include #include #include #include #include #include #include #include #include "dnssecinfra.hh" using namespace Botan; class BotanRSADNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: explicit BotanRSADNSCryptoKeyEngine(unsigned int algo) : DNSCryptoKeyEngine(algo) { // cerr<<"Called"< d_key; shared_ptr d_pubkey; }; void BotanRSADNSCryptoKeyEngine::create(unsigned int bits) { AutoSeeded_RNG rng; d_key = shared_ptr(new RSA_PrivateKey(rng, bits)); } int BotanRSADNSCryptoKeyEngine::getBits() const { return d_key->max_input_bits() + 1; } namespace { string asRaw(const BigInt& x) { SecureVector buffer=BigInt::encode(x); return string((const char*)&*buffer.begin(), (const char*)&*buffer.end()); } BigInt fromRaw(const std::string& raw) { if(raw.empty()) throw runtime_error("Unable to decode empty value"); return BigInt::decode((byte*)raw.c_str(), raw.length()); } } DNSCryptoKeyEngine::storvector_t BotanRSADNSCryptoKeyEngine::convertToISCVector() const { storvector_t storvect; string algorithm = lexical_cast(d_algorithm); if(d_algorithm == 5 || d_algorithm ==7 ) algorithm += " (RSASHA1)"; else if(d_algorithm == 8) algorithm += " (RSASHA256)"; else if(d_algorithm == 10) algorithm += " (RSASHA512)"; else algorithm += " (?)"; storvect.push_back(make_pair("Algorithm", algorithm)); storvect.push_back(make_pair("Modulus", asRaw(d_key->get_n()))); storvect.push_back(make_pair("PublicExponent",asRaw(d_key->get_e()))); storvect.push_back(make_pair("PrivateExponent",asRaw(d_key->get_d()))); storvect.push_back(make_pair("Prime1",asRaw(d_key->get_p()))); storvect.push_back(make_pair("Prime2",asRaw(d_key->get_q()))); #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0) BigInt d1 = d_key->get_d() % (d_key->get_p() - 1); BigInt d2 = d_key->get_d() % (d_key->get_q() - 1); BigInt c = inverse_mod(d_key->get_q(), d_key->get_p()); #else BigInt d1 = d_key->get_d1(); BigInt d2 = d_key->get_d2(); BigInt c = d_key->get_c(); #endif storvect.push_back(make_pair("Exponent1", asRaw(d1))); storvect.push_back(make_pair("Exponent2", asRaw(d2))); storvect.push_back(make_pair("Coefficient", asRaw(c))); return storvect; } void BotanRSADNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap ) { // wants p (Prime1), q (Prime2), d (PrivateExponent), e (PublicExponent) & n Modulus BigInt n, e, d, p, q; p=fromRaw(stormap["prime1"]); q=fromRaw(stormap["prime2"]); d=fromRaw(stormap["privateexponent"]); e=fromRaw(stormap["publicexponent"]); n=fromRaw(stormap["modulus"]); drc.d_algorithm = atoi(stormap["algorithm"].c_str()); if(drc.d_algorithm != d_algorithm) throw runtime_error("Unpossible, loaded a key from storage with wrong algorithm!"); AutoSeeded_RNG rng; d_key = shared_ptr(new RSA_PrivateKey(rng, p, q, e, d, n)); // this calculates d1, d2 & other stuff, plus does load checks.. d_pubkey.reset(); } std::string BotanRSADNSCryptoKeyEngine::getPubKeyHash() const { const BigInt& n = d_key->get_n(); const BigInt& e = d_key->get_e(); SecureVector buffer=BigInt::encode(n); SHA_160 hasher; hasher.update(buffer); buffer=BigInt::encode(e); hasher.update(buffer); SecureVector hash=hasher.final(); return string((const char*)hash.begin(), (const char*)hash.end()); } std::string BotanRSADNSCryptoKeyEngine::getPublicKeyString() const { MemoryVector bits = BigInt::encode(d_key->get_e()); string exponent(&*bits.begin(), &*bits.end()); bits = BigInt::encode(d_key->get_n()); string modulus(&*bits.begin(), &*bits.end()); string keystring; if(exponent.length() < 255) keystring.assign(1, (char) (unsigned int) exponent.length()); else { keystring.assign(1, 0); uint16_t len=htons(exponent.length()); keystring.append((char*)&len, 2); } keystring.append(exponent); keystring.append(modulus); return keystring; } void BotanRSADNSCryptoKeyEngine::fromPublicKeyString(const std::string& rawString) { string exponent, modulus; const unsigned char* raw = (const unsigned char*)rawString.c_str(); if(raw[0] != 0) { exponent=rawString.substr(1, raw[0]); modulus=rawString.substr(raw[0]+1); } else { exponent=rawString.substr(3, raw[1]*0xff + raw[2]); modulus = rawString.substr(3+ raw[1]*0xff + raw[2]); } BigInt e = BigInt::decode((const byte*)exponent.c_str(), exponent.length()); BigInt n = BigInt::decode((const byte*)modulus.c_str(), modulus.length()); d_pubkey = shared_ptr(new RSA_PublicKey(n, e)); d_key.reset(); } std::string BotanRSADNSCryptoKeyEngine::sign(const std::string& msg) const { #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0) EMSA* emsaptr; if(d_algorithm == 5 || d_algorithm ==7) emsaptr=new EMSA3(new SHA_160); else if(d_algorithm==8) emsaptr=new EMSA3(new SHA_256); else emsaptr=new EMSA3(new SHA_512); PK_Signer pks(*d_key, emsaptr); #else string emsa; if(d_algorithm == 5 || d_algorithm ==7) emsa="EMSA3(SHA-160)"; else if(d_algorithm==8) emsa="EMSA3(SHA-256)"; else emsa="EMSA3(SHA-512)"; PK_Signer pks(*d_key, emsa); #endif AutoSeeded_RNG rng; SecureVector signature= pks.sign_message((byte*)msg.c_str(), msg.length(), rng); return string((const char*)signature.begin(), (const char*) signature.end()); } std::string BotanRSADNSCryptoKeyEngine::hash(const std::string& orig) const { SecureVector result; if(d_algorithm == 5 || d_algorithm ==7 ) { // SHA160 SHA_160 hasher; result= hasher.process(orig); } if(d_algorithm == 8) { // SHA256 SHA_256 hasher; result= hasher.process(orig); } else if(d_algorithm==10) { // SHA512 SHA_512 hasher; result = hasher.process(orig); } return string((const char*)result.begin(), (const char*) result.end()); } bool BotanRSADNSCryptoKeyEngine::verify(const std::string& msg, const std::string& signature) const { RSA_PublicKey* key = d_key ? d_key.get() : d_pubkey.get(); string emsa; if(d_algorithm == 5 || d_algorithm ==7) emsa = "EMSA3(SHA-1)"; else if(d_algorithm==8) emsa = "EMSA3(SHA-256)"; else emsa = "EMSA3(SHA-512)"; #if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,0) std::auto_ptr ver(get_pk_verifier(*key, emsa)); return ver->verify_message((byte*)msg.c_str(), msg.length(), (byte*)signature.c_str(), signature.length()); #else PK_Verifier pkv(*key, emsa); return pkv.verify_message((byte*)msg.c_str(), msg.length(), (byte*)signature.c_str(), signature.length()); #endif } namespace { struct LoaderBotanStruct { LoaderBotanStruct() { new Botan::LibraryInitializer("thread_safe=true"); // this leaks, but is fine DNSCryptoKeyEngine::report(5, &BotanRSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(7, &BotanRSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(8, &BotanRSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(10, &BotanRSADNSCryptoKeyEngine::maker); } } loaderBotan; } pdns-3.3/pdns/recpacketcache.hh0000644000014601777760000000365712136555572020023 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_RECPACKETCACHE_HH #define PDNS_RECPACKETCACHE_HH #include #include #include #include "dns.hh" #include "namespaces.hh" #include #include #include #include #include using namespace ::boost::multi_index; //! Stores whole packets, ready for lobbing back at the client. Not threadsafe. class RecursorPacketCache { public: RecursorPacketCache(); bool getResponsePacket(const std::string& queryPacket, time_t now, std::string* responsePacket, uint32_t* age); void insertResponsePacket(const std::string& responsePacket, time_t now, uint32_t ttd); void doPruneTo(unsigned int maxSize=250000); int doWipePacketCache(const string& name, uint16_t qtype=0xffff); void prune(); uint64_t d_hits, d_misses; uint64_t size(); uint64_t bytes(); private: struct Entry { mutable uint32_t d_ttd; mutable uint32_t d_creation; mutable std::string d_packet; // "I know what I am doing" inline bool operator<(const struct Entry& rhs) const; uint32_t getTTD() const { return d_ttd; } }; typedef multi_index_container< Entry, indexed_by < ordered_unique >, sequenced<> > > packetCache_t; packetCache_t d_packetCache; }; // needs to take into account: qname, qtype, opcode, rd, qdcount, EDNS size inline bool RecursorPacketCache::Entry::operator<(const struct RecursorPacketCache::Entry &rhs) const { const struct dnsheader* dh=(const struct dnsheader*) d_packet.c_str(), *rhsdh=(const struct dnsheader*)rhs.d_packet.c_str(); if(make_tuple(dh->opcode, dh->rd, dh->qdcount) < make_tuple(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount)) return true; return dnspacketLessThan(d_packet, rhs.d_packet); } #endif pdns-3.3/pdns/rec_channel.cc0000644000014601777760000001024312136555572017312 0ustar00jenkinsnogroup00000000000000#include "rec_channel.hh" #include #include #include "misc.hh" #include #include #include #include #include #include #include "ahuexception.hh" #include "namespaces.hh" RecursorControlChannel::RecursorControlChannel() { d_fd=-1; *d_local.sun_path=0; } RecursorControlChannel::~RecursorControlChannel() { if(d_fd > 0) close(d_fd); if(*d_local.sun_path) unlink(d_local.sun_path); } int RecursorControlChannel::listen(const string& fname) { d_fd=socket(AF_UNIX,SOCK_DGRAM,0); Utility::setCloseOnExec(d_fd); if(d_fd < 0) throw AhuException("Creating UNIX domain socket: "+string(strerror(errno))); int tmp=1; if(setsockopt(d_fd, SOL_SOCKET, SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) throw AhuException(string("Setsockopt failed: ")+strerror(errno)); int err=unlink(fname.c_str()); if(err < 0 && errno!=ENOENT) throw AhuException("Can't remove (previous) controlsocket '"+fname+"': "+string(strerror(errno)) + " (try --socket-dir)"); memset(&d_local,0,sizeof(d_local)); d_local.sun_family=AF_UNIX; strcpy(d_local.sun_path, fname.c_str()); if(bind(d_fd, (sockaddr*)&d_local,sizeof(d_local))<0) throw AhuException("Unable to bind to controlsocket '"+fname+"': "+string(strerror(errno))); return d_fd; } void RecursorControlChannel::connect(const string& path, const string& fname) { struct sockaddr_un remote; d_fd=socket(AF_UNIX,SOCK_DGRAM,0); Utility::setCloseOnExec(d_fd); if(d_fd < 0) throw AhuException("Creating UNIX domain socket: "+string(strerror(errno))); int tmp=1; if(setsockopt(d_fd, SOL_SOCKET, SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { close(d_fd); d_fd=-1; throw AhuException(string("Setsockopt failed: ")+strerror(errno)); } string localname=path+"/lsockXXXXXX"; strcpy(d_local.sun_path, localname.c_str()); if(mkstemp(d_local.sun_path) < 0) { close(d_fd); d_fd=-1; d_local.sun_path[0]=0; throw AhuException("Unable to generate local temporary file in directory '"+path+"': "+string(strerror(errno))); } d_local.sun_family=AF_UNIX; int err=unlink(d_local.sun_path); if(err < 0 && errno!=ENOENT) throw AhuException("Unable to remove local controlsocket: "+string(strerror(errno))); if(bind(d_fd, (sockaddr*)&d_local,sizeof(d_local))<0) { unlink(d_local.sun_path); close(d_fd); d_fd=-1; throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno))); } if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply! unlink(d_local.sun_path); throw AhuException("Unable to chmnod local temporary socket: "+string(strerror(errno))); } memset(&remote,0,sizeof(remote)); remote.sun_family=AF_UNIX; strcpy(remote.sun_path,(path+"/"+fname).c_str()); if(::connect(d_fd, (sockaddr*)&remote, sizeof(remote)) < 0) { unlink(d_local.sun_path); throw AhuException("Unable to connect to remote '"+path+fname+"': "+string(strerror(errno))); } } void RecursorControlChannel::send(const std::string& msg, const std::string* remote) { if(remote) { struct sockaddr_un remoteaddr; memset(&remoteaddr, 0, sizeof(remoteaddr)); remoteaddr.sun_family=AF_UNIX; strcpy(remoteaddr.sun_path, remote->c_str()); if(::sendto(d_fd, msg.c_str(), msg.length(), 0, (struct sockaddr*) &remoteaddr, sizeof(remoteaddr) ) < 0) throw AhuException("Unable to send message over control channel '"+*remote+"': "+string(strerror(errno))); } else if(::send(d_fd, msg.c_str(), msg.length(), 0) < 0) throw AhuException("Unable to send message over control channel: "+string(strerror(errno))); } string RecursorControlChannel::recv(std::string* remote, unsigned int timeout) { char buffer[16384]; ssize_t len; struct sockaddr_un remoteaddr; socklen_t addrlen=sizeof(remoteaddr); if((waitForData(d_fd, timeout, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0) throw AhuException("Unable to receive message over control channel: "+string(strerror(errno))); if(remote) *remote=remoteaddr.sun_path; return string(buffer, buffer+len); } pdns-3.3/pdns/lua-pdns.hh0000644000014601777760000000175112147631274016606 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_LUA_PDNS_HH #define PDNS_LUA_PDNS_HH #include "dns.hh" #include "iputils.hh" struct lua_State; class PowerDNSLua { public: explicit PowerDNSLua(const std::string& fname); ~PowerDNSLua(); void reload(); ComboAddress getLocal() { return d_local; } void setVariable() { d_variable=true; } protected: // FIXME? lua_State* d_lua; bool passthrough(const string& func, const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable); bool getFromTable(const std::string& key, std::string& value); bool getFromTable(const std::string& key, uint32_t& value); bool d_failed; bool d_variable; ComboAddress d_local; }; void pushResourceRecordsTable(lua_State* lua, const vector& records); void popResourceRecordsTable(lua_State *lua, const string &query, vector& ret); int getLuaTableLength(lua_State* lua, int depth); #endif pdns-3.3/pdns/unix_utility.cc0000644000014601777760000001574012155272633017621 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include #include #include #include #include "ahuexception.hh" #include "logger.hh" #include "misc.hh" #include #include #include #ifdef NEED_INET_NTOP_PROTO extern "C" { const char *inet_ntop(int af, const void *src, char *dst, size_t cnt); } #endif #include "namespaces.hh" // Closes a socket. int Utility::closesocket( Utility::sock_t socket ) { int ret=::close(socket); if(ret < 0 && errno == ECONNRESET) // see ticket 192, odd BSD behaviour return 0; if(ret < 0) throw AhuException("Error closing socket: "+stringerror()); return ret; } bool Utility::setNonBlocking(sock_t sock) { int flags=fcntl(sock,F_GETFL,0); if(flags<0 || fcntl(sock, F_SETFL,flags|O_NONBLOCK) <0) return false; return true; } bool Utility::setBlocking(sock_t sock) { int flags=fcntl(sock,F_GETFL,0); if(flags<0 || fcntl(sock, F_SETFL,flags&(~O_NONBLOCK)) <0) return false; return true; } bool Utility::setCloseOnExec(sock_t sock) { int flags=fcntl(sock,F_GETFD,0); if(flags<0 || fcntl(sock, F_SETFD,flags|FD_CLOEXEC) <0) return false; return true; } const char *Utility::inet_ntop(int af, const char *src, char *dst, size_t size) { return ::inet_ntop(af,src,dst,size); } unsigned int Utility::sleep(unsigned int sec) { return ::sleep(sec); } void Utility::usleep(unsigned long usec) { ::usleep(usec); } // Drops the program's privileges. void Utility::dropPrivs( int uid, int gid ) { if(gid) { if(setgid(gid)<0) { theL()<pw_name, gid)<0) { theL()<gr_gid; } return newgid; } // Retrieves an uid using a username. int Utility::makeUidNumeric(const string &username) { int newuid; if(!(newuid=atoi(username.c_str()))) { struct passwd *pw=getpwnam(username.c_str()); if(!pw) { theL()<pw_uid; } return newuid; } // Returns a random number. long int Utility::random( void ) { return rand(); } // Sets the random seed. void Utility::srandom( unsigned int seed ) { ::srandom(seed); } // Writes a vector. int Utility::writev(int socket, const iovec *vector, size_t count ) { return ::writev(socket,vector,count); } /* this is cut and pasted from dietlibc, gratefully copied! */ static int isleap(int year) { /* every fourth year is a leap year except for century years that are * not divisible by 400. */ return (!(year%4) && ((year%100) || !(year%400))); } time_t Utility::timegm(struct tm *const t) { const static short spm[13] = /* days per month -- nonleap! */ { 0, (31), (31+28), (31+28+31), (31+28+31+30), (31+28+31+30+31), (31+28+31+30+31+30), (31+28+31+30+31+30+31), (31+28+31+30+31+30+31+31), (31+28+31+30+31+30+31+31+30), (31+28+31+30+31+30+31+31+30+31), (31+28+31+30+31+30+31+31+30+31+30), (31+28+31+30+31+30+31+31+30+31+30+31), }; time_t day; time_t i; time_t years = t->tm_year - 70; if (t->tm_sec>60) { t->tm_min += t->tm_sec/60; t->tm_sec%=60; } if (t->tm_min>60) { t->tm_hour += t->tm_min/60; t->tm_min%=60; } if (t->tm_hour>60) { t->tm_mday += t->tm_hour/60; t->tm_hour%=60; } if (t->tm_mon>11) { t->tm_year += t->tm_mon/12; t->tm_mon%=12; } while (t->tm_mday>spm[1+t->tm_mon]) { if (t->tm_mon==1 && isleap(t->tm_year+1900)) { if (t->tm_mon==31+29) break; --t->tm_mday; } t->tm_mday-=spm[t->tm_mon]; ++t->tm_mon; if (t->tm_mon>11) { t->tm_mon=0; ++t->tm_year; } } if (t->tm_year < 70) return (time_t) -1; /* Days since 1970 is 365 * number of years + number of leap years since 1970 */ day = years * 365 + (years + 1) / 4; /* After 2100 we have to substract 3 leap years for every 400 years This is not intuitive. Most mktime implementations do not support dates after 2059, anyway, so we might leave this out for it's bloat. */ if ((years -= 131) >= 0) { years /= 100; day -= (years >> 2) * 3 + 1; if ((years &= 3) == 3) years--; day -= years; } day += t->tm_yday = spm [t->tm_mon] + t->tm_mday-1 + ( isleap (t->tm_year+1900) & (t->tm_mon > 1) ); /* day is now the number of days since 'Jan 1 1970' */ i = 7; t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */ i = 24; day *= i; i = 60; return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; } pdns-3.3/pdns/cryptoppsigners.cc0000644000014601777760000001507712136555572020336 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include #include #include #include "dnssecinfra.hh" using namespace CryptoPP; template class CryptoPPECDSADNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: explicit CryptoPPECDSADNSCryptoKeyEngine(unsigned int algo) : DNSCryptoKeyEngine(algo) {} void create(unsigned int bits); string getName() const { return "CryptoPP ECDSA"; } storvector_t convertToISCVector() const; std::string getPubKeyHash() const; std::string sign(const std::string& msg) const; std::string hash(const std::string& hash) const; bool verify(const std::string& msg, const std::string& signature) const; std::string getPublicKeyString() const; int getBits() const; void fromISCMap(DNSKEYRecordContent& drc, std::map& stormap); void fromPublicKeyString(const std::string& content); // void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw); static DNSCryptoKeyEngine* maker(unsigned int algorithm) { return new CryptoPPECDSADNSCryptoKeyEngine(algorithm); } private: typedef typename ECDSA::PrivateKey privatekey_t; typedef typename ECDSA::PublicKey publickey_t; shared_ptr d_key; shared_ptr d_pubkey; }; template void CryptoPPECDSADNSCryptoKeyEngine::create(unsigned int bits) { if(bits != BITS) throw runtime_error("This CryptoPP class can only hosts keys of length "+lexical_cast(BITS)); AutoSeededRandomPool prng; privatekey_t* privateKey = new privatekey_t(); CryptoPP::OID oid=CURVE(); privateKey->Initialize( prng, oid); d_key= shared_ptr(privateKey); publickey_t* publicKey = new publickey_t(); d_key->MakePublicKey(*publicKey); d_pubkey = shared_ptr(publicKey); } template int CryptoPPECDSADNSCryptoKeyEngine::getBits() const { return BITS; } template DNSCryptoKeyEngine::storvector_t CryptoPPECDSADNSCryptoKeyEngine::convertToISCVector() const { /* Algorithm: 13 (ECDSAP256SHA256) PrivateKey: GU6SnQ/Ou+xC5RumuIUIuJZteXT2z0O/ok1s38Et6mQ= */ string algostr=lexical_cast(d_algorithm); if(d_algorithm==13) algostr+=" (ECDSAP256SHA256)"; else if(d_algorithm==14) algostr+=" (ECDSAP384SHA384)"; else algostr+=" (?)"; storvector_t storvect; storvect.push_back(make_pair("Algorithm", algostr)); const CryptoPP::Integer& pe=d_key->GetPrivateExponent(); unsigned char buffer[pe.MinEncodedSize()]; pe.Encode(buffer, pe.MinEncodedSize()); storvect.push_back(make_pair("PrivateKey", string((char*)buffer, sizeof(buffer)))); return storvect; } template void CryptoPPECDSADNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap ) { AutoSeededRandomPool prng; privatekey_t* privateKey = new privatekey_t; const CryptoPP::Integer x(reinterpret_cast(stormap["privatekey"].c_str()), BITS/8); // well it should be this long CryptoPP::OID oid=CURVE(); privateKey->Initialize(oid, x); bool result = privateKey->Validate(prng, 3); if (!result) { throw runtime_error("Cannot load private key - validation failed!"); } d_key = shared_ptr(privateKey); publickey_t* publicKey = new publickey_t(); d_key->MakePublicKey(*publicKey); d_pubkey = shared_ptr(publicKey); drc.d_algorithm = atoi(stormap["algorithm"].c_str()); } template std::string CryptoPPECDSADNSCryptoKeyEngine::getPubKeyHash() const { return getPublicKeyString(); // sad, hashme please! } template std::string CryptoPPECDSADNSCryptoKeyEngine::getPublicKeyString() const { const ECP::Point& q = d_pubkey->GetPublicElement(); const CryptoPP::Integer& qx = q.x; const CryptoPP::Integer& qy = q.y; unsigned char buffer[qx.MinEncodedSize() + qy.MinEncodedSize()]; qx.Encode(buffer, qx.MinEncodedSize()); qy.Encode(buffer + qx.MinEncodedSize(), qy.MinEncodedSize()); return string((char*)buffer, sizeof(buffer)); } template void CryptoPPECDSADNSCryptoKeyEngine::fromPublicKeyString(const std::string& rawString) { CryptoPP::Integer x, y; x.Decode((byte*)rawString.c_str(), rawString.size()/2); y.Decode((byte*)rawString.c_str() + rawString.size()/2, rawString.size()/2); ECP::Point q(x,y); publickey_t* pubkey = new publickey_t; CryptoPP::OID oid=CURVE(); pubkey->Initialize(oid, q); d_pubkey = shared_ptr(pubkey); d_key.reset(); } template std::string CryptoPPECDSADNSCryptoKeyEngine::sign(const std::string& msg) const { string signature; AutoSeededRandomPool prng; StringSource( msg, true /*pump all*/, new SignerFilter( prng, typename ECDSA::Signer( *d_key ), new StringSink( signature ) ) // SignerFilter ); // StringSource return signature; } template std::string CryptoPPECDSADNSCryptoKeyEngine::hash(const std::string& orig) const { string hash; HASHER hasher; StringSource( orig, true /*pump all*/, new HashFilter(hasher, new StringSink( hash ) ) // HashFilter ); // StringSource return hash; } template bool CryptoPPECDSADNSCryptoKeyEngine::verify(const std::string& msg, const std::string& signature) const { byte result; StringSource( signature+msg, true /*pump all*/, new SignatureVerificationFilter( typename ECDSA::Verifier(*d_pubkey), new ArraySink( (byte*)&result, sizeof(result) ) ) // SignatureVerificationFilter ); return result; } namespace { struct WrapperSECP256R1 { operator CryptoPP::OID () const { return CryptoPP::ASN1::secp256r1(); } }; struct WrapperSECP384R1 { operator CryptoPP::OID () const { return CryptoPP::ASN1::secp384r1(); } }; struct LoaderStruct { LoaderStruct() { DNSCryptoKeyEngine::report(13, &CryptoPPECDSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(14, &CryptoPPECDSADNSCryptoKeyEngine::maker); } } loaderCryptoPP; } pdns-3.3/pdns/syncres.cc0000644000014601777760000013007412145413600016525 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2003 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include "utility.hh" #include "syncres.hh" #include #include #include #include #include #include #include #include #include #include "logger.hh" #include "misc.hh" #include "arguments.hh" #include "lwres.hh" #include "recursor_cache.hh" #include "dnsparser.hh" #include "dns_random.hh" #include "lock.hh" #include "cachecleaner.hh" __thread SyncRes::StaticStorage* t_sstorage; unsigned int SyncRes::s_maxnegttl; unsigned int SyncRes::s_maxcachettl; unsigned int SyncRes::s_packetcachettl; unsigned int SyncRes::s_packetcacheservfailttl; unsigned int SyncRes::s_queries; unsigned int SyncRes::s_outgoingtimeouts; unsigned int SyncRes::s_outqueries; unsigned int SyncRes::s_tcpoutqueries; unsigned int SyncRes::s_throttledqueries; unsigned int SyncRes::s_dontqueries; unsigned int SyncRes::s_nodelegated; unsigned int SyncRes::s_unreachables; bool SyncRes::s_doIPv6; bool SyncRes::s_nopacketcache; string SyncRes::s_serverID; SyncRes::LogMode SyncRes::s_lm; #define LOG(x) if(d_lm == Log) { L <&ret) { s_queries++; if( (qtype.getCode() == QType::AXFR)) return -1; if( (qtype.getCode()==QType::PTR && pdns_iequals(qname, "1.0.0.127.in-addr.arpa.")) || (qtype.getCode()==QType::A && qname.length()==10 && pdns_iequals(qname, "localhost."))) { ret.clear(); DNSResourceRecord rr; rr.qname=qname; rr.qtype=qtype; rr.qclass=1; rr.ttl=86400; if(qtype.getCode()==QType::PTR) rr.content="localhost."; else rr.content="127.0.0.1"; ret.push_back(rr); return 0; } if(qclass==3 && qtype.getCode()==QType::TXT && (pdns_iequals(qname, "version.bind.") || pdns_iequals(qname, "id.server.") || pdns_iequals(qname, "version.pdns.") ) ) { ret.clear(); DNSResourceRecord rr; rr.qname=qname; rr.qtype=qtype; rr.qclass=qclass; rr.ttl=86400; if(pdns_iequals(qname,"version.bind.") || pdns_iequals(qname,"version.pdns.")) rr.content="\""+::arg()["version-string"]+"\""; else rr.content="\""+s_serverID+"\""; ret.push_back(rr); return 0; } if(qclass==0xff) qclass=1; else if(qclass!=1) return -1; set beenthere; int res=doResolve(qname, qtype, ret, 0, beenthere); if(!res && s_doAdditionalProcessing) addCruft(qname, ret); return res; } //! This is the 'out of band resolver', in other words, the authoritative server bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vector&ret, int depth, int& res) { string prefix; if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } LOG(prefix<domainmap->end()) { LOG(prefix< range; range=iter->second.d_records.equal_range(tie(qname)); // partial lookup ret.clear(); AuthDomain::records_t::const_iterator ziter; bool somedata=false; for(ziter=range.first; ziter!=range.second; ++ziter) { somedata=true; if(qtype.getCode()==QType::ANY || ziter->qtype==qtype || ziter->qtype.getCode()==QType::CNAME) // let rest of nameserver do the legwork on this one ret.push_back(*ziter); } if(!ret.empty()) { LOG(prefix<second.d_records.find(make_tuple(authdomain, QType(QType::SOA))); if(ziter!=iter->second.d_records.end()) { DNSResourceRecord rr=*ziter; rr.d_place=DNSResourceRecord::AUTHORITY; ret.push_back(rr); } else LOG(prefix<first) && chopOffDotted(wcarddomain)) { LOG(prefix<second.d_records.equal_range(make_tuple("*."+wcarddomain)); if(range.first==range.second) continue; for(ziter=range.first; ziter!=range.second; ++ziter) { DNSResourceRecord rr=*ziter; if(rr.qtype == qtype || qtype.getCode() == QType::ANY) { rr.qname = qname; rr.d_place=DNSResourceRecord::ANSWER; ret.push_back(rr); } } LOG(prefix<first)) { range=iter->second.d_records.equal_range(make_tuple(nsdomain,QType(QType::NS))); if(range.first==range.second) continue; for(ziter=range.first; ziter!=range.second; ++ziter) { DNSResourceRecord rr=*ziter; rr.d_place=DNSResourceRecord::AUTHORITY; ret.push_back(rr); } } if(ret.empty()) { LOG(prefix<second.d_records.find(make_tuple(authdomain, QType(QType::SOA))); if(ziter!=iter->second.d_records.end()) { DNSResourceRecord rr=*ziter; rr.d_place=DNSResourceRecord::AUTHORITY; ret.push_back(rr); } else LOG(prefix<ednsstatus.begin(); iter != t_sstorage->ednsstatus.end(); ++iter) { fprintf(fp, "%s\t%d\t%s", iter->first.toString().c_str(), (int)iter->second.mode, ctime(&iter->second.modeSetAt)); } fclose(fp); } int SyncRes::asyncresolveWrapper(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, LWResult* res) { /* what is your QUEST? the goal is to get as many remotes as possible on the highest level of hipness: EDNS PING responders. The levels are: -1) CONFIRMEDPINGER: Confirmed pinger! 0) UNKNOWN Unknown state 1) EDNSNOPING: Honors EDNS0 if no PING is included 2) EDNSPINGOK: Ignores EDNS0+PING, but does generate EDNS0 response 3) EDNSIGNORANT: Ignores EDNS0+PING, gives replies without EDNS0 nor PING 4) NOEDNS: Generates FORMERR on EDNS queries Everybody starts out assumed to be '0'. If '-1', send out EDNS0+Ping If we get a FormErr, ignore If we get a incorrect PING, ignore If we get no PING, ignore If '0', send out EDNS0+Ping If we get a pure EDNS response, you are downgraded to '2'. If you FORMERR us, go to '1', If no EDNS in response, go to '3' - 3 and 0 are really identical, except confirmed If with correct PING, upgrade to -1 If '1', send out EDNS0, no PING If FORMERR, downgrade to 4 If '2', keep on including EDNS0+PING, just don't expect PING to be correct If PING correct, move to '0', and cheer in the log file! If '3', keep on including EDNS0+PING, see what happens Same behaviour as 0 If '4', send bare queries */ if(s_noEDNS) { g_stats.noEdnsOutQueries++; return asyncresolve(ip, domain, type, doTCP, sendRDQuery, 0, now, res); } SyncRes::EDNSStatus* ednsstatus; ednsstatus = &t_sstorage->ednsstatus[ip]; if(ednsstatus->modeSetAt && ednsstatus->modeSetAt + 3600 < d_now.tv_sec) { *ednsstatus=SyncRes::EDNSStatus(); // cerr<<"Resetting EDNS Status for "<mode == EDNSStatus::UNKNOWN) ednsstatus->mode = EDNSStatus::EDNSNOPING; SyncRes::EDNSStatus::EDNSMode& mode=ednsstatus->mode; SyncRes::EDNSStatus::EDNSMode oldmode = mode; int EDNSLevel=0; int ret; for(int tries = 0; tries < 3; ++tries) { // cerr<<"Remote '"<d_pingCorrect) { L<d_rcode = RCode::ServFail; g_stats.ednsPingMismatches++; } else { g_stats.ednsPingMatches++; ednsstatus->modeSetAt=d_now.tv_sec; // only the very best mode self-perpetuates } } else if(mode==EDNSStatus::UNKNOWN || mode==EDNSStatus::EDNSPINGOK || mode == EDNSStatus::EDNSIGNORANT ) { if(res->d_rcode == RCode::FormErr) { // cerr<<"Downgrading to EDNSNOPING because of FORMERR!"<d_rcode == RCode::Refused || res->d_rcode == RCode::NotImp) ) { // this "fixes" F5 // cerr<<"Downgrading an unknown status to EDNSNOPING because of RCODE="<d_rcode<d_pingCorrect && res->d_haveEDNS) mode = EDNSStatus::EDNSPINGOK; else if(res->d_pingCorrect) { L<d_haveEDNS) { if(mode != EDNSStatus::EDNSIGNORANT) { mode = EDNSStatus::EDNSIGNORANT; // cerr<<"We find that "<d_rcode == RCode::FormErr) { // cerr<<"Downgrading to mode 4, FORMERR!"<d_pingCorrect) { // an upgrade! L<modeSetAt=d_now.tv_sec; // cerr<<"Result: ret="<d_haveEDNS<<", EDNS-PING correct: "<d_pingCorrect<<", new mode: "<&ret, int depth, set& beenthere) { string prefix; if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } int res=0; if(!(d_nocache && qtype.getCode()==QType::NS && qname==".")) { if(d_cacheonly) { // very limited OOB support LWResult lwr; LOG(prefix<domainmap->end()) { const vector& servers = iter->second.d_servers; if(servers.empty()) { ret.clear(); doOOBResolve(qname, qtype, ret, depth, res); return res; } else { const ComboAddress remoteIP = servers.front(); LOG(prefix<d_place == DNSResourceRecord::ANSWER) ret.push_back(*i); } return res; } } } if(doCNAMECacheCheck(qname,qtype,ret,depth,res)) // will reroute us if needed return res; if(doCacheCheck(qname,qtype,ret,depth,res)) // we done return res; } if(d_cacheonly) return 0; LOG(prefix< nsset; bool flawedNSSet=false; // the two retries allow getBestNSNamesFromCache&co to reprime the root // hints, in case they ever go missing for(int tries=0;tries<2 && nsset.empty();++tries) { subdomain=getBestNSNamesFromCache(subdomain, nsset, &flawedNSSet, depth, beenthere); // pass beenthere to both occasions } if(!(res=doResolveAt(nsset, subdomain, flawedNSSet, qname, qtype, ret, depth, beenthere))) return 0; LOG(prefix< SyncRes::getAddrs(const string &qname, int depth, set& beenthere) { typedef vector res_t; res_t res; typedef vector ret_t; ret_t ret; QType type; for(int j=0; j<1+s_doIPv6; j++) { type = j ? QType::AAAA : QType::A; if(!doResolve(qname, type, res,depth+1,beenthere) && !res.empty()) { // this consults cache, OR goes out for(res_t::const_iterator i=res.begin(); i!= res.end(); ++i) { if(i->qtype.getCode()==QType::A || i->qtype.getCode()==QType::AAAA) { ret.push_back(ComboAddress(i->content, 53)); } } } } if(ret.size() > 1) { random_shuffle(ret.begin(), ret.end(), dns_random); // move 'best' address for this nameserver name up front nsspeeds_t::iterator best = t_sstorage->nsSpeeds.find(qname); if(best != t_sstorage->nsSpeeds.end()) for(ret_t::iterator i=ret.begin(); i != ret.end(); ++i) { if(*i==best->second.d_best) { // got the fastest one if(i!=ret.begin()) { *i=*ret.begin(); *ret.begin()=best->second.d_best; } break; } } } return ret; } void SyncRes::getBestNSFromCache(const string &qname, set&bestns, bool* flawedNSSet, int depth, set& beenthere) { string prefix, subdomain(qname); if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } bestns.clear(); do { LOG(prefix< ns; *flawedNSSet = false; if(t_RC->get(d_now.tv_sec, subdomain, QType(QType::NS), &ns) > 0) { for(set::const_iterator k=ns.begin();k!=ns.end();++k) { if(k->ttl > (unsigned int)d_now.tv_sec ) { set aset; DNSResourceRecord rr=*k; rr.content=k->content; if(!dottedEndsOn(rr.content, subdomain) || t_RC->get(d_now.tv_sec, rr.content, s_doIPv6 ? QType(QType::ADDR) : QType(QType::A), doLog() ? &aset : 0) > 5) { bestns.insert(rr); LOG(prefix< '"<content<<") which we miss or is expired"<::const_iterator j=beenthere.begin();j!=beenthere.end();++j) { LOG(prefix<qname<<" ("<<(unsigned int)j->bestns.size()<<")"<domainmap->find(*qname); if(ret!=t_sstorage->domainmap->end()) break; }while(chopOffDotted(*qname)); return ret; } /** doesn't actually do the work, leaves that to getBestNSFromCache */ string SyncRes::getBestNSNamesFromCache(const string &qname, set& nsset, bool* flawedNSSet, int depth, set&beenthere) { string subdomain(qname); string authdomain(qname); domainmap_t::const_iterator iter=getBestAuthZone(&authdomain); if(iter!=t_sstorage->domainmap->end()) { if( iter->second.d_servers.empty() ) nsset.insert(string()); // this gets picked up in doResolveAt, if empty it means "we are auth", otherwise it denotes a forward else { for(vector::const_iterator server=iter->second.d_servers.begin(); server != iter->second.d_servers.end(); ++server) nsset.insert((iter->second.d_rdForward ? "+" : "-") + server->toStringWithPort()); // add a '+' if the rd bit should be set } return authdomain; } set bestns; getBestNSFromCache(subdomain, bestns, flawedNSSet, depth, beenthere); for(set::const_iterator k=bestns.begin();k!=bestns.end();++k) { nsset.insert(k->content); if(k==bestns.begin()) subdomain=k->qname; } return subdomain; } bool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res) { string prefix; if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } if((depth>9 && d_outqueries>10 && d_throttledqueries>5) || depth > 15) { LOG(prefix< cset; if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME),&cset) > 0) { for(set::const_iterator j=cset.begin();j!=cset.end();++j) { if(j->ttl>(unsigned int) d_now.tv_sec) { LOG(prefix<content<<"'"<beenthere; res=doResolve(j->content, qtype, ret, depth+1, beenthere); } else res=0; return true; } } } LOG(prefix<&ret, int depth, int &res) { bool giveNegative=false; string prefix; if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } string sqname(qname); QType sqt(qtype); uint32_t sttl=0; // cout<<"Lookup for '"< range=t_sstorage->negcache.equal_range(tie(qname)); negcache_t::iterator ni; for(ni=range.first; ni != range.second; ni++) { // we have something if(ni->d_qtype.getCode() == 0 || ni->d_qtype == qtype) { res=0; if((uint32_t)d_now.tv_sec < ni->d_ttd) { sttl=ni->d_ttd - d_now.tv_sec; if(ni->d_qtype.getCode()) { LOG(prefix<d_qname<<"' for another "<d_qname<<"' for another "<d_qname; sqt=QType::SOA; moveCacheItemToBack(t_sstorage->negcache, ni); break; } else { LOG(prefix<negcache, ni); } } } set cset; bool found=false, expired=false; if(t_RC->get(d_now.tv_sec, sqname, sqt, &cset) > 0) { LOG(prefix<::const_iterator j=cset.begin();j!=cset.end();++j) { LOG(j->content); if(j->ttl>(unsigned int) d_now.tv_sec) { DNSResourceRecord rr=*j; rr.ttl-=d_now.tv_sec; if(giveNegative) { rr.d_place=DNSResourceRecord::AUTHORITY; rr.ttl=sttl; } ret.push_back(rr); LOG("[ttl="<countb; } struct speedOrder { speedOrder(map &speeds) : d_speeds(speeds) {} bool operator()(const string &a, const string &b) const { return d_speeds[a] < d_speeds[b]; } map& d_speeds; }; inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, const string &prefix) { vector rnameservers; rnameservers.reserve(tnameservers.size()); BOOST_FOREACH(const string& str, tnameservers) { rnameservers.push_back(str); } map speeds; BOOST_FOREACH(const string& val, rnameservers) { double speed; speed=t_sstorage->nsSpeeds[val].get(&d_now); speeds[val]=speed; } random_shuffle(rnameservers.begin(),rnameservers.end(), dns_random); speedOrder so(speeds); stable_sort(rnameservers.begin(),rnameservers.end(), so); if(doLog()) { LOG(prefix<<"Nameservers: "); for(vector::const_iterator i=rnameservers.begin();i!=rnameservers.end();++i) { if(i!=rnameservers.begin()) { LOG(", "); if(!((i-rnameservers.begin())%3)) { LOG(endl<& a, const pair& b) const { if(pdns_ilexicographical_compare(a.first, b.first)) return true; if(pdns_ilexicographical_compare(b.first, a.first)) return false; return a.second < b.second; } }; static bool magicAddrMatch(const QType& query, const QType& answer) { if(query.getCode() != QType::ADDR) return false; return answer.getCode() == QType::A || answer.getCode() == QType::AAAA; } /** returns -1 in case of no results, rcode otherwise */ int SyncRes::doResolveAt(set nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, vector&ret, int depth, set&beenthere) { string prefix; if(doLog()) { prefix=d_prefix; prefix.append(depth, ' '); } LOG(prefix< rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname+": ") : string() ); for(vector::const_iterator tns=rnameservers.begin();;++tns) { if(tns==rnameservers.end()) { LOG(prefix<doAgeCache(d_now.tv_sec, auth, QType::NS, 10)) g_stats.nsSetInvalidations++; } return -1; } // this line needs to identify the 'self-resolving' behaviour, but we get it wrong now if(pdns_iequals(qname, *tns) && qtype.getCode()==QType::A && rnameservers.size() > (unsigned)(1+1*s_doIPv6)) { LOG(prefix< remoteIPs_t; remoteIPs_t remoteIPs; remoteIPs_t::const_iterator remoteIP; bool doTCP=false; int resolveret; bool pierceDontQuery=false; bool sendRDQuery=false; LWResult lwr; if(tns->empty()) { LOG(prefix<empty()) { sendRDQuery = txtAddr[0] == '+'; txtAddr=txtAddr.c_str()+1; } ComboAddress addr=parseIPAndPort(txtAddr, 53); remoteIPs.push_back(addr); pierceDontQuery=true; } else { remoteIPs=getAddrs(*tns, depth+2, beenthere); pierceDontQuery=false; } if(remoteIPs.empty()) { LOG(prefix<toString()); } LOG(endl); } for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { LOG(prefix<toStringWithPort() <<", asking '"<throttle.shouldThrottle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()))) { LOG(prefix<match(&*remoteIP)) { LOG(prefix<toString() << ", blocked by 'dont-query' setting" << endl); s_dontqueries++; continue; } else { s_outqueries++; d_outqueries++; TryTCP: if(doTCP) { LOG(prefix<toStringWithPort() <nsSpeeds[*tns].submit(*remoteIP, 1000000, &d_now); // 1 sec } if(resolveret==-1) t_sstorage->throttle.throttle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()), 60, 100); // unreachable, 1 minute or 100 queries else t_sstorage->throttle.throttle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()), 10, 5); // timeout } continue; } if(lwr.d_rcode==RCode::ServFail || lwr.d_rcode==RCode::Refused) { LOG(prefix<throttle.throttle(d_now.tv_sec,make_tuple(*remoteIP, qname, qtype.getCode()),60,3); // servfail or refused continue; } break; // this IP address worked! wasLame:; // well, it didn't LOG(prefix<toString() <<") is lame for '"<throttle.throttle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()), 60, 100); // lame } } if(remoteIP == remoteIPs.end()) // we tried all IP addresses, none worked continue; if(lwr.d_tcbit) { if(!doTCP) { doTCP=true; LOG(prefix<toString() <<"), rcode="<sin4.sin_family==AF_INET6) lwr.d_usec/=3; */ // cout<<"msec: "<nsSpeeds[*tns].submit(*remoteIP, lwr.d_usec, &d_now); } typedef map, set, TCacheComp > tcache_t; tcache_t tcache; // reap all answers from this packet that are acceptable for(LWResult::res_t::iterator i=lwr.d_result.begin();i != lwr.d_result.end();++i) { if(i->qtype.getCode() == QType::OPT) { LOG(prefix<qname<<"' from '"<qname<<"|"<qtype.getName()<<"|"<content<<"' from '"<qtype.getCode()==QType::ANY) { LOG("NO! - we don't accept 'ANY' data"<qname, auth)) { if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && i->d_place==DNSResourceRecord::ANSWER && ::arg().contains("delegation-only",auth)) { LOG("NO! Is from delegation-only zone"<ttl=min(s_maxcachettl, i->ttl); DNSResourceRecord rr=*i; rr.d_place=DNSResourceRecord::ANSWER; rr.ttl += d_now.tv_sec; if(rr.qtype.getCode() == QType::NS) // people fiddle with the case rr.content=toLower(rr.content); // this must stay! (the cache can't be case-insensitive on the RHS of records) tcache[make_pair(i->qname,i->qtype)].insert(rr); } } else LOG("NO!"<second.size() > 1) { // need to group the ttl to be the minimum of the RRSET (RFC 2181, 5.2) uint32_t lowestTTL=std::numeric_limits::max(); for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) lowestTTL=min(lowestTTL, j->ttl); for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) ((tcache_t::value_type::second_type::value_type*)&(*j))->ttl=lowestTTL; } t_RC->replace(d_now.tv_sec, i->first.first, i->first.second, i->second, lwr.d_aabit); } set nsset; LOG(prefix<d_place==DNSResourceRecord::AUTHORITY && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NXDomain && dottedEndsOn(qname,i->qname) && dottedEndsOn(i->qname, auth)) { LOG(prefix<ttl = min(i->ttl, s_maxnegttl); if(!newtarget.length()) // only add a SOA if we're not going anywhere after this ret.push_back(*i); NegCacheEntry ne; ne.d_qname=i->qname; ne.d_ttd=d_now.tv_sec + i->ttl; ne.d_name=qname; ne.d_qtype=QType(0); // this encodes 'whole record' replacing_insert(t_sstorage->negcache, ne); negindic=true; } else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { ret.push_back(*i); newtarget=i->content; } // for ANY answers we *must* have an authoritive answer, unless we are forwarding recursively else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && ( i->qtype==qtype || (lwr.d_aabit && (qtype==QType(QType::ANY) || magicAddrMatch(qtype, i->qtype) ) ) || sendRDQuery ) ) { LOG(prefix<content<<"|"<qtype.getName()<<"'"<d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { if(moreSpecificThan(i->qname,auth)) { newauth=i->qname; LOG(prefix<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<content); } else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NoError) { LOG(prefix< ttl = min(s_maxnegttl, i->ttl); ret.push_back(*i); NegCacheEntry ne; ne.d_qname=i->qname; ne.d_ttd=d_now.tv_sec + i->ttl; ne.d_name=qname; ne.d_qtype=qtype; if(qtype.getCode()) { // prevents us from blacking out a whole domain replacing_insert(t_sstorage->negcache, ne); } negindic=true; } } } if(done){ LOG(prefix< 10) { LOG(prefix< beenthere2; return doResolve(newtarget, qtype, ret, depth + 1, beenthere2); } if(lwr.d_rcode==RCode::NXDomain) { LOG(prefix<& ret) { for(vector::const_iterator k=ret.begin();k!=ret.end();++k) // don't add stuff to an NXDOMAIN! if(k->d_place==DNSResourceRecord::AUTHORITY && k->qtype==QType(QType::SOA)) return; // LOG(qname<<": Adding best authority records from cache"< addit; for(vector::const_iterator k=ret.begin();k!=ret.end();++k) if( (k->d_place==DNSResourceRecord::ANSWER && (k->qtype==QType(QType::MX) || k->qtype==QType(QType::SRV))) || ((k->d_place==DNSResourceRecord::AUTHORITY || k->d_place==DNSResourceRecord::ANSWER) && k->qtype==QType(QType::NS))) { LOG(d_prefix<content<<"|"<qtype.getName()<<"' needs IP for additional processing"< beenthere; vector > fields; vstringtok(fields, k->content, " "); string host; if(k->qtype==QType(QType::MX) && fields.size()==2) host=string(k->content.c_str() + fields[1].first, fields[1].second - fields[1].first); else if(k->qtype==QType(QType::NS)) host=k->content; else if(k->qtype==QType(QType::SRV) && fields.size()==4) host=string(k->content.c_str() + fields[3].first, fields[3].second - fields[3].first); else continue; // we used to do additional processing here.. no more // doResolve(host, QType(QType::A), addit, 1, beenthere); } if(!addit.empty()) { sort(addit.begin(), addit.end()); addit.erase(unique(addit.begin(), addit.end(), uniqueComp), addit.end()); for(vector::iterator k=addit.begin();k!=addit.end();++k) { if(k->qtype.getCode()==QType::A || k->qtype.getCode()==QType::AAAA) { k->d_place=DNSResourceRecord::ADDITIONAL; ret.push_back(*k); } } } LOG(d_prefix<& ret, int depth) { set bestns; set beenthere; bool dontcare; getBestNSFromCache(qname, bestns, &dontcare, depth, beenthere); for(set::const_iterator k=bestns.begin();k!=bestns.end();++k) { DNSResourceRecord ns=*k; ns.d_place=DNSResourceRecord::AUTHORITY; ns.ttl-=d_now.tv_sec; ret.push_back(ns); } } // used by PowerDNSLua - note that this neglects to add the packet count & statistics back to pdns_ercursor.cc int directResolve(const std::string& qname, const QType& qtype, int qclass, vector& ret) { struct timeval now; gettimeofday(&now, 0); SyncRes sr(now); int res = sr.beginResolve(qname, QType(qtype), qclass, ret); return res; } pdns-3.3/pdns/dnslabeltext.rl0000644000014601777760000000474012145460315017565 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include #include "namespaces.hh" namespace { void appendSplit(vector& ret, string& segment, char c) { if(segment.size()>254) { ret.push_back(segment); segment.clear(); } segment.append(1, c); } } vector segmentDNSText(const string& input ) { %%{ machine dnstext; write data; }%% (void)dnstext_error; // silence warnings (void)dnstext_en_main; const char *p = input.c_str(), *pe = input.c_str() + input.length(); const char* eof = pe; int cs; char val = 0; string segment; vector ret; %%{ action segmentEnd { ret.push_back(segment); segment.clear(); } action segmentBegin { segment.clear(); } action reportEscaped { char c = *fpc; appendSplit(ret, segment, c); } action reportEscapedNumber { char c = *fpc; val *= 10; val += c-'0'; } action doneEscapedNumber { appendSplit(ret, segment, val); val=0; } action reportPlain { appendSplit(ret, segment, *(fpc)); } escaped = '\\' (([^0-9]@reportEscaped) | ([0-9]{3}$reportEscapedNumber%doneEscapedNumber)); plain = ((extend-cntrl-'\\'-'"')|'\n'|'\t') $ reportPlain; txtElement = escaped | plain; main := (('"' txtElement* '"' space?) >segmentBegin %segmentEnd)+; # Initialize and execute. write init; write exec; }%% if ( cs < dnstext_first_final ) { throw runtime_error("Unable to parse DNS TXT '"+input+"'"); } return ret; }; #if 0 int main() { //char blah[]="\"blah\" \"bleh\" \"bloeh\\\"bleh\" \"\\97enzo\""; char blah[]="\"v=spf1 ip4:67.106.74.128/25 ip4:63.138.42.224/28 ip4:65.204.46.224/27 \\013\\010ip4:66.104.217.176/28 \\013\\010ip4:209.48.147.0/27 ~all\""; //char blah[]="\"abc \\097\\098 def\""; printf("Input: '%s'\n", blah); vector res=dnstext(blah); cerr< #include #include #include #include #include // #include #include "misc.hh" #include #include #include #include #include "dns.hh" #include "dnswriter.hh" /** DNS records have three representations: 1) in the packet 2) parsed in a class, ready for use 3) in the zone We should implement bidirectional transitions between 1&2 and 2&3. Currently we have: 1 -> 2 2 -> 3 We can add: 2 -> 1 easily by reversing the packetwriter And we might be able to reverse 2 -> 3 as well */ #include "namespaces.hh" #include "namespaces.hh" class MOADNSException : public runtime_error { public: MOADNSException(const string& str) : runtime_error(str) {} }; class MOADNSParser; class PacketReader { public: PacketReader(const vector& content) : d_pos(0), d_startrecordpos(0), d_content(content) { d_recordlen = content.size(); } uint32_t get32BitInt(); uint16_t get16BitInt(); uint8_t get8BitInt(); void xfr48BitInt(uint64_t& val); void xfr32BitInt(uint32_t& val) { val=get32BitInt(); } void xfrIP(uint32_t& val) { xfr32BitInt(val); val=htonl(val); } void xfrIP6(std::string &val) { xfrBlob(val, 16); } void xfrTime(uint32_t& val) { xfr32BitInt(val); } void xfr16BitInt(uint16_t& val) { val=get16BitInt(); } void xfrType(uint16_t& val) { xfr16BitInt(val); } void xfr8BitInt(uint8_t& val) { val=get8BitInt(); } void xfrLabel(string &label, bool compress=false) { label=getLabel(); } void xfrText(string &text, bool multi=false) { text=getText(multi); } void xfrBlob(string& blob); void xfrBlob(string& blob, int length); void xfrHexBlob(string& blob, bool keepReading=false); static uint16_t get16BitInt(const vector&content, uint16_t& pos); static void getLabelFromContent(const vector& content, uint16_t& frompos, string& ret, int recurs); void getDnsrecordheader(struct dnsrecordheader &ah); void copyRecord(vector& dest, uint16_t len); void copyRecord(unsigned char* dest, uint16_t len); string getLabel(unsigned int recurs=0); string getText(bool multi); uint16_t d_pos; private: uint16_t d_startrecordpos; // needed for getBlob later on uint16_t d_recordlen; // ditto const vector& d_content; }; struct DNSRecord; class DNSRecordContent { public: static DNSRecordContent* mastermake(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* mastermake(uint16_t qtype, uint16_t qclass, const string& zone); virtual std::string getZoneRepresentation() const = 0; virtual ~DNSRecordContent() {} virtual void toPacket(DNSPacketWriter& pw)=0; virtual string serialize(const string& qname, bool canonic=false, bool lowerCase=false) // it would rock if this were const, but it is too hard { vector packet; string empty; DNSPacketWriter pw(packet, empty, 1); if(canonic) pw.setCanonic(true); if(lowerCase) pw.setLowercase(true); pw.startRecord(qname, d_qtype); this->toPacket(pw); pw.commit(); string record; pw.getRecords(record); return record; } static shared_ptr unserialize(const string& qname, uint16_t qtype, const string& serialized); void doRecordCheck(const struct DNSRecord&){} std::string label; struct dnsrecordheader header; typedef DNSRecordContent* makerfunc_t(const struct DNSRecord& dr, PacketReader& pr); typedef DNSRecordContent* zmakerfunc_t(const string& str); static void regist(uint16_t cl, uint16_t ty, makerfunc_t* f, zmakerfunc_t* z, const char* name) { if(f) getTypemap()[make_pair(cl,ty)]=f; if(z) getZmakermap()[make_pair(cl,ty)]=z; getT2Namemap().insert(make_pair(make_pair(cl,ty), name)); getN2Typemap().insert(make_pair(name, make_pair(cl,ty))); } static void unregist(uint16_t cl, uint16_t ty) { pair key=make_pair(cl, ty); getTypemap().erase(key); getZmakermap().erase(key); } static uint16_t TypeToNumber(const string& name) { n2typemap_t::const_iterator iter = getN2Typemap().find(toUpper(name)); if(iter != getN2Typemap().end()) return iter->second.second; if(boost::starts_with(name, "TYPE")) return atoi(name.c_str()+4); throw runtime_error("Unknown DNS type '"+name+"'"); } static const string NumberToType(uint16_t num, uint16_t classnum=1) { t2namemap_t::const_iterator iter = getT2Namemap().find(make_pair(classnum, num)); if(iter == getT2Namemap().end()) return "TYPE" + lexical_cast(num); // throw runtime_error("Unknown DNS type with numerical id "+lexical_cast(num)); return iter->second; } explicit DNSRecordContent(uint16_t type) : d_qtype(type) {} DNSRecordContent& operator=(const DNSRecordContent& orig) { const_cast(d_qtype) = orig.d_qtype; // **COUGH** label = orig.label; header = orig.header; return *this; } const uint16_t d_qtype; protected: typedef std::map, makerfunc_t* > typemap_t; typedef std::map, zmakerfunc_t* > zmakermap_t; typedef std::map, string > t2namemap_t; typedef std::map > n2typemap_t; static typemap_t& getTypemap(); static t2namemap_t& getT2Namemap(); static n2typemap_t& getN2Typemap(); static zmakermap_t& getZmakermap(); }; struct DNSRecord { std::string d_label; uint16_t d_type; uint16_t d_class; uint32_t d_ttl; uint16_t d_clen; enum {Answer=1, Nameserver, Additional} d_place; boost::shared_ptr d_content; bool operator<(const DNSRecord& rhs) const { string lzrp, rzrp; if(d_content) lzrp=toLower(d_content->getZoneRepresentation()); if(rhs.d_content) rzrp=toLower(rhs.d_content->getZoneRepresentation()); string llabel=toLower(d_label); string rlabel=toLower(rhs.d_label); return tie(llabel, d_type, d_class, lzrp) < tie(rlabel, rhs.d_type, rhs.d_class, rzrp); } bool operator==(const DNSRecord& rhs) const { string lzrp, rzrp; if(d_content) lzrp=toLower(d_content->getZoneRepresentation()); if(rhs.d_content) rzrp=toLower(rhs.d_content->getZoneRepresentation()); string llabel=toLower(d_label); string rlabel=toLower(rhs.d_label); return tie(llabel, d_type, d_class, lzrp) == tie(rlabel, rhs.d_type, rhs.d_class, rzrp); } }; //! This class can be used to parse incoming packets, and is copyable class MOADNSParser : public boost::noncopyable { public: //! Parse from a string MOADNSParser(const string& buffer) : d_tsigPos(0) { init(buffer.c_str(), (unsigned int)buffer.size()); } //! Parse from a pointer and length MOADNSParser(const char *packet, unsigned int len) : d_tsigPos(0) { init(packet, len); } dnsheader d_header; string d_qname; uint16_t d_qclass, d_qtype; //uint8_t d_rcode; typedef vector > answers_t; //! All answers contained in this packet answers_t d_answers; shared_ptr getPacketReader(uint16_t offset) { shared_ptr pr(new PacketReader(d_content)); pr->d_pos=offset; return pr; } uint16_t getTSIGPos() { return d_tsigPos; } private: void getDnsrecordheader(struct dnsrecordheader &ah); void init(const char *packet, unsigned int len); vector d_content; uint16_t d_tsigPos; }; string simpleCompress(const string& label, const string& root=""); void simpleExpandTo(const string& label, unsigned int frompos, string& ret); void ageDNSPacket(std::string& packet, uint32_t seconds); #endif pdns-3.3/pdns/resolver.cc0000644000014601777760000004117712160025353016706 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include "resolver.hh" #include #include #include #include #include "misc.hh" #include #include #include "dnsrecords.hh" #include #include #include #include #include "dns.hh" #include "qtype.hh" #include "tcpreceiver.hh" #include "ahuexception.hh" #include "statbag.hh" #include "arguments.hh" #include "base64.hh" #include "dnswriter.hh" #include "dnsparser.hh" #include #include #include "dns_random.hh" #include "namespaces.hh" int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) { ComboAddress ourLocal(local); int sock=socket(ourLocal.sin4.sin_family, udpOrTCP ? SOCK_DGRAM : SOCK_STREAM, 0); Utility::setCloseOnExec(sock); if(sock < 0) { unixDie("Creating local resolver socket for "+ourLocal.toString() + ((local.sin4.sin_family == AF_INET6) ? ", does your OS miss IPv6?" : "")); } if(udpOrTCP) { // udp, try hard to bind an unpredictable port int tries=10; while(--tries) { ourLocal.sin4.sin_port = htons(10000+(dns_random(10000))); if (::bind(sock, (struct sockaddr *)&ourLocal, ourLocal.getSocklen()) >= 0) break; } // cerr<<"bound udp port "<=0) close(d_sock4); throw; } Resolver::~Resolver() { if(d_sock4>=0) Utility::closesocket(d_sock4); if(d_sock6>=0) Utility::closesocket(d_sock6); } uint16_t Resolver::sendResolve(const ComboAddress& remote, const char *domain, int type, bool dnssecOK, const string& tsigkeyname, const string& tsigalgorithm, const string& tsigsecret) { vector packet; DNSPacketWriter pw(packet, domain, type); pw.getHeader()->id = d_randomid = dns_random(0xffff); if(dnssecOK) { pw.addOpt(2800, 0, EDNSOpts::DNSSECOK); pw.commit(); } if(!tsigkeyname.empty()) { // cerr<<"Adding TSIG to notification, key name: '"<clear(); if(mdp.d_header.rcode) return mdp.d_header.rcode; if(!origQname.empty()) { // not AXFR if(mdp.d_header.id != id) throw ResolverException("Remote nameserver replied with wrong id"); if(mdp.d_header.qdcount != 1) throw ResolverException("resolver: received answer with wrong number of questions ("+itoa(mdp.d_header.qdcount)+")"); if(mdp.d_qname != origQname+".") throw ResolverException(string("resolver: received an answer to another question (")+mdp.d_qname+"!="+ origQname+".)"); } vector ret; DNSResourceRecord rr; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { rr.qname = i->first.d_label; if(!rr.qname.empty()) boost::erase_tail(rr.qname, 1); // strip . rr.qtype = i->first.d_type; rr.ttl = i->first.d_ttl; rr.content = i->first.d_content->getZoneRepresentation(); rr.priority = 0; uint16_t qtype=rr.qtype.getCode(); if(!rr.content.empty() && (qtype==QType::MX || qtype==QType::NS || qtype==QType::CNAME)) boost::erase_tail(rr.content, 1); if(rr.qtype.getCode() == QType::MX) { vector parts; stringtok(parts, rr.content); rr.priority = atoi(parts[0].c_str()); if(parts.size() > 1) rr.content=parts[1]; else rr.content="."; } else if(rr.qtype.getCode() == QType::SRV) { rr.priority = atoi(rr.content.c_str()); vector > fields; vstringtok(fields, rr.content, " "); if(fields.size()==4) { if(fields[3].second - fields[3].first > 1) // strip dot, unless root fields[3].second--; rr.content=string(rr.content.c_str() + fields[1].first, fields[3].second - fields[1].first); } } result->push_back(rr); } return 0; } bool Resolver::tryGetSOASerial(string* domain, uint32_t *theirSerial, uint32_t *theirInception, uint32_t *theirExpire, uint16_t* id) { Utility::setNonBlocking( d_sock4 ); Utility::setNonBlocking( d_sock6 ); int sock; if(!waitFor2Data(d_sock4, d_sock6, 0, 250000, &sock)) // lame function, I know.. return false; int err; ComboAddress fromaddr; socklen_t addrlen=fromaddr.getSocklen(); char buf[3000]; err = recvfrom(sock, buf, sizeof(buf), 0,(struct sockaddr*)(&fromaddr), &addrlen); if(err < 0) { if(errno == EAGAIN) return false; throw ResolverException("recvfrom error waiting for answer: "+stringerror()); } MOADNSParser mdp((char*)buf, err); *id=mdp.d_header.id; *domain = stripDot(mdp.d_qname); if(mdp.d_answers.empty()) throw ResolverException("Query to '" + fromaddr.toStringWithPort() + "' for SOA of '" + *domain + "' produced no results (error code: "+strrcode(mdp.d_header.rcode)+")"); if(mdp.d_qtype != QType::SOA) throw ResolverException("Query to '" + fromaddr.toStringWithPort() + "' for SOA of '" + *domain + "' returned wrong record type"); *theirInception = *theirExpire = 0; bool gotSOA=false; BOOST_FOREACH(const MOADNSParser::answers_t::value_type& drc, mdp.d_answers) { if(drc.first.d_type == QType::SOA) { shared_ptr src=boost::dynamic_pointer_cast(drc.first.d_content); *theirSerial=src->d_st.serial; gotSOA = true; } if(drc.first.d_type == QType::RRSIG) { shared_ptr rrc=boost::dynamic_pointer_cast(drc.first.d_content); if(rrc->d_type == QType::SOA) { *theirInception= std::max(*theirInception, rrc->d_siginception); *theirExpire = std::max(*theirExpire, rrc->d_sigexpire); } } } if(!gotSOA) throw ResolverException("Query to '" + fromaddr.toString() + "' for SOA of '" + *domain + "' did not return a SOA"); return true; } int Resolver::resolve(const string &ipport, const char *domain, int type, Resolver::res_t* res) { try { ComboAddress to(ipport, 53); int id = sendResolve(to, domain, type); int sock = to.sin4.sin_family == AF_INET ? d_sock4 : d_sock6; int err=waitForData(sock, 0, 3000000); if(!err) { throw ResolverException("Timeout waiting for answer"); } if(err < 0) throw ResolverException("Error waiting for answer: "+stringerror()); ComboAddress from; socklen_t addrlen = sizeof(from); char buffer[3000]; int len; if((len=recvfrom(sock, buffer, sizeof(buffer), 0,(struct sockaddr*)(&from), &addrlen)) < 0) throw ResolverException("recvfrom error waiting for answer: "+stringerror()); MOADNSParser mdp(buffer, len); return parseResult(mdp, domain, type, id, res); } catch(ResolverException &re) { throw ResolverException(re.reason+" from "+ipport); } return -1; } void Resolver::getSoaSerial(const string &ipport, const string &domain, uint32_t *serial) { vector res; int ret = resolve(ipport, domain.c_str(), QType::SOA, &res); if(ret || res.empty()) throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain + "' produced no answers"); if(res[0].qtype.getCode() != QType::SOA) throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain + "' produced a "+res[0].qtype.getName()+" record"); vectorparts; stringtok(parts, res[0].content); if(parts.size()<3) throw ResolverException("Query to '" + ipport + "' for SOA of '" + domain + "' produced an unparseable response"); *serial=(uint32_t)atol(parts[2].c_str()); } AXFRRetriever::AXFRRetriever(const ComboAddress& remote, const string& domain, const string& tsigkeyname, const string& tsigalgorithm, const string& tsigsecret, const ComboAddress* laddr) : d_tsigkeyname(tsigkeyname), d_tsigsecret(tsigsecret), d_tsigPos(0), d_nonSignedMessages(0) { ComboAddress local; if (laddr != NULL) { local = (ComboAddress) (*laddr); } else { if(remote.sin4.sin_family == AF_INET) local=ComboAddress(::arg()["query-local-address"]); else if(!::arg()["query-local-address6"].empty()) local=ComboAddress(::arg()["query-local-address6"]); else local=ComboAddress("::"); } d_sock = -1; try { d_sock = makeQuerySocket(local, false); // make a TCP socket d_buf = shared_array(new char[65536]); d_remote = remote; // mostly for error reporting this->connect(); d_soacount = 0; vector packet; DNSPacketWriter pw(packet, domain, QType::AXFR); pw.getHeader()->id = dns_random(0xffff); if(!tsigkeyname.empty()) { d_trc.d_algoName = tsigalgorithm + ".sig-alg.reg.int."; d_trc.d_time = time(0); d_trc.d_fudge = 300; d_trc.d_origID=ntohs(pw.getHeader()->id); d_trc.d_eRcode=0; addTSIG(pw, &d_trc, tsigkeyname, tsigsecret, "", false); } uint16_t replen=htons(packet.size()); Utility::iovec iov[2]; iov[0].iov_base=(char*)&replen; iov[0].iov_len=2; iov[1].iov_base=(char*)&packet[0]; iov[1].iov_len=packet.size(); int ret=Utility::writev(d_sock, iov, 2); if(ret < 0) throw ResolverException("Error sending question to "+d_remote.toStringWithPort()+": "+stringerror()); if(ret != (int)(2+packet.size())) { throw ResolverException("Partial write on AXFR request to "+d_remote.toStringWithPort()); } int res = waitForData(d_sock, 10, 0); if(!res) throw ResolverException("Timeout waiting for answer from "+d_remote.toStringWithPort()+" during AXFR"); if(res<0) throw ResolverException("Error waiting for answer from "+d_remote.toStringWithPort()+": "+stringerror()); } catch(...) { if(d_sock >= 0) close(d_sock); throw; } } AXFRRetriever::~AXFRRetriever() { close(d_sock); } int AXFRRetriever::getChunk(Resolver::res_t &res) // Implementation is making sure RFC2845 4.4 is followed. { if(d_soacount > 1) return false; // d_sock is connected and is about to spit out a packet int len=getLength(); if(len<0) throw ResolverException("EOF trying to read axfr chunk from remote TCP client"); timeoutReadn(len); MOADNSParser mdp(d_buf.get(), len); int err = parseResult(mdp, "", 0, 0, &res); if(err) throw ResolverException("AXFR chunk with a non-zero rcode "+lexical_cast(err)); BOOST_FOREACH(const MOADNSParser::answers_t::value_type& answer, mdp.d_answers) if (answer.first.d_type == QType::SOA) d_soacount++; if(!d_tsigkeyname.empty()) { // TSIG verify message // If we have multiple messages, we need to concatenate them together. We also need to make sure we know the location of // the TSIG record so we can remove it in makeTSIGMessageFromTSIGPacket d_signData.append(d_buf.get(), len); if (mdp.getTSIGPos() == 0) d_tsigPos += len; else d_tsigPos += mdp.getTSIGPos(); string theirMac; bool checkTSIG = false; BOOST_FOREACH(const MOADNSParser::answers_t::value_type& answer, mdp.d_answers) { if (answer.first.d_type == QType::SOA) // A SOA is either the first or the last record. We need to check TSIG if that's the case. checkTSIG = true; if(answer.first.d_type == QType::TSIG) { shared_ptr trc = boost::dynamic_pointer_cast(answer.first.d_content); theirMac = trc->d_mac; d_trc.d_time = trc->d_time; checkTSIG = true; } } if( ! checkTSIG && d_nonSignedMessages > 99) { // We're allowed to get 100 digest without a TSIG. throw ResolverException("No TSIG message received in last 100 messages of AXFR transfer."); } if (checkTSIG) { if (theirMac.empty()) throw ResolverException("No TSIG on AXFR response from "+d_remote.toStringWithPort()+" , should be signed with TSIG key '"+d_tsigkeyname+"'"); string message; if (!d_prevMac.empty()) { message = makeTSIGMessageFromTSIGPacket(d_signData, d_tsigPos, d_tsigkeyname, d_trc, d_prevMac, true, d_signData.size()-len); } else { message = makeTSIGMessageFromTSIGPacket(d_signData, d_tsigPos, d_tsigkeyname, d_trc, d_trc.d_mac, false); } string ourMac=calculateMD5HMAC(d_tsigsecret, message); // ourMac[0]++; // sabotage == for testing :-) if(ourMac != theirMac) { throw ResolverException("Signature failed to validate on AXFR response from "+d_remote.toStringWithPort()+" signed with TSIG key '"+d_tsigkeyname+"'"); } // Reset and store some values for the next chunks. d_prevMac = theirMac; d_nonSignedMessages = 0; d_signData.clear(); d_tsigPos = 0; } else d_nonSignedMessages++; } return true; } void AXFRRetriever::timeoutReadn(uint16_t bytes) { time_t start=time(0); int n=0; int numread; while(n # include # include #endif // WIN32 #include "ueberbackend.hh" #include "dnspacket.hh" #include "packetcache.hh" #include "dnsseckeeper.hh" #include "lua-auth.hh" #include "namespaces.hh" // silly Solaris people define PC #undef PC /** Central DNS logic according to RFC1034. Ask this class a question in the form of a DNSPacket and it will return, synchronously, a DNSPacket answer, suitable for sending out over the network. The PacketHandler gives your question to the PacketCache for possible inclusion in the cache. In order to do so, the PacketHandler contains a reference to the global extern PacketCache PC It also contains an UeberBackend instance for answering the subqueries needed to generate a complete reply. */ class NSEC3PARAMRecordContent; class PacketHandler { public: template class Guard { public: Guard(T **guard) { d_guard=guard; } ~Guard() { if(*d_guard) delete *d_guard; } private: T **d_guard; }; DNSPacket *questionOrRecurse(DNSPacket *, bool* shouldRecurse); //!< hand us a DNS packet with a question, we'll tell you answer, or that you should recurse DNSPacket *question(DNSPacket *); //!< hand us a DNS packet with a question, we give you an answer PacketHandler(); ~PacketHandler(); // defined in packethandler.cc, and does --count static int numRunning(){return s_count;}; //!< Returns the number of running PacketHandlers. Called by Distributor void soaMagic(DNSResourceRecord *rr); DNSBackend *getBackend(); int trySuperMasterSynchronous(DNSPacket *p); private: int trySuperMaster(DNSPacket *p); int processNotify(DNSPacket *); void addRootReferral(DNSPacket *r); int makeCanonic(DNSPacket *p, DNSPacket *r, string &target); int findMboxFW(DNSPacket *p, DNSPacket *r, string &target); int findUrl(DNSPacket *p, DNSPacket *r, string &target); int doFancyRecords(DNSPacket *p, DNSPacket *r, string &target); int doVersionRequest(DNSPacket *p, DNSPacket *r, string &target); bool addDNSKEY(DNSPacket *p, DNSPacket *r, const SOAData& sd); bool addNSEC3PARAM(DNSPacket *p, DNSPacket *r, const SOAData& sd); bool getAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId); bool getTLDAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId); int doAdditionalProcessingAndDropAA(DNSPacket *p, DNSPacket *r, const SOAData& sd); bool doDNSSECProcessing(DNSPacket* p, DNSPacket *r); void addNSECX(DNSPacket *p, DNSPacket* r, const string &target, const string &wildcard, const std::string &auth, int mode); void addNSEC(DNSPacket *p, DNSPacket* r, const string &target, const string &wildcard, const std::string& auth, int mode); void addNSEC3(DNSPacket *p, DNSPacket* r, const string &target, const string &wildcard, const std::string& auth, const NSEC3PARAMRecordContent& nsec3param, bool narrow, int mode); void emitNSEC(const std::string& before, const std::string& after, const std::string& toNSEC, const SOAData& sd, DNSPacket *r, int mode); void emitNSEC3(const NSEC3PARAMRecordContent &ns3rc, const SOAData& sd, const std::string& unhashed, const std::string& begin, const std::string& end, const std::string& toNSEC3, DNSPacket *r, int mode); void synthesiseRRSIGs(DNSPacket* p, DNSPacket* r); void makeNXDomain(DNSPacket* p, DNSPacket* r, const std::string& target, const std::string& wildcard, SOAData& sd); void makeNOError(DNSPacket* p, DNSPacket* r, const std::string& target, const std::string& wildcard, SOAData& sd, int mode); vector getBestReferralNS(DNSPacket *p, SOAData& sd, const string &target); bool tryReferral(DNSPacket *p, DNSPacket*r, SOAData& sd, const string &target); bool getBestWildcard(DNSPacket *p, SOAData& sd, const string &target, string &wildcard, vector* ret); bool tryWildcard(DNSPacket *p, DNSPacket*r, SOAData& sd, string &target, string &wildcard, bool& retargeted, bool& nodata); bool addDSforNS(DNSPacket* p, DNSPacket* r, SOAData& sd, const string& dsname); void completeANYRecords(DNSPacket *p, DNSPacket*r, SOAData& sd, const string &target); static AtomicCounter s_count; bool d_doFancyRecords; bool d_doRecursion; bool d_doCNAME; bool d_logDNSDetails; bool d_doIPv6AdditionalProcessing; AuthLua* d_pdl; UeberBackend B; // every thread an own instance DNSSECKeeper d_dk; // same, might even share B? }; void emitNSEC3(DNSBackend& B, const NSEC3PARAMRecordContent& ns3prc, const SOAData& sd, const std::string& unhashed, const std::string& begin, const std::string& end, const std::string& toNSEC3, DNSPacket *r, int mode); bool getNSEC3Hashes(bool narrow, DNSBackend* db, int id, const std::string& hashed, bool decrement, string& unhashed, string& before, string& after); #endif /* PACKETHANDLER */ pdns-3.3/pdns/selectmplexer.cc0000644000014601777760000000616112136555572017731 0ustar00jenkinsnogroup00000000000000#include "mplexer.hh" #include "sstuff.hh" #include #include "misc.hh" #include #include "syncres.hh" #include "utility.hh" #include "namespaces.hh" #include "namespaces.hh" static FDMultiplexer* make() { return new SelectFDMultiplexer(); } static struct RegisterOurselves { RegisterOurselves() { FDMultiplexer::getMultiplexerMap().insert(make_pair(1, &make)); } } doIt; void SelectFDMultiplexer::addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const boost::any& parameter) { Callback cb; cb.d_callback=toDo; cb.d_parameter=parameter; memset(&cb.d_ttd, 0, sizeof(cb.d_ttd)); if(cbmap.count(fd)) throw FDMultiplexerException("Tried to add fd "+lexical_cast(fd)+ " to multiplexer twice"); cbmap[fd]=cb; } void SelectFDMultiplexer::removeFD(callbackmap_t& cbmap, int fd) { if(d_inrun && d_iter->first==fd) // trying to remove us! d_iter++; if(!cbmap.erase(fd)) throw FDMultiplexerException("Tried to remove unlisted fd "+lexical_cast(fd)+ " from multiplexer"); } int SelectFDMultiplexer::run(struct timeval* now) { if(d_inrun) { throw FDMultiplexerException("FDMultiplexer::run() is not reentrant!\n"); } fd_set readfds, writefds; FD_ZERO(&readfds); FD_ZERO(&writefds); int fdmax=0; for(callbackmap_t::const_iterator i=d_readCallbacks.begin(); i != d_readCallbacks.end(); ++i) { FD_SET(i->first, &readfds); fdmax=max(i->first, fdmax); } for(callbackmap_t::const_iterator i=d_writeCallbacks.begin(); i != d_writeCallbacks.end(); ++i) { FD_SET(i->first, &writefds); fdmax=max(i->first, fdmax); } struct timeval tv={0,500000}; int ret=select(fdmax + 1, &readfds, &writefds, 0, &tv); Utility::gettimeofday(now, 0); // MANDATORY! if(ret < 0 && errno!=EINTR) throw FDMultiplexerException("select returned error: "+stringerror()); if(ret < 1) // nothing - thanks AB return 0; d_iter=d_readCallbacks.end(); d_inrun=true; for(callbackmap_t::iterator i=d_readCallbacks.begin(); i != d_readCallbacks.end() && i->first <= fdmax; ) { d_iter=i++; if(FD_ISSET(d_iter->first, &readfds)) { d_iter->second.d_callback(d_iter->first, d_iter->second.d_parameter); continue; // so we don't refind ourselves as writable } } for(callbackmap_t::iterator i=d_writeCallbacks.begin(); i != d_writeCallbacks.end() && i->first <= fdmax; ) { d_iter=i++; if(FD_ISSET(d_iter->first, &writefds)) { d_iter->second.d_callback(d_iter->first, d_iter->second.d_parameter); } } d_inrun=false; return 0; } #if 0 void acceptData(int fd, boost::any& parameter) { cout<<"Have data on fd "<(parameter); string packet; IPEndpoint rem; sock->recvFrom(packet, rem); cout<<"Received "< #include #include #include #include #include #include #include "dns_random.hh" #include "namespaces.hh" using namespace boost; using namespace boost::accumulators; typedef accumulator_set< double , stats > acc_t; BOOST_AUTO_TEST_SUITE(test_dns_random_hh) BOOST_AUTO_TEST_CASE(test_dns_random_average) { dns_random_init("/dev/urandom"); acc_t acc; for(unsigned int n=0; n < 100000; ++n) { acc(dns_random(100000)/100000.0); } BOOST_CHECK_CLOSE(0.5, median(acc), 2.0); // within 2% BOOST_CHECK_CLOSE(0.5, mean(acc), 2.0); // please add covariance tests, chi-square, Kolmogorov-Smirnov } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/dnssec.schema.mysql.sql0000644000014601777760000000160512136555572021147 0ustar00jenkinsnogroup00000000000000create table domainmetadata ( id INT auto_increment, domain_id INT NOT NULL, kind VARCHAR(16), content TEXT, primary key(id) ); create index domainmetaidindex on domainmetadata(domain_id); create table cryptokeys ( id INT auto_increment, domain_id INT NOT NULL, flags INT NOT NULL, active BOOL, content TEXT, primary key(id) ); create index domainidindex on cryptokeys(domain_id); alter table records add ordername VARCHAR(255) BINARY; alter table records add auth bool; create index recordorder on records (domain_id, ordername); create table tsigkeys ( id INT auto_increment, name VARCHAR(255), algorithm VARCHAR(50), secret VARCHAR(255), primary key(id) ); create unique index namealgoindex on tsigkeys(name, algorithm); alter table records change column type type VARCHAR(10); pdns-3.3/pdns/ws.hh0000644000014601777760000000505612140444471015510 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2009 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef WS_HH #define WS_HH #include #include #include #include #include #include #ifndef WIN32 # include #endif // WIN32 #ifdef HAVE_CONFIG_H # include #endif // HAVE_CONFIG_H #include "misc.hh" #include "namespaces.hh" class Ewma { public: Ewma() : d_last(0), d_10(0), d_5(0), d_1(0), d_max(0){dt.set();} void submit(int val) { int rate=val-d_last; double difft=dt.udiff()/1000000.0; dt.set(); d_10=((600.0-difft)*d_10+(difft*rate))/600.0; d_5=((300.0-difft)*d_5+(difft*rate))/300.0; d_1=((60.0-difft)*d_1+(difft*rate))/60.0; d_max=max(d_1,d_max); d_last=val; } double get10() { return d_10; } double get5() { return d_5; } double get1() { return d_1; } double getMax() { return d_max; } private: DTime dt; int d_last; double d_10, d_5, d_1, d_max; }; class WebServer; class StatWebServer { public: StatWebServer(); void go(); static string makePercentage(const double& val); private: static void *threadHelper(void *); static void *statThreadHelper(void *p); static string indexfunction(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); static string cssfunction(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); static string jsonstat(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); void printvars(ostringstream &ret); void printargs(ostringstream &ret); void launch(); void statThread(); pthread_t d_tid; time_t d_start; double d_min10, d_min5, d_min1; Ewma d_queries, d_cachehits, d_cachemisses; Ewma d_qcachehits, d_qcachemisses; WebServer *d_ws; }; #endif pdns-3.3/pdns/htimer.hh0000644000014601777760000000250012136555572016350 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_HTIMER_HH #define PDNS_HTIMER_HH #include #include #include #include class HTimerSentinel; // typedef boost::shared_ptr HTimerSentinel; class HTimer : public boost::noncopyable { public: HTimer(){}; explicit HTimer(const std::string& name); ~HTimer(); void start(); void stop(); uint64_t getAccumulated() const; uint64_t getAccumulatedReset(); HTimerSentinel getSentinel(); static void listAll(); private: typedef std::map timers_t; static timers_t s_timers; uint64_t d_accumulated; uint64_t d_started; }; class HTimerSentinel { public: explicit HTimerSentinel(class HTimer* parent) : d_parent(parent) { d_rc=1; d_parent->start(); } HTimerSentinel(const HTimerSentinel& orig) { d_parent = orig.d_parent; orig.d_rc++; } ~HTimerSentinel() { if(!--d_rc) d_parent->stop(); } private: HTimerSentinel& operator=(const HTimerSentinel& rhs); HTimer* d_parent; mutable unsigned int d_rc; }; class HTimerSentinelImp : public boost::noncopyable { public: explicit HTimerSentinelImp(class HTimer* parent) : d_parent(parent) { d_parent->start(); } ~HTimerSentinelImp() { d_parent->stop(); } private: HTimer* d_parent; }; #endif pdns-3.3/pdns/dnssecsigner.cc0000644000014601777760000001735512142141727017541 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2001 - 2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dnssecinfra.hh" #include "namespaces.hh" #include #include "md5.hh" #include "dnsseckeeper.hh" #include "dns_random.hh" #include "lock.hh" /* this is where the RRSIGs begin, keys are retrieved, but the actual signing happens in fillOutRRSIG */ int getRRSIGsForRRSET(DNSSECKeeper& dk, const std::string& signer, const std::string signQName, uint16_t signQType, uint32_t signTTL, vector >& toSign, vector& rrcs, bool ksk) { if(toSign.empty()) return -1; uint32_t startOfWeek = getStartOfWeek(); RRSIGRecordContent rrc; rrc.d_type=signQType; rrc.d_labels=countLabels(signQName); rrc.d_originalttl=signTTL; rrc.d_siginception=startOfWeek - 7*86400; // XXX should come from zone metadata rrc.d_sigexpire=startOfWeek + 14*86400; rrc.d_signer = signer.empty() ? "." : toLower(signer); rrc.d_tag = 0; // we sign the RRSET in toSign + the rrc w/o hash DNSSECKeeper::keyset_t keys = dk.getKeys(signer); // we don't want the . for the root! vector KSKs, ZSKs; vector* signingKeys; // if ksk==1, only get KSKs // if ksk==0, get ZSKs, unless there is no ZSK, then get KSK BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type& keymeta, keys) { rrc.d_algorithm = keymeta.first.d_algorithm; if(!keymeta.second.active) continue; if(keymeta.second.keyOrZone) KSKs.push_back(keymeta.first); else if(!ksk) ZSKs.push_back(keymeta.first); } if(ksk) signingKeys = &KSKs; else { if(ZSKs.empty()) signingKeys = &KSKs; else signingKeys =&ZSKs; } BOOST_FOREACH(DNSSECPrivateKey& dpk, *signingKeys) { fillOutRRSIG(dpk, signQName, rrc, toSign); rrcs.push_back(rrc); } return 0; } // this is the entrypoint from DNSPacket void addSignature(DNSSECKeeper& dk, DNSBackend& db, const std::string& signer, const std::string signQName, const std::string& wildcardname, uint16_t signQType, uint32_t signTTL, DNSPacketWriter::Place signPlace, vector >& toSign, vector& outsigned, uint32_t origTTL) { //cerr<<"Asked to sign '"< rrcs; if(dk.isPresigned(signer)) { //cerr<<"Doing presignatures"<, string> signaturecache_t; static signaturecache_t g_signatures; static int g_cacheweekno; void fillOutRRSIG(DNSSECPrivateKey& dpk, const std::string& signQName, RRSIGRecordContent& rrc, vector >& toSign) { DNSKEYRecordContent drc = dpk.getDNSKEY(); const DNSCryptoKeyEngine* rc = dpk.getKey(); rrc.d_tag = drc.getTag(); rrc.d_algorithm = drc.d_algorithm; string msg=getMessageForRRSET(signQName, rrc, toSign); // this is what we will hash & sign pair lookup(rc->getPubKeyHash(), pdns_md5sum(msg)); // this hash is a memory saving exercise bool doCache=1; if(doCache) { ReadLock l(&g_signatures_lock); signaturecache_t::const_iterator iter = g_signatures.find(lookup); if(iter != g_signatures.end()) { rrc.d_signature=iter->second; return; } else ; // cerr<<"Miss!"<sign(msg); if(doCache) { WriteLock l(&g_signatures_lock); /* we add some jitter here so not all your slaves start pruning their caches at the very same millisecond */ int weekno = (time(0) - dns_random(3600)) / (86400*7); // we just spent milliseconds doing a signature, microsecond more won't kill us if(g_cacheweekno < weekno) { // blunt but effective (C) Habbie g_signatures.clear(); g_cacheweekno = weekno; } g_signatures[lookup] = rrc.d_signature; } } static bool rrsigncomp(const DNSResourceRecord& a, const DNSResourceRecord& b) { return tie(a.d_place, a.qtype) < tie(b.d_place, b.qtype); } static bool getBestAuthFromSet(const set& authSet, const string& name, string& auth) { auth.clear(); string sname(name); do { if(authSet.find(sname) != authSet.end()) { auth = sname; return true; } } while(chopOff(sname)); return false; } void addRRSigs(DNSSECKeeper& dk, DNSBackend& db, const set& authSet, vector& rrs) { stable_sort(rrs.begin(), rrs.end(), rrsigncomp); string signQName, wildcardQName; uint16_t signQType=0; uint32_t signTTL=0; uint32_t origTTL=0; DNSPacketWriter::Place signPlace=DNSPacketWriter::ANSWER; vector > toSign; vector signedRecords; string signer; for(vector::const_iterator pos = rrs.begin(); pos != rrs.end(); ++pos) { if(pos != rrs.begin() && (signQType != pos->qtype.getCode() || signQName != pos->qname)) { if(getBestAuthFromSet(authSet, signQName, signer)) addSignature(dk, db, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL); } signedRecords.push_back(*pos); signQName= pos->qname; wildcardQName = pos->wildcardname; signQType = pos ->qtype.getCode(); if(pos->signttl) signTTL = pos->signttl; else signTTL = pos->ttl; origTTL = pos->ttl; signPlace = (DNSPacketWriter::Place) pos->d_place; if(pos->auth || pos->qtype.getCode() == QType::DS) { string content = pos->content; if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) { content = lexical_cast(pos->priority) + " " + pos->content; } if(!pos->content.empty() && pos->qtype.getCode()==QType::TXT && pos->content[0]!='"') { content="\""+pos->content+"\""; } if(pos->content.empty()) // empty contents confuse the MOADNS setup content="."; shared_ptr drc(DNSRecordContent::mastermake(pos->qtype.getCode(), 1, content)); toSign.push_back(drc); } } if(getBestAuthFromSet(authSet, signQName, signer)) addSignature(dk, db, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL); rrs.swap(signedRecords); } pdns-3.3/pdns/arguments.hh0000644000014601777760000001066112145356404017065 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef ARGUMENTS_HH #define ARGUMENTS_HH #include #include #include #include #include #include "misc.hh" #include "ahuexception.hh" #ifndef WIN32 # include # include # include #endif #include "namespaces.hh" typedef AhuException ArgException; /** This class helps parsing argc and argv into a map of parameters. We have 3 kinds of formats: -w this leads to a key/value pair of "w"/void --port=25 "port"/"25" --daemon "daemon"/void We do not support "--port 25" syntax. It can also read from a file. This file can contain '#' to delimit comments. Some sample code: \code ArgvMap R; R.set("port")="25"; // use this to specify default parameters R.file("./default.conf"); // parse configuration file R.parse(argc, argv); // read the arguments from main() cout<<"Will we be a deamon?: "<::const_iterator i; cout<<"via iterator"<first<<"="<second< param_t; //!< use this if you need to know the content of the map bool parmIsset(const string &var); //!< Checks if a parameter is set to *a* value bool mustDo(const string &var); //!< if a switch is given, if we must do something (--help) int asNum(const string &var); //!< return a variable value as a number #ifndef WIN32 mode_t asMode(const string &var); //list(); string getHelp(const string &item); const param_t::const_iterator begin(); //!< iterator semantics const param_t::const_iterator end(); //!< iterator semantics const string &operator[](const string &); //!< iterator semantics const vector&getCommands(); private: void parseOne(const string &unparsed, const string &parseOnly="", bool lax=false); typedef map params_t; params_t params; map helpmap; map d_typeMap; vector d_cmds; }; extern ArgvMap &arg(); #endif /* ARGUMENTS_HH */ pdns-3.3/pdns/test-nameserver_cc.cc0000644000014601777760000000303412142002512020614 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include "iputils.hh" #include "nameserver.hh" #include "statbag.hh" #include "arguments.hh" #include extern vector g_localaddresses; StatBag S; ArgvMap &arg() { static ArgvMap theArg; return theArg; } BOOST_AUTO_TEST_SUITE(nameserver_cc) BOOST_AUTO_TEST_CASE(test_AddressIsUs4) { ComboAddress local1("127.0.0.1", 53); ComboAddress local2("127.0.0.2", 53); ComboAddress Remote("192.168.255.255", 53); g_localaddresses.push_back(ComboAddress("0.0.0.0", 53)); BOOST_CHECK_EQUAL(AddressIsUs(local1), true); // BOOST_CHECK_EQUAL(AddressIsUs(local2), false); BOOST_CHECK_EQUAL(AddressIsUs(Remote), false); g_localaddresses.clear(); g_localaddresses.push_back(ComboAddress("192.168.255.255", 53)); BOOST_CHECK_EQUAL(AddressIsUs(Remote), true); Remote.sin4.sin_port = 1; BOOST_CHECK_EQUAL(AddressIsUs(Remote), false); } BOOST_AUTO_TEST_CASE(test_AddressIsUs6) { ComboAddress local1("127.0.0.1", 53); ComboAddress local2("127.0.0.2", 53); ComboAddress local3("::1", 53); ComboAddress Remote("192.168.255.255", 53); g_localaddresses.clear(); g_localaddresses.push_back(ComboAddress("::", 53)); BOOST_CHECK_EQUAL(AddressIsUs(local1), true); // BOOST_CHECK_EQUAL(AddressIsUs(local2), false); BOOST_CHECK_EQUAL(AddressIsUs(local3), true); BOOST_CHECK_EQUAL(AddressIsUs(Remote), false); Remote.sin4.sin_port = 1; BOOST_CHECK_EQUAL(AddressIsUs(Remote), false); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/ws.cc0000644000014601777760000006412212143161064015472 0ustar00jenkinsnogroup00000000000000/* Copyright (C) 2002 - 2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include "dynlistener.hh" #include "ws.hh" #include "json.hh" #include "webserver.hh" #include "logger.hh" #include "packetcache.hh" #include "statbag.hh" #include "misc.hh" #include "arguments.hh" #include "dns.hh" #include "ueberbackend.hh" #include #include #include "namespaces.hh" #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "version.hh" using namespace rapidjson; extern StatBag S; StatWebServer::StatWebServer() { d_start=time(0); d_min10=d_min5=d_min1=0; d_ws = 0; if(arg().mustDo("webserver")) d_ws = new WebServer(arg()["webserver-address"], arg().asNum("webserver-port"),arg()["webserver-password"]); } void StatWebServer::go() { if(arg().mustDo("webserver")) { S.doRings(); pthread_create(&d_tid, 0, threadHelper, this); pthread_create(&d_tid, 0, statThreadHelper, this); } } void StatWebServer::statThread() { try { for(;;) { d_queries.submit(S.read("udp-queries")); d_cachehits.submit(S.read("packetcache-hit")); d_cachemisses.submit(S.read("packetcache-miss")); d_qcachehits.submit(S.read("query-cache-hit")); d_qcachemisses.submit(S.read("query-cache-miss")); Utility::sleep(1); } } catch(...) { L<(p); sws->statThread(); return 0; // never reached } void *StatWebServer::threadHelper(void *p) { StatWebServer *sws=static_cast(p); sws->launch(); return 0; // never reached } void printtable(ostringstream &ret, const string &ringname, const string &title, int limit=10) { int tot=0; int entries=0; vector >ring=S.getRing(ringname); for(vector >::const_iterator i=ring.begin(); i!=ring.end();++i) { tot+=i->second; entries++; } ret<<""; ret<<""; int printed=0; for(vector >::const_iterator i=ring.begin();limit && i!=ring.end();++i,--limit) { ret<<""<second; } ret<<""<"<"; ret<<"
"<first<<""<second<<""<< StatWebServer::makePercentage(i->second*100.0/tot)<<"
Rest:"<"<< StatWebServer::makePercentage((tot-printed)*100.0/tot)<<"Total:"<100%
"<

Variables

"<entries=S.getEntries(); for(vector::const_iterator i=entries.begin();i!=entries.end();++i) { ret<<""<entries=arg().list(); for(vector::const_iterator i=entries.begin();i!=entries.end();++i) { ret<<"
"<<*i<<""<"<"<"<
Arguments
"<<*i<<""<"<"< &varmap, void *ptr, bool *custom) { StatWebServer *sws=static_cast(ptr); maprvarmap=varmap; if(!rvarmap["resetring"].empty()){ *custom=true; S.resetRing(rvarmap["resetring"]); return "HTTP/1.1 301 Moved Permanently\nLocation: /\nConnection: close\n\n"; } if(!rvarmap["resizering"].empty()){ *custom=true; S.resizeRing(rvarmap["resizering"], atoi(rvarmap["size"].c_str())); return "HTTP/1.1 301 Moved Permanently\nLocation: /\nConnection: close\n\n"; } ostringstream ret; ret<<""<"<PowerDNS Authoritative Server Monitor"<"<"<"<"; ret<<"PowerDNS "VERSION; if(!arg()["config-name"].empty()) { ret<<" ["<"<"; ret<<"
"; time_t passed=time(0)-s_starttime; ret<<"

Uptime: "<< humanDuration(passed)<< "
"<d_queries.get1()<<", "<< sws->d_queries.get5()<<", "<< sws->d_queries.get10()<<". Max queries/second: "<d_queries.getMax()<< "
"<d_cachemisses.get10()+sws->d_cachehits.get10()>0) ret<<"Cache hitrate, 1, 5, 10 minute averages: "<< makePercentage((sws->d_cachehits.get1()*100.0)/((sws->d_cachehits.get1())+(sws->d_cachemisses.get1())))<<", "<< makePercentage((sws->d_cachehits.get5()*100.0)/((sws->d_cachehits.get5())+(sws->d_cachemisses.get5())))<<", "<< makePercentage((sws->d_cachehits.get10()*100.0)/((sws->d_cachehits.get10())+(sws->d_cachemisses.get10())))<< "
"<d_qcachemisses.get10()+sws->d_qcachehits.get10()>0) ret<<"Backend query cache hitrate, 1, 5, 10 minute averages: "<d_qcachehits.get1()*100.0)/((sws->d_qcachehits.get1())+(sws->d_qcachemisses.get1())))<<", "<< makePercentage((sws->d_qcachehits.get5()*100.0)/((sws->d_qcachehits.get5())+(sws->d_qcachemisses.get5())))<<", "<< makePercentage((sws->d_qcachehits.get10()*100.0)/((sws->d_qcachehits.get10())+(sws->d_qcachemisses.get10())))<< "
"<d_qcachemisses.get1()<<", "<< sws->d_qcachemisses.get5()<<", "<< sws->d_qcachemisses.get10()<<". Max queries/second: "<d_qcachemisses.getMax()<< "
"<
"<entries=S.listRings(); for(vector::const_iterator i=entries.begin();i!=entries.end();++i) printtable(ret,*i,S.getRingTitle(*i)); sws->printvars(ret); if(arg().mustDo("webserver-print-arguments")) sws->printargs(ret); } else printtable(ret,rvarmap["ring"],S.getRingTitle(rvarmap["ring"]),100); ret<<"

"<"<© 2013
PowerDNS.COM BV."<"< &varmap, void *ptr, bool *custom) { *custom=1; // indicates we build the response string ret="HTTP/1.1 200 OK\r\n" "Server: PowerDNS/"VERSION"\r\n" "Connection: close\r\n" "Access-Control-Allow-Origin: *\r\n" "Content-Type: application/json\r\n" "\r\n" ; typedef map varmap_t; varmap_t ourvarmap=varmap; string callback; string command; if(ourvarmap.count("callback")) { callback=ourvarmap["callback"]; ourvarmap.erase("callback"); } if(ourvarmap.count("command")) { command=ourvarmap["command"]; ourvarmap.erase("command"); } ourvarmap.erase("_"); if(!callback.empty()) ret += callback+"("; if(command=="get") { if(ourvarmap.empty()) { vector entries = S.getEntries(); BOOST_FOREACH(string& ent, entries) { ourvarmap[ent]; } ourvarmap["version"]; ourvarmap["uptime"]; } string variable, value; Document doc; doc.SetObject(); for(varmap_t::const_iterator iter = ourvarmap.begin(); iter != ourvarmap.end() ; ++iter) { variable = iter->first; if(variable == "version") { value =VERSION; } else if(variable == "uptime") { value = lexical_cast(time(0) - s_starttime); } else value = lexical_cast(S.read(variable)); Value jval; jval.SetString(value.c_str(), value.length(), doc.GetAllocator()); doc.AddMember(variable.c_str(), jval, doc.GetAllocator()); } ret+=makeStringFromDocument(doc); } if(command=="config") { vector items = ::arg().list(); Document doc; doc.SetArray(); BOOST_FOREACH(const string& var, items) { Value kv, key, value; kv.SetArray(); key.SetString(var.c_str(), var.length()); kv.PushBack(key, doc.GetAllocator()); if(var.find("password") != string::npos) value="*****"; else value.SetString(::arg()[var].c_str(), ::arg()[var].length(), doc.GetAllocator()); kv.PushBack(value, doc.GetAllocator()); doc.PushBack(kv, doc.GetAllocator()); } ret += makeStringFromDocument(doc); } if(command == "flush-cache") { extern PacketCache PC; int number; if(ourvarmap["domain"].empty()) number = PC.purge(); else number = PC.purge(ourvarmap["domain"]); map object; object["number"]=lexical_cast(number); //cerr<<"Flushed cache for '"<list(ourvarmap["zone"], sd.domain_id); DNSResourceRecord rr; ret+="["; map object; bool first=1; while(sd.db->get(rr)) { if(!first) ret += ", "; first=false; object.clear(); object["name"] = rr.qname; object["type"] = rr.qtype.getName(); object["ttl"] = lexical_cast(rr.ttl); object["priority"] = lexical_cast(rr.priority); object["content"] = rr.content; ret+=returnJSONObject(object); } ret += "]"; } if(command == "pdns-control") { if(method!="POST") { map m; m["error"]="pdns-control requires a POST"; return ret + returnJSONObject(m); } // cout<<"post: "<(post.c_str()).HasParseError()) { return ret+"{\"error\": \"Unable to parse JSON\""; } // cout<<"Parameters: '"< parameters; stringtok(parameters, document["parameters"].GetString(), " \t"); DynListener::g_funk_t* ptr=0; if(!parameters.empty()) ptr = DynListener::getFunc(toUpper(parameters[0])); map m; if(ptr) { m["result"] = (*ptr)(parameters, 0); } else { m["error"]="No such function "+toUpper(parameters[0]); } ret+= returnJSONObject(m); } if(command == "zone-rest") { // http://jsonstat?command=zone-rest&rest=/powerdns.nl/www.powerdns.nl/a vector parts; stringtok(parts, ourvarmap["rest"], "/"); if(parts.size() != 3) return ret+"{\"error\": \"Could not parse rest parameter\"}"; UeberBackend B; SOAData sd; sd.db = (DNSBackend*)-1; if(!B.getSOA(parts[0], sd) || !sd.db) { map err; err["error"]= "Could not find domain '"+parts[0]+"'"; return ret+returnJSONObject(err); } QType qtype; qtype=parts[2]; string qname=parts[1]; extern PacketCache PC; PC.purge(qname); // cerr<<"domain id: "< object; bool first=1; while(B.get(rr)) { if(!first) ret += ", "; first=false; object.clear(); object["name"] = rr.qname; object["type"] = rr.qtype.getName(); object["ttl"] = lexical_cast(rr.ttl); object["priority"] = lexical_cast(rr.priority); object["content"] = rr.content; ret+=returnJSONObject(object); } ret+="]}"; } else if(method=="DELETE") { sd.db->replaceRRSet(sd.domain_id, qname, qtype, vector()); } else if(method=="POST") { rapidjson::Document document; if(document.Parse<0>(post.c_str()).HasParseError()) { return ret+"{\"error\": \"Unable to parse JSON\""; } DNSResourceRecord rr; vector rrset; const rapidjson::Value &records= document["records"]; for(rapidjson::SizeType i = 0; i < records.Size(); ++i) { const rapidjson::Value& record = records[i]; rr.qname=record["name"].GetString(); rr.content=record["content"].GetString(); rr.qtype=record["type"].GetString(); rr.domain_id = sd.domain_id; rr.auth=0; rr.ttl=atoi(record["ttl"].GetString()); rr.priority=atoi(record["priority"].GetString()); rrset.push_back(rr); if(rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) rr.content = lexical_cast(rr.priority)+" "+rr.content; try { shared_ptr drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); string tmp=drc->serialize(rr.qname); } catch(std::exception& e) { map err; err["error"]= "Following record had a problem: "+rr.qname+" IN " +rr.qtype.getName()+ " " + rr.content+": "+e.what(); return ret+returnJSONObject(err); } } // but now what sd.db->startTransaction(qname); sd.db->replaceRRSet(sd.domain_id, qname, qtype, rrset); sd.db->commitTransaction(); return ret+post; } } if(command=="log-grep") { ret += makeLogGrepJSON(ourvarmap, ::arg()["experimental-logfile"], " pdns["); } const char *kinds[]={"Master", "Slave", "Native"}; if(command=="domains") { UeberBackend B; vector domains; B.getAllDomains(&domains); Document doc; doc.SetObject(); Value jdomains; jdomains.SetArray(); BOOST_FOREACH(const DomainInfo& di, domains) { Value jdi; jdi.SetObject(); jdi.AddMember("name", di.zone.c_str(), doc.GetAllocator()); jdi.AddMember("kind", kinds[di.kind], doc.GetAllocator()); string masters = boost::join(di.masters, " "); Value jmasters; jmasters.SetString(masters.c_str(), masters.size(), doc.GetAllocator()); jdi.AddMember("masters", jmasters, doc.GetAllocator()); // ^^^ this makes an actual copy, otherwise the zerocopy behaviour bites us! jdi.AddMember("serial", di.serial, doc.GetAllocator()); jdi.AddMember("notified_serial", di.notified_serial, doc.GetAllocator()); jdi.AddMember("last_check", (unsigned int) di.last_check, doc.GetAllocator()); jdomains.PushBack(jdi, doc.GetAllocator()); } doc.AddMember("domains", jdomains, doc.GetAllocator()); ret.append(makeStringFromDocument(doc)); } if(!callback.empty()) { ret += ");"; } return ret; } string StatWebServer::cssfunction(const string& method, const string& post, const map &varmap, void *ptr, bool *custom) { *custom=1; // indicates we build the response ostringstream ret; ret<<"HTTP/1.1 200 OK\r\n" "Server: PowerDNS/"VERSION"\r\n" "Connection: close\r\n" "Cache-Control: max-age=86400\r\n" "Content-Type: text/css\r\n" "\r\n"; ret<<"* { box-sizing: border-box; margin: 0; padding: 0; }"<setCaller(this); d_ws->registerHandler("",&indexfunction); d_ws->registerHandler("style.css",&cssfunction); if(::arg().mustDo("experimental-json-interface")) d_ws->registerHandler("jsonstat", &jsonstat); d_ws->go(); } catch(...) { L< #include #include #include #include #include "misc.hh" #include "iputils.hh" void Session::init() { d_bufsize=15049; // why?! d_verbose=false; rdbuf=new char[d_bufsize]; rdoffset=0; wroffset=0; } void Session::beVerbose() { d_verbose=true; } Session::Session(int s, struct sockaddr_in r) { init(); remote=r; clisock=s; } int Session::close() { int rc=0; if(clisock>=0) rc=Utility::closesocket(clisock); clisock=-1; return rc; } Session::~Session() { /* NOT CLOSING AUTOMATICALLY ANYMORE! if(clisock>=0) ::close(clisock); */ delete[] rdbuf; } //! This function makes a deep copy of Session Session::Session(const Session &s) { d_bufsize=s.d_bufsize; init(); // needs d_bufsize, but will reset rdoffset & wroffset rdoffset=s.rdoffset; wroffset=s.wroffset; clisock=s.clisock; remote=s.remote; memcpy(rdbuf,s.rdbuf,d_bufsize); } void Session::setTimeout(unsigned int seconds) { d_timeout=seconds; } bool Session::putLine(const string &s) { int length=s.length(); int written=0; int err; while(written < length) { err=waitForRWData(clisock, false, d_timeout, 0); if(err<=0) throw SessionException("nonblocking write failed: "+string(strerror(errno))); err = send(clisock, s.c_str() + written, length-written, 0); if(err < 0) return false; written+=err; } return true; } char *strnchr(char *p, char c, int len) { int n; for(n=0;n= (int)bytes) { ret = string(rdbuf + rdoffset, bytes); bytes -= ret.length(); rdoffset += ret.length(); } if(bytes) { scoped_array buffer(new char[bytes]); int err = read(clisock, &buffer[0], bytes); // XXX FIXME should be nonblocking if(err < 0) throw SessionException("Error reading bytes from client: "+string(strerror(errno))); if(err != (int)bytes) throw SessionException("Error reading bytes from client: partial read"); ret.append(&buffer[0], err); } return ret; } int Session::timeoutRead(int s, char *buf, size_t len) { int err = waitForRWData(s, true, d_timeout, 0); if(!err) throw SessionTimeoutException("timeout reading"); if(err < 0) throw SessionException("nonblocking read failed: "+string(strerror(errno))); return recv(s,buf,len,0); } bool Session::haveLine() { return (wroffset!=rdoffset && (strnchr(rdbuf+rdoffset,'\n',wroffset-rdoffset)!=NULL)); } bool Session::getLine(string &line) { int bytes; char *p; int linelength; // read data into a buffer // find first \n, and return that as string, store how far we were for(;;) { if(wroffset==rdoffset) { wroffset=rdoffset=0; } if(wroffset!=rdoffset && (p=strnchr(rdbuf+rdoffset,'\n',wroffset-rdoffset))) // we have a full line in store, return that { // from rdbuf+rdoffset to p should become the new line linelength=p-(rdbuf+rdoffset); *p=0; // terminate line=rdbuf+rdoffset; line+="\n"; rdoffset+=linelength+1; return true; } // we need more data before we can return a line if(wroffset==d_bufsize) // buffer is full, flush to left { if(!rdoffset) // line too long! { // FIXME: do stuff close(); return false; } memmove(rdbuf,rdbuf+rdoffset,wroffset-rdoffset); wroffset-=rdoffset; rdoffset=0; } bytes=timeoutRead(clisock,rdbuf+wroffset,d_bufsize-wroffset); if(bytes<0) throw SessionException("error on read from socket: "+string(strerror(errno))); if(bytes==0) throw SessionException("Remote closed connection"); wroffset+=bytes; } // we never get here } int Session::getSocket() { return clisock; } string Session::getRemote () { ostringstream o; uint32_t rint=htonl(remote.sin_addr.s_addr); o<< (rint>>24 & 0xff)<<"."; o<< (rint>>16 & 0xff)<<"."; o<< (rint>>8 & 0xff)<<"."; o<< (rint & 0xff); o<<":"<>24 & 0xff)<<"."; o<< (rint>>16 & 0xff)<<"."; o<< (rint>>8 & 0xff)<<"."; o<< (rint & 0xff); return o.str(); } Session *Server::accept() { struct sockaddr_in remote; Utility::socklen_t len=sizeof(remote); int clisock=-1; while((clisock=::accept(s,(struct sockaddr *)(&remote),&len))==-1) // repeat until we have a successful connect { // L< packet; DNSPacketWriter pw(packet, argv[3], DNSRecordContent::TypeToNumber(argv[4])); pw.getHeader()->id=htons(0x4831); string key; B64Decode("Syq9L9WrBWdxBC+HxKok2g==", key); string keyname("pdns-b-aa"); TSIGRecordContent trc; trc.d_algoName="hmac-md5.sig-alg.reg.int."; trc.d_time=time(0); trc.d_fudge=300; trc.d_origID=ntohs(pw.getHeader()->id); trc.d_eRcode=0; addTSIG(pw, &trc, keyname, key, "", false); Socket sock(InterNetwork, Datagram); ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); #if 0 sock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), dest); string reply; sock.recvFrom(reply, dest); MOADNSParser mdp(reply); cout<<"Reply to question for qname='"< trc2; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { cout<first.d_place-1<<"\t"<first.d_label<<"\tIN\t"<first.d_type, i->first.d_class); cout<<"\t"<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; if(i->first.d_type == QType::TSIG) trc2 = boost::dynamic_pointer_cast(i->first.d_content); } if(mdp.getTSIGPos()) { string message = makeTSIGMessageFromTSIGPacket(reply, mdp.getTSIGPos(), keyname, trc, trc.d_mac, false); // insert our question MAC string hmac2=calculateMD5HMAC(key, message); cerr<<"Calculated mac: "<d_mac) cerr<<"MATCH!"< res; while(axfr.getChunk(res)) { } return 0; } catch(std::exception &e) { cerr<<"Fatal: "< #include #include #include #include "iputils.hh" #include "ednssubnet.hh" #ifndef WIN32 #include #include #include #include #include #endif // WIN32 #include #include #include #include "qtype.hh" #include "dns.hh" #include "misc.hh" #include "utility.hh" #include "logger.hh" #include "ahuexception.hh" #include "dnsrecords.hh" #ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H #ifdef WIN32 # ifdef BYTE_ORDER # undef BYTE_ORDER # endif // BYTE_ORDER # define BYTE_ORDER LITTLE_ENDIAN #endif // WIN32 class DNSBackend; class DNSSECKeeper; //! This class represents DNS packets, either received or to be sent. class DNSPacket { public: DNSPacket(); DNSPacket(const DNSPacket &orig); int noparse(const char *mesg, int len); //!< just suck the data inward int parse(const char *mesg, int len); //!< parse a raw UDP or TCP packet and suck the data inward const string& getString(); //!< for serialization - just passes the whole packet // address & socket manipulation void setRemote(const ComboAddress*); string getRemote() const; Netmask getRealRemote() const; string getLocal() const { ComboAddress ca; socklen_t len=sizeof(ca); getsockname(d_socket, (sockaddr*)&ca, &len); return ca.toString(); } uint16_t getRemotePort() const; boost::optional d_anyLocal; Utility::sock_t getSocket() const { return d_socket; } void setSocket(Utility::sock_t sock); // these manipulate 'd' void setA(bool); //!< make this packet authoritative - manipulates 'd' void setID(uint16_t); //!< set the DNS id of this packet - manipulates 'd' void setRA(bool); //!< set the Recursion Available flag - manipulates 'd' void setRD(bool); //!< set the Recursion Desired flag - manipulates 'd' void setAnswer(bool); //!< Make this packet an answer - clears the 'stringbuffer' first, if passed 'true', does nothing otherwise, manipulates 'd' void setOpcode(uint16_t); //!< set the Opcode of this packet - manipulates 'd' void setRcode(int v); //!< set the Rcode of this packet - manipulates 'd' void clearRecords(); //!< when building a packet, wipe all previously added records (clears 'rrs') /** Add a DNSResourceRecord to this packet. A DNSPacket (as does a DNS Packet) has 4 kinds of resource records. Questions, Answers, Authority and Additional. See RFC 1034 and 1035 for details. You can specify where a record needs to go in the DNSResourceRecord d_place field */ void addRecord(const DNSResourceRecord &); // adds to 'rrs' void setQuestion(int op, const string &qdomain, int qtype); // wipes 'd', sets a random id, creates start of packet (label, type, class etc) DTime d_dt; //!< the time this packet was created. replyPacket() copies this in for you, so d_dt becomes the time spent processing the question+answer void wrapup(); // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer void spoofQuestion(const DNSPacket *qd); //!< paste in the exact right case of the question. Useful for PacketCache unsigned int getMinTTL(); //!< returns lowest TTL of any record in the packet vector getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing vector getAnswerRecords(); //!< get a vector with DNSResourceRecords that are answers void setCompress(bool compress); DNSPacket *replyPacket() const; //!< convenience function that creates a virgin answer packet to this question void commitD(); //!< copies 'd' into the stringbuffer unsigned int getMaxReplyLen(); //!< retrieve the maximum length of the packet we should send in response void setMaxReplyLen(int bytes); //!< set the max reply len (used when retrieving from the packet cache, and this changed) bool couldBeCached(); //!< returns 0 if this query should bypass the packet cache bool hasEDNSSubnet(); bool hasEDNS(); //////// DATA ! ComboAddress d_remote; uint16_t qclass; //!< class of the question - should always be INternet 2 struct dnsheader d; //!< dnsheader at the start of the databuffer 12 QType qtype; //!< type of the question 8 string qdomain; //!< qname of the question 4 - unsure how this is used bool d_tcp; bool d_dnssecOk; bool d_havetsig; bool getTSIGDetails(TSIGRecordContent* tr, string* keyname, string* message) const; void setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly=false); vector& getRRS() { return d_rrs; } TSIGRecordContent d_trc; static bool s_doEDNSSubnetProcessing; private: void pasteQ(const char *question, int length); //!< set the question of this packet, useful for crafting replies bool d_wrapped; // 1 bool d_compress; // 1 uint16_t d_qlen; // length of the question (including class & type) in this packet 2 int d_socket; // 4 string d_rawpacket; // this is where everything lives 4 int d_maxreplylen; string d_ednsping; bool d_wantsnsid; bool d_haveednssubnet; bool d_haveednssection; EDNSSubnetOpts d_eso; string d_tsigsecret; string d_tsigkeyname; string d_tsigprevious; bool d_tsigtimersonly; vector d_rrs; // 4 }; bool checkForCorrectTSIG(const DNSPacket* q, DNSBackend* B, string* keyname, string* secret, TSIGRecordContent* trc); #endif pdns-3.3/pdns/session.hh0000644000014601777760000000647512155637744016565 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SESSION_HH #define SESSION_HH #include #include #ifndef WIN32 # include # include # include # include # include # include # include # include # include #endif // WIN32 #include "iputils.hh" #include "ahuexception.hh" class SessionException: public AhuException { public: SessionException(const string &reason) : AhuException(reason){} }; class SessionTimeoutException: public SessionException { public: SessionTimeoutException(const string &reason) : SessionException(reason){} }; //! The Session class represents a TCP/IP session, which can either be created or run on an existing socket class Session { public: bool getLine(string &); //!< Read a line from the remote bool haveLine(); //!< returns true if a line is available bool putLine(const string &s); //!< Write a line to the remote bool sendFile(int fd); //!< Send a file out int timeoutRead(int s,char *buf, size_t len); string get(unsigned int bytes); Session(int s, struct sockaddr_in r); //!< Start a session on an existing socket, and inform this class of the remotes name /** Create a session to a remote host and port. This function reads a timeout value from the ArgvMap class and does a nonblocking connect to support this timeout. It should be noted that nonblocking connects suffer from bad portability problems, so look here if you see weird problems on new platforms */ Session(const string &remote, int port, int timeout=0); Session(uint32_t ip, int port, int timeout=0); Session(const Session &s); ~Session(); int getSocket(); //!< return the filedescriptor for layering violations string getRemote(); uint32_t getRemoteAddr(); string getRemoteIP(); void beVerbose(); int close(); //!< close and disconnect the connection void setTimeout(unsigned int seconds); private: void doConnect(uint32_t ip, int port); bool d_verbose; char *rdbuf; int d_bufsize; int rdoffset; int wroffset; int clisock; struct sockaddr_in remote; void init(); int d_timeout; }; //! The server class can be used to create listening servers class Server { public: Server(int p, const string &localaddress=""); //!< port on which to listen Session* accept(); //!< Call accept() in an endless loop to accept new connections ComboAddress d_local; private: int s; int port; int backlog; }; class Exception { public: Exception(){reason="Unspecified";}; Exception(string r){reason=r;}; string reason; }; #endif /* SESSION_HH */ pdns-3.3/pdns/dnswasher.cc0000644000014601777760000000324112164306474017043 0ustar00jenkinsnogroup00000000000000/** two modes: anonymizing and stripping tcpdumps of irrelevant traffic, so operators can send non-privacy violating dumps for analysis. algorithm: read a packet, check if it has the recursion desired bit set. If the question has the response bit set, obfuscate the destination IP address otherwise, obfuscate the response IP address */ #include "statbag.hh" #include "dnspcap.hh" #include "namespaces.hh" #include "namespaces.hh" StatBag S; class IPObfuscator { public: IPObfuscator() : d_romap(d_ipmap), d_counter(0) { } uint32_t obf(uint32_t orig) { if(d_romap.count(orig)) return d_ipmap[orig]; else { return d_ipmap[orig]=d_counter++; } } private: map d_ipmap; const map& d_romap; uint32_t d_counter; }; int main(int argc, char** argv) try { if(argc!=3) { cerr<<"Syntax: dnswasher infile outfile\n"; exit(1); } PcapPacketReader pr(argv[1]); PcapPacketWriter pw(argv[2], pr); IPObfuscator ipo; while(pr.getUDPPacket()) { if(ntohs(pr.d_udp->uh_dport)==53 || (ntohs(pr.d_udp->uh_sport)==53 && pr.d_len > sizeof(dnsheader))) { dnsheader* dh=(dnsheader*)pr.d_payload; uint32_t *src=(uint32_t*)&pr.d_ip->ip_src; uint32_t *dst=(uint32_t*)&pr.d_ip->ip_dst; if(dh->qr) *dst=htonl(ipo.obf(*dst)); else *src=htonl(ipo.obf(*src)); pr.d_ip->ip_sum=0; pw.write(); } } cerr<<"Saw "< #include #include #include #include "lock.hh" #include "namespaces.hh" class StatRing { public: StatRing(unsigned int size=10000); ~StatRing(); void account(const string &item) { Lock l(d_lock); d_items[d_pos++ % d_size]=item; } unsigned int getSize() { return d_size; } void resize(unsigned int newsize); void reset(); void setHelp(const string &str); string getHelp(); vector >get() const; private: unsigned int d_size; unsigned int d_pos; vector d_items; pthread_mutex_t *d_lock; string d_help; }; //! use this to gather and query statistics class StatBag { map d_stats; map d_keyDescrips; mapd_rings; bool d_doRings; pthread_mutex_t d_lock; public: StatBag(); //!< Naked constructor. You need to declare keys before this class becomes useful ~StatBag(); void declare(const string &key, const string &descrip=""); //!< Before you can store or access a key, you need to declare it void declareRing(const string &name, const string &title, unsigned int size=10000); vector >getRing(const string &name); string getRingTitle(const string &name); void ringAccount(const string &name, const string &item) { if(d_doRings) d_rings[name].account(item); } void doRings() { d_doRings=true; } vectorlistRings(); void resetRing(const string &name); void resizeRing(const string &name, unsigned int newsize); unsigned int getRingSize(const string &name); string directory(); //!< Returns a list of all data stored vector getEntries(); //!< returns a vector with datums (items) string getDescrip(const string &item); //!< Returns the description of this datum/item void exists(const string &key); //!< call this function to throw an exception in case a key does not exist inline void deposit(const string &key, int value); //!< increment the statistics behind this key by value amount inline void inc(const string &key); //!< increase this key's value by one void set(const string &key, unsigned int value); //!< set this key's value unsigned int read(const string &key); //!< read the value behind this key unsigned int readZero(const string &key); //!< read the value behind this key, and zero it afterwards unsigned int *getPointer(const string &key); //!< get a direct pointer to the value behind a key. Use this for high performance increments string getValueStr(const string &key); //!< read a value behind a key, and return it as a string string getValueStrZero(const string &key); //!< read a value behind a key, and return it as a string, and zero afterwards private: void lock(){pthread_mutex_lock(&d_lock);} void unlock(){pthread_mutex_unlock(&d_lock);} }; inline void StatBag::deposit(const string &key, int value) { lock(); exists(key); *d_stats[key]+=value; unlock(); } inline void StatBag::inc(const string &key) { deposit(key,1); } #endif /* STATBAG_HH */ pdns-3.3/pdns/dnssec.schema.pgsql.sql0000644000014601777760000000217512136555572021133 0ustar00jenkinsnogroup00000000000000alter table records add ordername VARCHAR(255); alter table records add auth bool; create index recordorder on records (domain_id, ordername text_pattern_ops); create table domainmetadata ( id SERIAL PRIMARY KEY, domain_id INT REFERENCES domains(id) ON DELETE CASCADE, kind VARCHAR(16), content TEXT ); create index domainidmetaindex on domainmetadata(domain_id); create table cryptokeys ( id SERIAL PRIMARY KEY, domain_id INT REFERENCES domains(id) ON DELETE CASCADE, flags INT NOT NULL, active BOOL, content TEXT ); create index domainidindex on cryptokeys(domain_id); -- GRANT ALL ON domainmetadata TO pdns; -- GRANT ALL ON domainmetadata_id_seq TO pdns; -- GRANT ALL ON cryptokeys TO pdns; -- GRANT ALL ON cryptokeys_id_seq TO pdns; create table tsigkeys ( id SERIAL PRIMARY KEY, name VARCHAR(255), algorithm VARCHAR(50), secret VARCHAR(255) ); create unique index namealgoindex on tsigkeys(name, algorithm); -- GRANT ALL ON tsigkeys TO pdns; -- GRANT ALL ON tsigkeys_id_seq TO pdns; alter table records alter column type type VARCHAR(10); pdns-3.3/pdns/toysdig.cc0000644000014601777760000000470112136555572016535 0ustar00jenkinsnogroup00000000000000#include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "statbag.hh" #include "ednssubnet.hh" StatBag S; int main(int argc, char** argv) try { reportAllTypes(); if(argc < 4) { cerr<<"Syntax: sdig IP-address port question question-type\n"; exit(EXIT_FAILURE); } vector packet; DNSPacketWriter pw(packet, argv[3], DNSRecordContent::TypeToNumber(argv[4])); pw.getHeader()->rd=1; // void addOpt(int udpsize, int extRCode, int Z, const optvect_t& options=optvect_t()); DNSPacketWriter::optvect_t opts; EDNSSubnetOpts eso; eso.scope = eso.source = Netmask("2001:960:2:1e5::2"); string subnet = makeEDNSSubnetOptsString(eso); opts.push_back(make_pair(0x50fa, subnet)); pw.addOpt(1200, 0, 0, opts); // 1200 bytes answer size pw.commit(); Socket sock(InterNetwork, Datagram); ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); sock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), dest); string reply; sock.recvFrom(reply, dest); MOADNSParser mdp(reply); cout<<"Reply to question for qname='"<first.d_place-1<<"\t"<first.d_label<<"\tIN\t"<first.d_type); cout<<"\t"<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; } EDNSOpts edo; if(getEDNSOpts(mdp, &edo)) { cerr<<"Have "< >::const_iterator iter = edo.d_options.begin(); iter != edo.d_options.end(); ++iter) { if(iter->first == 0x50fa) { EDNSSubnetOpts eso; if(getEDNSSubnetOptsFromString(iter->second, &eso)) { cerr<<"Subnet options in reply: source "<first< #include #include #include #include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "statbag.hh" #include #include #include #include StatBag S; namespace po = boost::program_options; po::variables_map g_vm; bool g_verbose; bool g_onlyTCP; bool g_tcpNoDelay; unsigned int g_timeoutMsec; AtomicCounter g_networkErrors, g_otherErrors, g_OK, g_truncates, g_authAnswers, g_timeOuts; ComboAddress g_dest; unsigned int makeUsec(const struct timeval& tv) { return 1000000*tv.tv_sec + tv.tv_usec; } /* On Linux, run echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle to prevent running out of free TCP ports */ struct BenchQuery { BenchQuery(const std::string& qname_, uint16_t qtype_) : qname(qname_), qtype(qtype_), udpUsec(0), tcpUsec(0), answerSecond(0) {} BenchQuery(){} std::string qname; uint16_t qtype; uint32_t udpUsec, tcpUsec; time_t answerSecond; }; void doQuery(BenchQuery* q) try { vector packet; DNSPacketWriter pw(packet, q->qname, q->qtype); int res; string reply; struct timeval tv, now; gettimeofday(&tv, 0); if(!g_onlyTCP) { Socket udpsock((AddressFamily)g_dest.sin4.sin_family, Datagram); udpsock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), g_dest); ComboAddress origin; res = waitForData(udpsock.getHandle(), 0, 1000 * g_timeoutMsec); if(res < 0) throw NetworkError("Error waiting for response"); if(!res) { g_timeOuts++; return; } udpsock.recvFrom(reply, origin); gettimeofday(&now, 0); q->udpUsec = makeUsec(now - tv); tv=now; MOADNSParser mdp(reply); if(!mdp.d_header.tc) return; g_truncates++; } Socket sock((AddressFamily)g_dest.sin4.sin_family, Stream); int tmp=1; if(setsockopt(sock.getHandle(),SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) throw runtime_error("Unable to set socket reuse: "+string(strerror(errno))); if(g_tcpNoDelay && setsockopt(sock.getHandle(), IPPROTO_TCP, TCP_NODELAY,(char*)&tmp,sizeof tmp)<0) throw runtime_error("Unable to set socket no delay: "+string(strerror(errno))); sock.connect(g_dest); uint16_t len = htons(packet.size()); string tcppacket((char*)& len, 2); tcppacket.append((char*)&*packet.begin(), (char*)&*packet.end()); sock.writen(tcppacket); res = waitForData(sock.getHandle(), 0, 1000 * g_timeoutMsec); if(res < 0) throw NetworkError("Error waiting for response"); if(!res) { g_timeOuts++; return; } if(sock.read((char *) &len, 2) != 2) throw AhuException("tcp read failed"); len=ntohs(len); char *creply = new char[len]; int n=0; int numread; while(ntcpUsec = makeUsec(now - tv); q->answerSecond = now.tv_sec; MOADNSParser mdp(reply); // cout<<"Had correct TCP/IP response, "< g_queries; static void* worker(void*) { for(;;) { unsigned int pos = g_pos++; if(pos >= g_queries.size()) break; doQuery(&g_queries[pos]); // this is safe as long as nobody *inserts* to g_queries } return 0; } int main(int argc, char** argv) try { po::options_description desc("Allowed options"), hidden, alloptions; desc.add_options() ("help,h", "produce help message") ("verbose,v", "be verbose") ("udp-first,u", "try UDP first") ("file,f", po::value(), "source file - if not specified, defaults to stdin") ("tcp-no-delay", po::value()->default_value(true), "use TCP_NODELAY socket option") ("timeout-msec", po::value()->default_value(10), "wait for this amount of milliseconds for an answer") ("workers", po::value()->default_value(100), "number of parallel workers"); hidden.add_options() ("remote-host", po::value(), "remote-host") ("remote-port", po::value()->default_value(53), "remote-port"); alloptions.add(desc).add(hidden); po::positional_options_description p; p.add("remote-host", 1); p.add("remote-port", 1); po::store(po::command_line_parser(argc, argv).options(alloptions).positional(p).run(), g_vm); po::notify(g_vm); if(g_vm.count("help")) { cout << desc<(); g_onlyTCP = !g_vm.count("udp-first"); g_verbose = g_vm.count("verbose"); g_timeoutMsec = g_vm["timeout-msec"].as(); reportAllTypes(); if(g_vm["remote-host"].empty()) { cerr<<"Syntax: tcpbench remote [port] < queries"<().c_str(), g_vm["remote-port"].as()); unsigned int numworkers=g_vm["workers"].as(); if(g_verbose) { cout<<"Sending queries to: "<().c_str(), "r"); if(!fp) unixDie("Unable to open "+g_vm["file"].as()+" for input"); } pair q; string line; while(stringfgets(fp, line)) { trim_right(line); q=splitField(line, ' '); g_queries.push_back(BenchQuery(q.first, DNSRecordContent::TypeToNumber(q.second))); } fclose(fp); for(unsigned int n = 0; n < numworkers; ++n) { pthread_create(&workers[n], 0, worker, 0); } for(unsigned int n = 0; n < numworkers; ++n) { void* status; pthread_join(workers[n], &status); } using namespace boost::accumulators; typedef accumulator_set< unsigned int , stats > acc_t; acc_t udpspeeds, tcpspeeds, qps; typedef map counts_t; counts_t counts; BOOST_FOREACH(const BenchQuery& bq, g_queries) { counts[bq.answerSecond]++; udpspeeds(bq.udpUsec); tcpspeeds(bq.tcpUsec); } BOOST_FOREACH(const counts_t::value_type& val, counts) { qps(val.second); } cout<<"Average qps: "< #include #include #include "misc.hh" #include "iputils.hh" #ifndef WIN32 # include # include # include # include # include # include # include # include # undef res_mkquery #endif // WIN32 #include "ahuexception.hh" #include "dns.hh" #include "namespaces.hh" int asendto(const char *data, int len, int flags, const ComboAddress& ip, uint16_t id, const string& domain, uint16_t qtype, int* fd); int arecvfrom(char *data, int len, int flags, const ComboAddress& ip, int *d_len, uint16_t id, const string& domain, uint16_t, int fd, struct timeval* now); class LWResException : public AhuException { public: LWResException(const string &reason) : AhuException(reason){} }; //! LWRes class class LWResult { public: typedef vector res_t; vector d_result; int d_rcode; bool d_aabit, d_tcbit; uint32_t d_usec; bool d_pingCorrect; bool d_haveEDNS; }; int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, LWResult* res); #endif // PDNS_LWRES_HH pdns-3.3/pdns/ednssubnet.cc0000644000014601777760000000544112136555572017227 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2011 Netherlabs Computer Consulting BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "ednssubnet.hh" #include "dns.hh" namespace { struct EDNSSubnetOptsWire { uint16_t family; uint8_t sourceMask; uint8_t scopeMask; } GCCPACKATTRIBUTE; } bool getEDNSSubnetOptsFromString(const string& options, EDNSSubnetOpts* eso) { //cerr<<"options.size:"<> 3)+1; //cerr<<"octetsin:"< 4) return false; memset(&address, 0, sizeof(address)); address.sin4.sin_family = AF_INET; memcpy(&address.sin4.sin_addr.s_addr, options.c_str()+4, octetsin); } else if(esow.family == 2) { if(options.size() != 4+octetsin) return false; if(octetsin > 16) return false; memset(&address, 0, sizeof(address)); address.sin4.sin_family = AF_INET6; memcpy(&address.sin6.sin6_addr.s6_addr, options.c_str()+4, octetsin); } else return false; // cerr<<"Source address: "<source = Netmask(address, esow.sourceMask); eso->scope = Netmask(address, esow.scopeMask); return true; } string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso) { string ret; EDNSSubnetOptsWire esow; uint16_t family = htons(eso.source.getNetwork().sin4.sin_family == AF_INET ? 1 : 2); memcpy(&esow.family, &family, 2); esow.sourceMask = eso.source.getBits(); esow.scopeMask = eso.scope.getBits(); ret.assign((const char*)&esow, sizeof(esow)); int octetsout = ((esow.sourceMask - 1)>> 3)+1; if(family == htons(1)) ret.append((const char*) &eso.source.getNetwork().sin4.sin_addr.s_addr, octetsout); else ret.append((const char*) &eso.source.getNetwork().sin6.sin6_addr.s6_addr, octetsout); return ret; } pdns-3.3/pdns/testrunner.cc0000644000014601777760000000017012136555572017260 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE unit #include pdns-3.3/pdns/dynloader.cc0000644000014601777760000001053012136555572017031 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ahuexception.hh" #include "misc.hh" #include "dynmessenger.hh" #include "arguments.hh" #include "config.h" #include "statbag.hh" #include "misc.hh" #include "namespaces.hh" #include "namespaces.hh" ArgvMap &arg() { static ArgvMap arg; return arg; } StatBag S; int main(int argc, char **argv) { string s_programname="pdns"; string localdir; ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=SYSCONFDIR; ::arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR; ::arg().set("remote-address","Remote address to query"); ::arg().set("remote-port","Remote port to query")="53000"; ::arg().set("secret","Secret needed to connect to remote PowerDNS"); ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")=""; ::arg().setCmd("no-config","Don't parse configuration file"); ::arg().set("chroot","")=""; ::arg().setCmd("help","Provide a helpful message"); ::arg().laxParse(argc,argv); if(::arg().mustDo("help")) { cerr<<"syntax:"<commands=::arg().getCommands(); if(commands.empty()) { cerr<<"No command passed"< D; if(::arg()["remote-address"].empty()) D=shared_ptr(new DynMessenger(localdir,socketname)); else { uint16_t port; try { port = lexical_cast(::arg()["remote-port"]); } catch(...) { cerr<<"Unable to convert '"<<::arg()["remote-port"]<<"' to a port number for connecting to remote PowerDNS\n"; exit(99); } D=shared_ptr(new DynMessenger(ComboAddress(::arg()["remote-address"], port), ::arg()["secret"])); } string message; for(vector::const_iterator i=commands.begin();i!=commands.end();++i) { if(i!=commands.begin()) message+=" "; message+=*i; } if(command=="show") { message="SHOW "; for(unsigned int n=1;nsend(message)<0) { cerr<<"Error sending command"<receive(); cout< #include #include #include #include #include // deal with partial reads namespace { int readn(int fd, void* buffer, unsigned int len) { unsigned int pos=0; int res; for(;;) { res = read(fd, (char*)buffer + pos, len - pos); if(res == 0) { if(pos) throw runtime_error("Signing Pipe remote shut down in the middle of a message"); else { //cerr<<"Got decent EOF on "<worker(shs.d_id, shs.d_fd); return 0; } catch(std::exception& e) { L<()); // load an empty chunk if(!d_mustSign) return; int fds[2]; for(unsigned int n=0; n < d_numworkers; ++n) { if(socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) throw runtime_error("Unable to create communication socket in for ChunkedSigningPipe"); Utility::setCloseOnExec(fds[0]); Utility::setCloseOnExec(fds[1]); pthread_create(&d_tids[n], 0, helperWorker, (void*) new StartHelperStruct(this, n, fds[1])); Utility::setNonBlocking(fds[0]); d_sockets.push_back(fds[0]); } } ChunkedSigningPipe::~ChunkedSigningPipe() { delete d_rrsetToSign; if(!d_mustSign) return; BOOST_FOREACH(int fd, d_sockets) { close(fd); // this will trigger all threads to exit } void* res; BOOST_FOREACH(pthread_t& tid, d_tids) { pthread_join(tid, &res); } //cout<<"Did: "<begin(), d_rrsetToSign->end(), dedupLessThan); d_rrsetToSign->erase(unique(d_rrsetToSign->begin(), d_rrsetToSign->end(), dedupEqual), d_rrsetToSign->end()); } bool ChunkedSigningPipe::submit(const DNSResourceRecord& rr) { ++d_submitted; // check if we have a full RRSET to sign if(!d_rrsetToSign->empty() && (d_rrsetToSign->begin()->qtype.getCode() != rr.qtype.getCode() || !pdns_iequals(d_rrsetToSign->begin()->qname, rr.qname))) { dedupRRSet(); sendRRSetToWorker(); } d_rrsetToSign->push_back(rr); return !d_chunks.empty() && d_chunks.front().size() >= d_maxchunkrecords; // "you can send more" } pair, vector > ChunkedSigningPipe::waitForRW(bool rd, bool wr, int seconds) { vector pfds; for(unsigned int n = 0; n < d_sockets.size(); ++n) { if(d_eof.count(d_sockets[n])) continue; struct pollfd pfd; memset(&pfd, 0, sizeof(pfd)); pfd.fd = d_sockets[n]; if(rd) pfd.events |= POLLIN; if(wr) pfd.events |= POLLOUT; pfds.push_back(pfd); } int res = poll(&pfds[0], pfds.size(), (seconds < 0) ? -1 : (seconds * 1000)); // -1 = infinite if(res < 0) unixDie("polling for activity from signers, "+lexical_cast(d_sockets.size())); pair, vector > vects; for(unsigned int n = 0; n < pfds.size(); ++n) if(pfds[n].revents & POLLIN) vects.first.push_back(pfds[n].fd); else if(pfds[n].revents & POLLOUT) vects.second.push_back(pfds[n].fd); return vects; } void ChunkedSigningPipe::addSignedToChunks(chunk_t* signedChunk) { chunk_t::const_iterator from = signedChunk->begin(); while(from != signedChunk->end()) { chunk_t& fillChunk = d_chunks.back(); chunk_t::size_type room = d_maxchunkrecords - fillChunk.size(); unsigned int fit = std::min(room, (chunk_t::size_type)(signedChunk->end() - from)); d_chunks.back().insert(fillChunk.end(), from , from + fit); from+=fit; if(from != signedChunk->end()) // it didn't fit, so add a new chunk d_chunks.push_back(chunk_t()); } } void ChunkedSigningPipe::sendRRSetToWorker() // it sounds so socialist! { if(!d_mustSign) { addSignedToChunks(d_rrsetToSign); d_rrsetToSign->clear(); return; } if(d_final && !d_outstanding) // nothing to do! return; bool wantRead, wantWrite; wantWrite = !d_rrsetToSign->empty(); wantRead = d_outstanding || wantWrite; // if we wrote, we want to read pair, vector > rwVect; rwVect = waitForRW(wantRead, wantWrite, -1); // wait for something to happen if(wantWrite && !rwVect.second.empty()) { random_shuffle(rwVect.second.begin(), rwVect.second.end()); // pick random available worker writen2(*rwVect.second.begin(), &d_rrsetToSign, sizeof(d_rrsetToSign)); d_rrsetToSign = new rrset_t; d_outstanding++; d_queued++; wantWrite=false; } if(wantRead) { while(d_outstanding) { chunk_t* chunk; BOOST_FOREACH(int fd, rwVect.first) { if(d_eof.count(fd)) continue; while(d_outstanding) { int res = readn(fd, &chunk, sizeof(chunk)); if(!res) { d_eof.insert(fd); break; } if(res < 0) { if(errno != EAGAIN && errno != EINTR) unixDie("Error reading signed chunk from thread"); else break; } --d_outstanding; addSignedToChunks(chunk); delete chunk; } } if(!d_outstanding || !d_final) break; rwVect = waitForRW(1, 0, -1); // wait for something to happen } } if(wantWrite) { // our optimization above failed, we now wait synchronously rwVect = waitForRW(0, wantWrite, -1); // wait for something to happen random_shuffle(rwVect.second.begin(), rwVect.second.end()); // pick random available worker writen2(*rwVect.second.begin(), &d_rrsetToSign, sizeof(d_rrsetToSign)); d_rrsetToSign = new rrset_t; d_outstanding++; d_queued++; } } unsigned int ChunkedSigningPipe::getReady() { unsigned int sum=0; BOOST_FOREACH(const std::vector& v, d_chunks) { sum += v.size(); } return sum; } void ChunkedSigningPipe::worker(int id, int fd) try { DNSSECKeeper dk; UeberBackend db("key-only"); chunk_t* chunk; int res; for(;;) { res = readn(fd, &chunk, sizeof(chunk)); if(!res) break; if(res < 0) unixDie("reading object pointer to sign from pdns"); set authSet; authSet.insert(d_signer); addRRSigs(dk, db, authSet, *chunk); ++d_signed; writen2(fd, &chunk, sizeof(chunk)); } close(fd); } catch(std::exception& e) { L<clear(); } vector ChunkedSigningPipe::getChunk(bool final) { if(final && !d_final) { // this means we should keep on reading until d_outstanding == 0 d_final = true; flushToSign(); BOOST_FOREACH(int fd, d_sockets) { shutdown(fd, SHUT_WR); // perhaps this transmits EOF the other side //cerr<<"shutdown of "< front=d_chunks.front(); d_chunks.pop_front(); if(d_chunks.empty()) d_chunks.push_back(vector()); if(d_final && front.empty()) ; // cerr<<"getChunk returning empty in final"< buf(new char[len]); readn(fd, buf.get(), len); msg.assign(buf.get(), len); return true; } void writeLStringToSocket(int fd, const string& msg) { string realmsg; uint32_t len = htonl(msg.length()); string tot((char*)&len, 4); tot+=msg; writen2(fd, tot.c_str(), tot.length()); } #endif pdns-3.3/pdns/common_startup.hh0000644000014601777760000000326012151077203020121 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef COMMON_STARTUP_HH #define COMMON_STARTUP_HH #include "packetcache.hh" #include "utility.hh" #include "arguments.hh" #include "communicator.hh" #include "distributor.hh" #include "dnspacket.hh" #include "dnsproxy.hh" #include "dynlistener.hh" #include "nameserver.hh" #include "statbag.hh" #include "tcpreceiver.hh" #include "webserver.hh" #include "ws.hh" extern ArgvMap theArg; extern StatBag S; //!< Statistics are gathered across PDNS via the StatBag class S extern PacketCache PC; //!< This is the main PacketCache, shared accross all threads extern DNSProxy *DP; extern DynListener *dl; extern CommunicatorClass Communicator; extern UDPNameserver *N; extern int avg_latency; extern TCPNameserver *TN; extern ArgvMap & arg( void ); extern void declareArguments(); extern void declareStats(); extern void mainthread(); extern int isGuarded( char ** ); extern bool g_anyToTcp; extern bool g_addSuperfluousNSEC3; #endif // COMMON_STARTUP_HH pdns-3.3/pdns/dnsbulktest.cc0000644000014601777760000002350512165455411017411 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include "inflighter.cc" #include #include "namespaces.hh" #include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" using namespace boost::accumulators; namespace po = boost::program_options; po::variables_map g_vm; StatBag S; bool g_quiet=false; bool g_envoutput=false; struct DNSResult { vector ips; int rcode; bool seenauthsoa; }; struct TypedQuery { TypedQuery(const string& name_, uint16_t type_) : name(name_), type(type_){} string name; uint16_t type; }; struct SendReceive { typedef int Identifier; typedef DNSResult Answer; // ip int d_socket; deque d_idqueue; typedef accumulator_set< double , stats > acc_t; acc_t* d_acc; boost::array d_probs; SendReceive(const std::string& remoteAddr, uint16_t port) { boost::array tmp ={{0.001,0.01, 0.025, 0.1, 0.25,0.5,0.75,0.9,0.975, 0.99,0.9999}}; d_probs = tmp; d_acc = new acc_t(boost::accumulators::tag::extended_p_square::probabilities=d_probs); // //d_acc = acc_t d_socket = socket(AF_INET, SOCK_DGRAM, 0); int val=1; setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); ComboAddress remote(remoteAddr, port); connect(d_socket, (struct sockaddr*)&remote, remote.getSocklen()); d_oks = d_errors = d_nodatas = d_nxdomains = d_unknowns = 0; d_receiveds = d_receiveerrors = d_senderrors = 0; for(unsigned int id =0 ; id < std::numeric_limits::max(); ++id) d_idqueue.push_back(id); } ~SendReceive() { close(d_socket); } Identifier send(TypedQuery& domain) { //cerr<<"Sending query for '"< packet; DNSPacketWriter pw(packet, domain.name, domain.type); if(d_idqueue.empty()) { cerr<<"Exhausted ids!"<id = d_idqueue.front(); d_idqueue.pop_front(); pw.getHeader()->rd = 1; pw.getHeader()->qr = 0; if(::send(d_socket, &*packet.begin(), packet.size(), 0) < 0) d_senderrors++; return pw.getHeader()->id; } bool receive(Identifier& id, DNSResult& dr) { if(waitForData(d_socket, 0, 500000) > 0) { char buf[512]; int len = recv(d_socket, buf, sizeof(buf), 0); if(len < 0) { d_receiveerrors++; return 0; } else { d_receiveds++; } // parse packet, set 'id', fill out 'ip' MOADNSParser mdp(string(buf, len)); if(!g_quiet) { cout<<"Reply to question for qname='"<first.d_place == 1 && i->first.d_type == mdp.d_qtype) dr.ips.push_back(ComboAddress(i->first.d_content->getZoneRepresentation())); if(i->first.d_place == 2 && i->first.d_type == QType::SOA) { dr.seenauthsoa = 1; } if(!g_quiet) { cout<first.d_place-1<<"\t"<first.d_label<<"\tIN\t"<first.d_type); cout<<"\t"<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; } } id = mdp.d_header.id; d_idqueue.push_back(id); return 1; } return 0; } void deliverTimeout(const Identifier& id) { d_idqueue.push_back(id); } void deliverAnswer(TypedQuery& domain, const DNSResult& dr, unsigned int usec) { (*d_acc)(usec/1000.0); // if(usec > 1000000) // cerr<<"Slow: "<()->default_value("A"), "What type to query for") ("envoutput,e", "write report in shell environment format") ; po::options_description alloptions; po::options_description hidden("hidden options"); hidden.add_options() ("ip-address", po::value(), "ip-address") ("portnumber", po::value(), "portnumber") ("limit", po::value()->default_value(0), "limit"); alloptions.add(desc).add(hidden); po::positional_options_description p; p.add("ip-address", 1); p.add("portnumber", 1); p.add("limit", 1); po::store(po::command_line_parser(argc, argv).options(alloptions).positional(p).run(), g_vm); po::notify(g_vm); if (g_vm.count("help")) { cerr << "Usage: dnsbulktest [--options] ip-address portnumber [limit]"< 0; g_envoutput = g_vm.count("envoutput") > 0; uint16_t qtype; reportAllTypes(); try { qtype = DNSRecordContent::TypeToNumber(g_vm["type"].as()); } catch(std::exception& e) { cerr << e.what() << endl; return EXIT_FAILURE; } SendReceive sr(g_vm["ip-address"].as(), g_vm["portnumber"].as()); unsigned int limit = g_vm["limit"].as(); vector domains; Inflighter, SendReceive> inflighter(domains, sr); inflighter.d_maxInFlight = 100; inflighter.d_timeoutSeconds = 3; string line; pair split; string::size_type pos; while(stringfgets(stdin, line)) { if(limit && domains.size() >= limit) break; trim_right(line); split=splitField(line,','); pos=split.second.find('/'); if(pos != string::npos) // alexa has whole urls in the list now.. split.second.resize(pos); if(find_if(split.second.begin(), split.second.end(), isalpha) == split.second.end()) { continue; // this was an IP address } domains.push_back(TypedQuery(split.second, qtype)); domains.push_back(TypedQuery("www."+split.second, qtype)); } cerr<<"Read "< #include #include "namespaces.hh" #include #include "iputils.hh" #include "rec_channel.hh" #include "arguments.hh" #include "misc.hh" #include "syncres.hh" #include "config.h" JWebserver::JWebserver(FDMultiplexer* fdm) : d_fdm(fdm) { RecursorControlParser rcp; // inits d_socket = socket(AF_INET6, SOCK_STREAM, 0); setSocketReusable(d_socket); ComboAddress local("::", 8082); bind(d_socket, (struct sockaddr*)&local, local.getSocklen()); listen(d_socket, 5); d_fdm->addReadFD(d_socket, boost::bind(&JWebserver::newConnection, this)); } void JWebserver::readRequest(int fd) { char buffer[16384]; int res = read(fd, buffer, sizeof(buffer)); if(res <= 0) { d_fdm->removeReadFD(fd); close(fd); cerr<<"Lost connection"<removeReadFD(fd); close(fd); cerr<<"Invalid request"< varmap; if((p = strchr(buffer, '?'))) { vector variables; string line(p+1); line.resize(line.length() - strlen(" HTTP/1.0")); stringtok(variables, line, "&"); BOOST_FOREACH(const string& var, variables) { varmap.insert(splitField(var, '=')); cout<<"Variable: '"< stats; if(varmap["command"] =="domains") { content += "["; bool first=1; BOOST_FOREACH(const SyncRes::domainmap_t::value_type& val, *t_sstorage->domainmap) { if(!first) content+= ", "; first=false; stats.clear(); stats["name"] = val.first; stats["type"] = val.second.d_servers.empty() ? "Native" : "Forwarded"; stats["servers"]; BOOST_FOREACH(const ComboAddress& server, val.second.d_servers) { stats["servers"]+= server.toStringWithPort() + " "; } stats["rdbit"] = lexical_cast(val.second.d_servers.empty() ? 0 : val.second.d_rdForward); // fill out forwarders too one day, and rdrequired content += returnJSONObject(stats); } content += "]"; } else if(varmap["command"]=="flush-cache") { string canon=toCanonic("", varmap["domain"]); cerr<<"Canon: '"<(boost::bind(pleaseWipeCache, canon)); count+=broadcastAccFunction(boost::bind(pleaseWipeAndCountNegCache, canon)); stats["number"]=lexical_cast(count); content += returnJSONObject(stats); } else if(varmap["command"] == "config") { vector items = ::arg().list(); BOOST_FOREACH(const string& var, items) { stats[var] = ::arg()[var]; } content += returnJSONObject(stats); } else if(varmap["command"]=="log-grep") { content += makeLogGrepJSON(varmap, ::arg()["experimental-logfile"], " pdns_recursor["); } else { // if(varmap["command"] == "stats") { stats = getAllStatsMap(); content += returnJSONObject(stats); } if(!callback.empty()) content += ");"; string tot = (boost::format(response) % content.length()).str(); tot += content; cout << "Starting write"<addReadFD(sock, boost::bind(&JWebserver::readRequest, this, _1)); } pdns-3.3/pdns/namespaces.hh0000644000014601777760000000260012136555572017200 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_NAMESPACES_HH #define PDNS_NAMESPACES_HH #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::vector; using std::map; using std::pair; using std::make_pair; using std::runtime_error; using std::ostringstream; using std::set; using std::deque; using std::cerr; using std::cout; using std::clog; using std::endl; using std::ifstream; using std::ofstream; using std::ostream; using std::min; // these are a bit scary, everybody uses 'min' using std::max; namespace pdns { typedef std::string string; }; typedef pdns::string string; using boost::lexical_cast; using boost::tie; using boost::shared_ptr; using boost::shared_array; using boost::scoped_array; using boost::tuple; using boost::format; using boost::make_tuple; using boost::optional; using boost::any_cast; using boost::any; using boost::function; using boost::trim; using boost::trim_left; using boost::trim_right; using boost::is_any_of; using boost::trim_right_copy_if; using boost::equals; using boost::ends_with; using boost::iends_with; #endif pdns-3.3/pdns/dynhandler.cc0000644000014601777760000001423012136555572017201 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include "dynhandler.hh" #include "statbag.hh" #include "logger.hh" #include "dns.hh" #include "arguments.hh" #include #include "misc.hh" #include "communicator.hh" #include "dnsseckeeper.hh" static bool s_pleasequit; bool DLQuitPlease() { return s_pleasequit; } string DLQuitHandler(const vector&parts, Utility::pid_t ppid) { string ret="No return value"; if(parts[0]=="QUIT") { s_pleasequit=true; ret="Scheduling exit"; L<&parts, Utility::pid_t ppid) { #ifndef WIN32 signal(SIGALRM, dokill); alarm(1); #else if ( !PDNSService::instance()->isRunningAsService()) GenerateConsoleCtrlEvent( CTRL_C_EVENT, 0 ); else PDNSService::instance()->stop(); #endif // WIN32 return "Exiting"; } string DLPingHandler(const vector&parts, Utility::pid_t ppid) { return "PONG"; } string DLShowHandler(const vector&parts, Utility::pid_t ppid) { extern StatBag S; string ret("Wrong number of parameters"); if(parts.size()==2) { if(parts[1]=="*") ret=S.directory(); else ret=S.getValueStr(parts[1]); } return ret; } static string d_status; void setStatus(const string &str) { d_status=str; } string DLStatusHandler(const vector&parts, Utility::pid_t ppid) { ostringstream os; os<&parts, Utility::pid_t ppid) { ostringstream os; os<&parts, Utility::pid_t ppid) { extern PacketCache PC; DNSSECKeeper dk; ostringstream os; int ret=0; if(parts.size()>1) { for (vector::const_iterator i=++parts.begin();i&parts, Utility::pid_t ppid) { extern PacketCache PC; map counts=PC.getCounts(); ostringstream os; bool first=true; for(map::const_iterator i=counts.begin();i!=counts.end();++i) { if(!first) os<<", "; first=false; if(i->first=='!') os<<"negative queries: "; else if(i->first=='Q') os<<"queries: "; else if(i->first=='n') os<<"non-recursive packets: "; else if(i->first=='r') os<<"recursive packets: "; else os<<"unknown: "; os<second; } return os.str(); } string DLSettingsHandler(const vector&parts, Utility::pid_t ppid) { static const char *whitelist[]={"query-logging",0}; const char **p; if(parts.size()!=3) { return "Syntax: set variable value"; } for(p=whitelist;*p;p++) if(*p==parts[1]) break; if(*p) { ::arg().set(parts[1])=parts[2]; return "done"; } else return "This setting cannot be changed at runtime, or no such setting"; } string DLVersionHandler(const vector&parts, Utility::pid_t ppid) { return VERSION; } string DLNotifyRetrieveHandler(const vector&parts, Utility::pid_t ppid) { extern CommunicatorClass Communicator; ostringstream os; if(parts.size()!=2) return "syntax: retrieve domain"; const string& domain=parts[1]; DomainInfo di; PacketHandler P; if(!P.getBackend()->getDomainInfo(domain, di)) return "Domain '"+domain+"' unknown"; if(di.masters.empty()) return "Domain '"+domain+"' is not a slave domain (or has no master defined)"; random_shuffle(di.masters.begin(), di.masters.end()); Communicator.addSuckRequest(domain, di.masters.front()); return "Added retrieval request for '"+domain+"' from master "+di.masters.front(); } string DLNotifyHostHandler(const vector&parts, Utility::pid_t ppid) { extern CommunicatorClass Communicator; ostringstream os; if(parts.size()!=3) return "syntax: notify-host domain ip"; if(!::arg().mustDo("master")) return "PowerDNS not configured as master"; try { ComboAddress ca(parts[2]); } catch(...) { return "Unable to convert '"+parts[2]+"' to an IP address"; } L<&parts, Utility::pid_t ppid) { extern CommunicatorClass Communicator; ostringstream os; if(parts.size()!=2) return "syntax: notify domain"; if(!::arg().mustDo("master")) return "PowerDNS not configured as master"; L<&parts, Utility::pid_t ppid) { PacketHandler P; try { L<rediscover(&status); return status; } catch(AhuException &ae) { return ae.reason; } } string DLReloadHandler(const vector&parts, Utility::pid_t ppid) { PacketHandler P; P.getBackend()->reload(); L< #include #include #include #include "dns.hh" #include #include "namespaces.hh" using namespace ::boost::multi_index; #include "namespaces.hh" #include "dnspacket.hh" #include "lock.hh" #include "statbag.hh" /** This class performs 'whole packet caching'. Feed it a question packet and it will try to find an answer. If you have an answer, insert it to have it cached for later use. Take care not to replace existing cache entries. While this works, it is wasteful. Only insert packets that where not found by get() Locking! The cache itself is protected by a read/write lock. Because deleting is a two step process, which first marks and then sweeps, a second lock is present to prevent simultaneous inserts and deletes. */ struct CIBackwardsStringCompare: public std::binary_function { bool operator()(const string& str_a, const string& str_b) const { string::const_reverse_iterator ra, rb; char a=0, b=0; for(ra = str_a.rbegin(), rb = str_b.rbegin(); ra < str_a.rend() && rb < str_b.rend() && (a=dns_tolower(*ra)) == (b=dns_tolower(*rb)); ra++, rb++); if (ra < str_a.rend() && rb==str_b.rend()) { a=*(ra++); b=0; return false; } // we are at the beginning of b -> b smaller if (rb < str_b.rend() && ra==str_a.rend()) { b=*(rb++); a=0; return true; } // we are at the beginning of a -> a smaller // if BOTH are at their ends, a and b will be equal, and we should return false, which we will return a < b; } }; class PacketCache : public boost::noncopyable { public: PacketCache(); ~PacketCache(); enum CacheEntryType { PACKETCACHE, QUERYCACHE}; void insert(DNSPacket *q, DNSPacket *r, unsigned int maxttl=UINT_MAX); //!< We copy the contents of *p into our cache. Do not needlessly call this to insert questions already in the cache as it wastes resources void insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID=-1, bool meritsRecursion=false, unsigned int maxReplyLen=512, bool dnssecOk=false, bool EDNS=false); int get(DNSPacket *p, DNSPacket *q); //!< We return a dynamically allocated copy out of our cache. You need to delete it. You also need to spoof in the right ID with the DNSPacket.spoofID() method. bool getEntry(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, bool meritsRecursion=false, unsigned int maxReplyLen=512, bool dnssecOk=false, bool hasEDNS=false); int size(); //!< number of entries in the cache void cleanup(); //!< force the cache to preen itself from expired packets int purge(); int purge(const string &match); map getCounts(); private: bool getEntryLocked(const string &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1, bool meritsRecursion=false, unsigned int maxReplyLen=512, bool dnssecOk=false, bool hasEDNS=false); struct CacheEntry { CacheEntry() { qtype = ctype = 0; zoneID = -1; meritsRecursion=false; dnssecOk=false; hasEDNS=false;} string qname; uint16_t qtype; uint16_t ctype; int zoneID; time_t ttd; bool meritsRecursion; unsigned int maxReplyLen; bool dnssecOk; bool hasEDNS; string value; }; void getTTLS(); typedef multi_index_container< CacheEntry, indexed_by < ordered_unique< composite_key< CacheEntry, member, member, member, member, member, member, member, member >, composite_key_compare, std::less, std::less, std::less, std::less, std::less, std::less > >, sequenced<> > > cmap_t; cmap_t d_map; pthread_rwlock_t d_mut; AtomicCounter d_ops; int d_ttl; int d_recursivettl; bool d_doRecursion; unsigned int *d_statnumhit; unsigned int *d_statnummiss; unsigned int *d_statnumentries; }; #endif /* PACKETCACHE_HH */ pdns-3.3/pdns/test-md5_hh.cc0000644000014601777760000000174212150646616017172 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include #include #include "md5.hh" #include "misc.hh" using namespace boost; BOOST_AUTO_TEST_SUITE(test_md5_hh) BOOST_AUTO_TEST_CASE(test_md5summer) { std::string result = "a3 24 8c e3 1a 88 a6 40 e6 30 73 98 57 6d 06 9e "; std::vector cases = boost::assign::list_of ("a ") ("quick ") ("brown ") ("fox ") ("jumped ") ("over ") ("the ") ("lazy ") ("dog"); MD5Summer s; BOOST_FOREACH(std::string item, cases) { s.feed(item); } BOOST_CHECK_EQUAL(makeHexDump(s.get()), result); } BOOST_AUTO_TEST_CASE(test_pdns_md5sum) { std::string result = "a3 24 8c e3 1a 88 a6 40 e6 30 73 98 57 6d 06 9e "; std::string sum = pdns_md5sum("a quick brown fox jumped over the lazy dog"); BOOST_CHECK_EQUAL(makeHexDump(sum), result); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/webserver.hh0000644000014601777760000000305412136555572017071 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef WEBSERVER_HH #define WEBSERVER_HH #include #include #include "namespaces.hh" class Server; class WebServer { public: WebServer(const string &listenaddress, int port, const string &password=""); void go(); static void* serveConnection(void *); void setCaller(void *that); typedef string HandlerFunction(const string& method, const string& post, const map&varmap, void *that, bool *custom); void registerHandler(const string &, HandlerFunction *ptr); private: static char B64Decode1(char cInChar); static int B64Decode(const std::string& strInput, std::string& strOutput); string d_listenaddress; int d_port; static mapd_functions; static void *d_that; static string d_password; Server* d_server; }; #endif /* WEBSERVER_HH */ pdns-3.3/pdns/precursor.in0000755000014601777760000000167612136555572017133 0ustar00jenkinsnogroup00000000000000#!/bin/sh # chkconfig: - 80 75 # description: pdns_recursor is a versatile high performance recursing nameserver prefix=@prefix@ exec_prefix=@exec_prefix@ BINARYPATH=@bindir@ SBINARYPATH=@sbindir@ SOCKETPATH=@socketdir@ PIDFILE=@socketdir@/pdns_recursor.pid if [ -s $PIDFILE -a -d /proc/$(cat $PIDFILE) 2>/dev/null ] then RUNNING=1 PID=$(cat $PIDFILE) else RUNNING=0 fi case "$1" in status) if [ $RUNNING = "1" ] then echo pdns_recursor is running else echo pdns_recursor is not running fi ;; stop) echo -n "Stopping PowerDNS recursor: " if [ $RUNNING = "1" ] then kill -9 $PID echo stopped else echo not running fi ;; start) echo -n "Starting PowerDNS recursor: " if [ $RUNNING = "1" ] then echo already running else $SBINARYPATH/pdns_recursor --daemon > /dev/null 2> /dev/null echo started fi ;; restart) $0 stop $0 start ;; *) echo unknown instruction \'$1\' ;; esac pdns-3.3/pdns/dnsscope.cc0000644000014601777760000001364712136555572016702 0ustar00jenkinsnogroup00000000000000#define __FAVOR_BSD #include "statbag.hh" #include "dnspcap.hh" #include "dnsparser.hh" #include #include #include #include #include #include #include "anadns.hh" #include "namespaces.hh" #include "namespaces.hh" StatBag S; struct QuestionData { QuestionData() : d_qcount(0), d_answercount(0) { d_firstquestiontime.tv_sec=0; } int d_qcount; int d_answercount; struct pdns_timeval d_firstquestiontime; }; typedef map statmap_t; statmap_t statmap; int main(int argc, char** argv) try { if(argc!=2) { cerr<<"Syntax: dnsscope filename.pcap"< cumul_t; cumul_t cumul; unsigned int untracked=0, errorresult=0, reallylate=0; typedef map rcodes_t; rcodes_t rcodes; time_t lowestTime=2000000000, highestTime=0; while(pr.getUDPPacket()) { if((ntohs(pr.d_udp->uh_dport)==5300 || ntohs(pr.d_udp->uh_sport)==5300 || ntohs(pr.d_udp->uh_dport)==53 || ntohs(pr.d_udp->uh_sport)==53) && pr.d_len > 12) { try { MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); lowestTime=min((time_t)lowestTime, (time_t)pr.d_pheader.ts.tv_sec); highestTime=max((time_t)highestTime, (time_t)pr.d_pheader.ts.tv_sec); string name=mdp.d_qname+"|"+DNSRecordContent::NumberToType(mdp.d_qtype); QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp); if(!mdp.d_header.qr) { // cout<<"Question for '"<< name <<"'\n"; QuestionData& qd=statmap[qi]; if(!qd.d_firstquestiontime.tv_sec) qd.d_firstquestiontime=pr.d_pheader.ts; qd.d_qcount++; } else { // NO ERROR or NXDOMAIN QuestionData& qd=statmap[qi]; if(!qd.d_qcount) untracked++; qd.d_answercount++; // cout<<"Answer to '"<< name <<"': RCODE="<<(int)mdp.d_rcode<<", "<write(); dnserrors++; continue; } catch(std::exception& e) { if(pw) pw->write(); bogus++; continue; } } } cerr<<"Timespan: "<<(highestTime-lowestTime)/3600.0<<" hours"<second.d_answercount) { unanswered++; // cout << i->first.d_qname <<" " <first.d_qtype<first<<"\t"<second<first<<"\t"<<(sum+=i->second)<<"\n"; totpackets+=i->second; tottime+=i->first*i->second; } typedef map done_t; done_t done; done[50]; done[100]; done[200]; done[250]; done[300]; done[350]; done[400]; done[800]; done[1000]; done[2000]; done[4000]; done[8000]; done[16000]; done[32000]; done[64000]; done[128000]; done[256000]; done[512000]; done[1024000]; done[2048000]; cout.setf(std::ios::fixed); cout.precision(2); sum=0; double lastperc=0, perc=0; for(cumul_t::const_iterator i=cumul.begin(); i!=cumul.end(); ++i) { sum+=i->second; for(done_t::iterator j=done.begin(); j!=done.end(); ++j) if(!j->second && i->first > j->first) { j->second=true; perc=sum*100.0/totpackets; if(j->first < 1024) cout<< perc <<"% of questions answered within " << j->first << " usec ("; else cout<< perc <<"% of questions answered within " << j->first/1000.0 << " msec ("; cout< #include #include #include "namespaces.hh" #include "namespaces.hh" #define includeboilerplate(RNAME) RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr); \ RNAME##RecordContent(const string& zoneData); \ static void report(void); \ static void unreport(void); \ static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); \ static DNSRecordContent* make(const string& zonedata); \ string getZoneRepresentation() const; \ void toPacket(DNSPacketWriter& pw); \ template void xfrPacket(Convertor& conv); class NAPTRRecordContent : public DNSRecordContent { public: NAPTRRecordContent(uint16_t order, uint16_t preference, string flags, string services, string regexp, string replacement); includeboilerplate(NAPTR); template void xfrRecordContent(Convertor& conv); private: uint16_t d_order, d_preference; string d_flags, d_services, d_regexp, d_replacement; }; class ARecordContent : public DNSRecordContent { public: explicit ARecordContent(uint32_t ip); includeboilerplate(A); void doRecordCheck(const DNSRecord& dr); uint32_t getIP() const; private: uint32_t d_ip; }; class AAAARecordContent : public DNSRecordContent { public: AAAARecordContent(std::string &val); includeboilerplate(AAAA); private: std::string d_ip6; }; class MXRecordContent : public DNSRecordContent { public: MXRecordContent(uint16_t preference, const string& mxname); includeboilerplate(MX) private: uint16_t d_preference; string d_mxname; }; class KXRecordContent : public DNSRecordContent { public: KXRecordContent(uint16_t preference, const string& exchanger); includeboilerplate(KX) private: uint16_t d_preference; string d_exchanger; }; class IPSECKEYRecordContent : public DNSRecordContent { public: IPSECKEYRecordContent(uint16_t preference, uint8_t gatewaytype, uint8_t algo, const std::string& gateway, const std::string &publickey); includeboilerplate(IPSECKEY) private: uint8_t d_preference, d_gatewaytype, d_algorithm; string d_gateway, d_publickey; uint32_t d_ip4; string d_ip6; }; class DHCIDRecordContent : public DNSRecordContent { public: includeboilerplate(DHCID) private: string d_content; }; class SRVRecordContent : public DNSRecordContent { public: SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target); includeboilerplate(SRV) private: uint16_t d_preference, d_weight, d_port; string d_target; }; class TSIGRecordContent : public DNSRecordContent { public: includeboilerplate(TSIG) TSIGRecordContent() : DNSRecordContent(QType::TSIG) {} string d_algoName; uint64_t d_time; // 48 bits uint16_t d_fudge; // uint16_t d_macSize; string d_mac; uint16_t d_origID; uint16_t d_eRcode; // uint16_t d_otherLen string d_otherData; }; class TXTRecordContent : public DNSRecordContent { public: includeboilerplate(TXT) private: string d_text; }; class SPFRecordContent : public DNSRecordContent { public: includeboilerplate(SPF) private: string d_text; }; class NSRecordContent : public DNSRecordContent { public: includeboilerplate(NS) private: string d_content; }; class PTRRecordContent : public DNSRecordContent { public: includeboilerplate(PTR) private: string d_content; }; class CNAMERecordContent : public DNSRecordContent { public: includeboilerplate(CNAME) private: string d_content; }; class MRRecordContent : public DNSRecordContent { public: includeboilerplate(MR) private: string d_alias; }; class MINFORecordContent : public DNSRecordContent { public: includeboilerplate(MINFO) private: string d_rmailbx; string d_emailbx; }; class OPTRecordContent : public DNSRecordContent { public: includeboilerplate(OPT) void getData(vector > &opts); private: string d_data; }; class HINFORecordContent : public DNSRecordContent { public: includeboilerplate(HINFO) private: string d_cpu, d_host; }; class RPRecordContent : public DNSRecordContent { public: includeboilerplate(RP) private: string d_mbox, d_info; }; class DNSKEYRecordContent : public DNSRecordContent { public: DNSKEYRecordContent(); includeboilerplate(DNSKEY) uint16_t getTag(); uint16_t d_flags; uint8_t d_protocol; uint8_t d_algorithm; string d_key; }; class DSRecordContent : public DNSRecordContent { public: DSRecordContent(); includeboilerplate(DS) uint16_t d_tag; uint8_t d_algorithm, d_digesttype; string d_digest; }; class DLVRecordContent : public DNSRecordContent { public: DLVRecordContent(); includeboilerplate(DLV) uint16_t d_tag; uint8_t d_algorithm, d_digesttype; string d_digest; }; class SSHFPRecordContent : public DNSRecordContent { public: includeboilerplate(SSHFP) private: uint8_t d_algorithm, d_fptype; string d_fingerprint; }; class KEYRecordContent : public DNSRecordContent { public: includeboilerplate(KEY) private: uint16_t d_flags; uint8_t d_protocol, d_algorithm; string d_certificate; }; class AFSDBRecordContent : public DNSRecordContent { public: includeboilerplate(AFSDB) private: uint16_t d_subtype; string d_hostname; }; class CERTRecordContent : public DNSRecordContent { public: includeboilerplate(CERT) private: uint16_t d_type, d_tag; uint8_t d_algorithm; string d_certificate; }; class TLSARecordContent : public DNSRecordContent { public: includeboilerplate(TLSA) private: uint8_t d_certusage, d_selector, d_matchtype; string d_cert; }; class RRSIGRecordContent : public DNSRecordContent { public: RRSIGRecordContent(); includeboilerplate(RRSIG) uint16_t d_type; uint8_t d_algorithm, d_labels; uint32_t d_originalttl, d_sigexpire, d_siginception; uint16_t d_tag; string d_signer, d_signature; }; //namespace { struct soatimes { uint32_t serial; uint32_t refresh; uint32_t retry; uint32_t expire; uint32_t minimum; }; //} class RKEYRecordContent : public DNSRecordContent { public: RKEYRecordContent(); includeboilerplate(RKEY) uint16_t d_flags; uint8_t d_protocol, d_algorithm; string d_key; }; class SOARecordContent : public DNSRecordContent { public: includeboilerplate(SOA) SOARecordContent(const string& mname, const string& rname, const struct soatimes& st); string d_mname; string d_rname; struct soatimes d_st; }; class NSECRecordContent : public DNSRecordContent { public: static void report(void); NSECRecordContent() : DNSRecordContent(47) {} NSECRecordContent(const string& content, const string& zone=""); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& content); string getZoneRepresentation() const; void toPacket(DNSPacketWriter& pw); string d_next; std::set d_set; private: }; class NSEC3RecordContent : public DNSRecordContent { public: static void report(void); NSEC3RecordContent() : DNSRecordContent(50) {} NSEC3RecordContent(const string& content, const string& zone=""); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& content); string getZoneRepresentation() const; void toPacket(DNSPacketWriter& pw); uint8_t d_algorithm, d_flags; uint16_t d_iterations; uint8_t d_saltlength; string d_salt; uint8_t d_nexthashlength; string d_nexthash; std::set d_set; private: }; class NSEC3PARAMRecordContent : public DNSRecordContent { public: static void report(void); NSEC3PARAMRecordContent() : DNSRecordContent(51) {} NSEC3PARAMRecordContent(const string& content, const string& zone=""); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& content); string getZoneRepresentation() const; void toPacket(DNSPacketWriter& pw); uint8_t d_algorithm, d_flags; uint16_t d_iterations; uint8_t d_saltlength; string d_salt; }; class LOCRecordContent : public DNSRecordContent { public: static void report(void); LOCRecordContent() : DNSRecordContent(ns_t_loc) {} LOCRecordContent(const string& content, const string& zone=""); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& content); string getZoneRepresentation() const; void toPacket(DNSPacketWriter& pw); uint8_t d_version, d_size, d_horizpre, d_vertpre; uint32_t d_latitude, d_longitude, d_altitude; private: }; class WKSRecordContent : public DNSRecordContent { public: static void report(void); WKSRecordContent() : DNSRecordContent(ns_t_wks) {} WKSRecordContent(const string& content, const string& zone=""); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& content); string getZoneRepresentation() const; void toPacket(DNSPacketWriter& pw); uint32_t d_ip; std::bitset<65535> d_services; private: }; class URLRecordContent : public DNSRecordContent // Fake, 'fancy record' with type 256 { public: includeboilerplate(URL) private: string d_url; }; class MBOXFWRecordContent : public DNSRecordContent // Fake, 'fancy record' with type 256 { public: includeboilerplate(MBOXFW) private: string d_mboxfw; }; class EUI48RecordContent : public DNSRecordContent { public: EUI48RecordContent() : DNSRecordContent(ns_t_eui48) {}; static void report(void); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& zone); void toPacket(DNSPacketWriter& pw); string getZoneRepresentation() const; private: // storage for the bytes uint8_t d_eui48[6]; }; class EUI64RecordContent : public DNSRecordContent { public: EUI64RecordContent() : DNSRecordContent(ns_t_eui64) {}; static void report(void); static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr); static DNSRecordContent* make(const string& zone); void toPacket(DNSPacketWriter& pw); string getZoneRepresentation() const; private: // storage for the bytes uint8_t d_eui64[8]; }; #define boilerplate(RNAME, RTYPE) \ RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \ { \ return new RNAME##RecordContent(dr, pr); \ } \ \ RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr) : DNSRecordContent(RTYPE) \ { \ doRecordCheck(dr); \ xfrPacket(pr); \ } \ \ RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const string& zonedata) \ { \ return new RNAME##RecordContent(zonedata); \ } \ \ void RNAME##RecordContent::toPacket(DNSPacketWriter& pw) \ { \ this->xfrPacket(pw); \ } \ \ void RNAME##RecordContent::report(void) \ { \ regist(1, RTYPE, &RNAME##RecordContent::make, &RNAME##RecordContent::make, #RNAME); \ } \ void RNAME##RecordContent::unreport(void) \ { \ unregist(1, RTYPE); \ } \ \ RNAME##RecordContent::RNAME##RecordContent(const string& zoneData) : DNSRecordContent(RTYPE) \ { \ try { \ RecordTextReader rtr(zoneData); \ xfrPacket(rtr); \ } \ catch(RecordTextException& rtr) { \ throw MOADNSException("Parsing record content: "+string(rtr.what())); \ } \ } \ \ string RNAME##RecordContent::getZoneRepresentation() const \ { \ string ret; \ RecordTextWriter rtw(ret); \ const_cast(this)->xfrPacket(rtw); \ return ret; \ } #define boilerplate_conv(RNAME, TYPE, CONV) \ boilerplate(RNAME, TYPE) \ template \ void RNAME##RecordContent::xfrPacket(Convertor& conv) \ { \ CONV; \ } \ struct EDNSOpts { uint16_t d_packetsize; uint8_t d_extRCode, d_version; uint16_t d_Z; vector > d_options; enum zFlags { DNSSECOK=32768 }; }; //! Convenience function that fills out EDNS0 options, and returns true if there are any class MOADNSParser; bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo); void reportBasicTypes(); void reportOtherTypes(); void reportAllTypes(); void reportFancyTypes(); #endif pdns-3.3/pdns/base64.hh0000644000014601777760000000032112136555572016143 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_BASE64_HH #define PDNS_BASE64_HH #include #include int B64Decode(const std::string& strInput, std::string& strOutput); std::string Base64Encode (const std::string& vby); #endif pdns-3.3/pdns/dnsseckeeper.hh0000644000014601777760000001203112145416060017517 0ustar00jenkinsnogroup00000000000000#ifndef PDNSDNSSECKEEPER_HH #define PDNSDNSSECKEEPER_HH /* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include "dnssecinfra.hh" #include "dnsrecords.hh" #include "ueberbackend.hh" using namespace ::boost::multi_index; class DNSSECKeeper : public boost::noncopyable { public: struct KeyMetaData { unsigned int id; bool active; bool keyOrZone; string fname; }; typedef std::pair keymeta_t; typedef std::vector keyset_t; private: UeberBackend* d_keymetadb; bool d_ourDB; public: DNSSECKeeper() : d_keymetadb( new UeberBackend("key-only")), d_ourDB(true) { } DNSSECKeeper(UeberBackend* db) : d_keymetadb(db), d_ourDB(false) { } ~DNSSECKeeper() { if(d_ourDB) delete d_keymetadb; } bool isSecuredZone(const std::string& zone); keyset_t getKeys(const std::string& zone, boost::tribool allOrKeyOrZone = boost::indeterminate); DNSSECPrivateKey getKeyById(const std::string& zone, unsigned int id); bool addKey(const std::string& zname, bool keyOrZone, int algorithm=5, int bits=0, bool active=true); bool addKey(const std::string& zname, const DNSSECPrivateKey& dpk, bool active=true); bool removeKey(const std::string& zname, unsigned int id); bool activateKey(const std::string& zname, unsigned int id); bool deactivateKey(const std::string& zname, unsigned int id); bool secureZone(const std::string& fname, int algorithm, int size); bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* n3p=0, bool* narrow=0); bool setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false); bool unsetNSEC3PARAM(const std::string& zname); void clearAllCaches(); void clearCaches(const std::string& name); bool getPreRRSIGs(DNSBackend& db, const std::string& signer, const std::string& qname, const std::string& wildcardname, const QType& qtype, DNSPacketWriter::Place, vector& rrsigs, uint32_t signTTL); bool isPresigned(const std::string& zname); bool setPresigned(const std::string& zname); bool unsetPresigned(const std::string& zname); bool TSIGGrantsAccess(const string& zone, const string& keyname, const string& algorithm); bool getTSIGForAccess(const string& zone, const string& master, string* keyname); void startTransaction() { (*d_keymetadb->backends.begin())->startTransaction("", -1); } void commitTransaction() { (*d_keymetadb->backends.begin())->commitTransaction(); } void getFromMeta(const std::string& zname, const std::string& key, std::string& value); private: struct KeyCacheEntry { typedef vector keys_t; uint32_t getTTD() const { return d_ttd; } string d_domain; unsigned int d_ttd; mutable keys_t d_keys; }; struct METACacheEntry { uint32_t getTTD() const { return d_ttd; } string d_domain; unsigned int d_ttd; mutable std::string d_key, d_value; }; typedef multi_index_container< KeyCacheEntry, indexed_by< ordered_unique, CIStringCompare >, sequenced<> > > keycache_t; typedef multi_index_container< METACacheEntry, indexed_by< ordered_unique< composite_key< METACacheEntry, member , member >, composite_key_compare >, sequenced<> > > metacache_t; void cleanup(); static keycache_t s_keycache; static metacache_t s_metacache; static pthread_rwlock_t s_metacachelock; static pthread_rwlock_t s_keycachelock; static AtomicCounter s_ops; static time_t s_last_prune; }; class DNSPacket; uint32_t localtime_format_YYYYMMDDSS(time_t t, uint32_t seq); bool editSOA(DNSSECKeeper& dk, const string& qname, DNSPacket* dp); uint32_t calculateEditSoa(SOAData sd, const string& kind); #endif pdns-3.3/pdns/dnsparser.cc0000644000014601777760000004300212156064043017037 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dnsparser.hh" #include "dnswriter.hh" #include #include #include #include "namespaces.hh" class UnknownRecordContent : public DNSRecordContent { public: UnknownRecordContent(const DNSRecord& dr, PacketReader& pr) : DNSRecordContent(dr.d_type), d_dr(dr) { pr.copyRecord(d_record, dr.d_clen); } UnknownRecordContent(const string& zone) : DNSRecordContent(0) { d_record.insert(d_record.end(), zone.begin(), zone.end()); } string getZoneRepresentation() const { ostringstream str; str<<"\\# "<<(unsigned int)d_record.size()<<" "; char hex[4]; for(size_t n=0; n parts; stringtok(parts, tmp); if(parts.size()!=3 && !(parts.size()==2 && equals(parts[1],"0")) ) throw MOADNSException("Unknown record was stored incorrectly, need 3 fields, got "+lexical_cast(parts.size())+": "+tmp ); const string& relevant=(parts.size() > 2) ? parts[2] : ""; unsigned int total=atoi(parts[1].c_str()); if(relevant.size()!=2*total) throw MOADNSException((boost::format("invalid unknown record length for label %s: size not equal to length field (%d != %d)") % d_dr.d_label.c_str() % relevant.size() % (2*total)).str()); string out; out.reserve(total+1); for(unsigned int n=0; n < total; ++n) { int c; sscanf(relevant.c_str()+2*n, "%02x", &c); out.append(1, (char)c); } pw.xfrBlob(out); } private: DNSRecord d_dr; vector d_record; }; static const string EncodeDNSLabel(const string& input) { if(input.length() == 1 && input[0]=='.') // otherwise we encode .. (long story) return string (1, 0); labelparts_t parts; bool unescapedSomething = labeltokUnescape(parts, input); string ret; if(!unescapedSomething) { for(labelparts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { ret.append(1, i->second - i->first); ret.append(input.c_str() + i->first, i->second - i->first); } } else { for(labelparts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { string part(input.c_str() + i->first, i->second - i->first); boost::replace_all(part, "\\\\", "\\"); boost::replace_all(part, "\\.", "."); ret.append(1, part.length()); ret.append(part); } } ret.append(1, 0); return ret; } shared_ptr DNSRecordContent::unserialize(const string& qname, uint16_t qtype, const string& serialized) { dnsheader dnsheader; memset(&dnsheader, 0, sizeof(dnsheader)); dnsheader.qdcount=htons(1); dnsheader.ancount=htons(1); vector packet; // build pseudo packet /* will look like: dnsheader, 5 bytes, encoded qname, dns record header, serialized data */ string encoded=EncodeDNSLabel(qname); packet.resize(sizeof(dnsheader) + 5 + encoded.size() + sizeof(struct dnsrecordheader) + serialized.size()); uint16_t pos=0; memcpy(&packet[0], &dnsheader, sizeof(dnsheader)); pos+=sizeof(dnsheader); char tmp[6]="\x0" "\x0\x1" "\x0\x1"; // root question for ns_t_a memcpy(&packet[pos], &tmp, 5); pos+=5; memcpy(&packet[pos], encoded.c_str(), encoded.size()); pos+=(uint16_t)encoded.size(); struct dnsrecordheader drh; drh.d_type=htons(qtype); drh.d_class=htons(1); drh.d_ttl=0; drh.d_clen=htons(serialized.size()); memcpy(&packet[pos], &drh, sizeof(drh)); pos+=sizeof(drh); memcpy(&packet[pos], serialized.c_str(), serialized.size()); pos+=(uint16_t)serialized.size(); MOADNSParser mdp((char*)&*packet.begin(), (unsigned int)packet.size()); shared_ptr ret= mdp.d_answers.begin()->first.d_content; ret->header.d_type=ret->d_qtype; ret->label=mdp.d_answers.begin()->first.d_label; ret->header.d_ttl=mdp.d_answers.begin()->first.d_ttl; return ret; } DNSRecordContent* DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr) { uint16_t searchclass = (dr.d_type == QType::OPT) ? 1 : dr.d_class; // class is invalid for OPT typemap_t::const_iterator i=getTypemap().find(make_pair(searchclass, dr.d_type)); if(i==getTypemap().end() || !i->second) { return new UnknownRecordContent(dr, pr); } return i->second(dr, pr); } DNSRecordContent* DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass, const string& content) { zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype)); if(i==getZmakermap().end()) { return new UnknownRecordContent(content); } return i->second(content); } DNSRecordContent::typemap_t& DNSRecordContent::getTypemap() { static DNSRecordContent::typemap_t typemap; return typemap; } DNSRecordContent::n2typemap_t& DNSRecordContent::getN2Typemap() { static DNSRecordContent::n2typemap_t n2typemap; return n2typemap; } DNSRecordContent::t2namemap_t& DNSRecordContent::getT2Namemap() { static DNSRecordContent::t2namemap_t t2namemap; return t2namemap; } DNSRecordContent::zmakermap_t& DNSRecordContent::getZmakermap() { static DNSRecordContent::zmakermap_t zmakermap; return zmakermap; } void MOADNSParser::init(const char *packet, unsigned int len) { if(len < sizeof(dnsheader)) throw MOADNSException("Packet shorter than minimal header"); memcpy(&d_header, packet, sizeof(dnsheader)); if(d_header.opcode!=0 && d_header.opcode != 4) // notification throw MOADNSException("Can't parse non-query packet with opcode="+ lexical_cast(d_header.opcode)); d_header.qdcount=ntohs(d_header.qdcount); d_header.ancount=ntohs(d_header.ancount); d_header.nscount=ntohs(d_header.nscount); d_header.arcount=ntohs(d_header.arcount); uint16_t contentlen=len-sizeof(dnsheader); d_content.resize(contentlen); copy(packet+sizeof(dnsheader), packet+len, d_content.begin()); unsigned int n=0; PacketReader pr(d_content); bool validPacket=false; try { d_qtype = d_qclass = 0; // sometimes replies come in with no question, don't present garbage then for(n=0;n < d_header.qdcount; ++n) { d_qname=pr.getLabel(); d_qtype=pr.get16BitInt(); d_qclass=pr.get16BitInt(); } struct dnsrecordheader ah; vector record; validPacket=true; for(n=0;n < (unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount); ++n) { DNSRecord dr; if(n < d_header.ancount) dr.d_place=DNSRecord::Answer; else if(n < d_header.ancount + d_header.nscount) dr.d_place=DNSRecord::Nameserver; else dr.d_place=DNSRecord::Additional; unsigned int recordStartPos=pr.d_pos; string label=pr.getLabel(); pr.getDnsrecordheader(ah); dr.d_ttl=ah.d_ttl; dr.d_type=ah.d_type; dr.d_class=ah.d_class; dr.d_label=label; dr.d_clen=ah.d_clen; dr.d_content=boost::shared_ptr(DNSRecordContent::mastermake(dr, pr)); d_answers.push_back(make_pair(dr, pr.d_pos)); if(dr.d_type == QType::TSIG && dr.d_class == 0xff) d_tsigPos = recordStartPos + sizeof(struct dnsheader); } #if 0 if(pr.d_pos!=contentlen) { throw MOADNSException("Packet ("+d_qname+"|#"+lexical_cast(d_qtype)+") has trailing garbage ("+ lexical_cast(pr.d_pos) + " < " + lexical_cast(contentlen) + ")"); } #endif } catch(std::out_of_range &re) { if(validPacket && d_header.tc) { // don't sweat it over truncated packets, but do adjust an, ns and arcount if(n < d_header.ancount) { d_header.ancount=n; d_header.nscount = d_header.arcount = 0; } else if(n < d_header.ancount + d_header.nscount) { d_header.nscount = n - d_header.ancount; d_header.arcount=0; } else { d_header.arcount = n - d_header.ancount - d_header.nscount; } } else { throw MOADNSException("Error parsing packet of "+lexical_cast(len)+" bytes (rd="+ lexical_cast(d_header.rd)+ "), out of bounds: "+string(re.what())); } } } void PacketReader::getDnsrecordheader(struct dnsrecordheader &ah) { unsigned int n; unsigned char *p=reinterpret_cast(&ah); for(n=0; n < sizeof(dnsrecordheader); ++n) p[n]=d_content.at(d_pos++); ah.d_type=ntohs(ah.d_type); ah.d_class=ntohs(ah.d_class); ah.d_clen=ntohs(ah.d_clen); ah.d_ttl=ntohl(ah.d_ttl); d_startrecordpos=d_pos; // needed for getBlob later on d_recordlen=ah.d_clen; } void PacketReader::copyRecord(vector& dest, uint16_t len) { dest.resize(len); if(!len) return; for(uint16_t n=0;n d_content.size()) throw std::out_of_range("Attempt to copy outside of packet"); memcpy(dest, &d_content.at(d_pos), len); d_pos+=len; } void PacketReader::xfr48BitInt(uint64_t& ret) { ret=0; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); } uint32_t PacketReader::get32BitInt() { uint32_t ret=0; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); ret<<=8; ret+=d_content.at(d_pos++); return ret; } uint16_t PacketReader::get16BitInt() { return get16BitInt(d_content, d_pos); } uint16_t PacketReader::get16BitInt(const vector&content, uint16_t& pos) { uint16_t ret=0; ret+=content.at(pos++); ret<<=8; ret+=content.at(pos++); return ret; } uint8_t PacketReader::get8BitInt() { return d_content.at(d_pos++); } string PacketReader::getLabel(unsigned int recurs) { string ret; ret.reserve(40); getLabelFromContent(d_content, d_pos, ret, recurs++); return ret; } static string txtEscape(const string &name) { string ret; char ebuf[5]; for(string::const_iterator i=name.begin();i!=name.end();++i) { if((unsigned char) *i > 127 || (unsigned char) *i < 32) { snprintf(ebuf, sizeof(ebuf), "\\%03u", (unsigned char)*i); ret += ebuf; } else if(*i=='"' || *i=='\\'){ ret += '\\'; ret += *i; } else ret += *i; } return ret; } // exceptions thrown here do not result in logging in the main pdns auth server - just so you know! string PacketReader::getText(bool multi) { string ret; ret.reserve(40); while(d_pos < d_startrecordpos + d_recordlen ) { if(!ret.empty()) { ret.append(1,' '); } unsigned char labellen=d_content.at(d_pos++); ret.append(1,'"'); if(labellen) { // no need to do anything for an empty string string val(&d_content.at(d_pos), &d_content.at(d_pos+labellen-1)+1); ret.append(txtEscape(val)); // the end is one beyond the packet } ret.append(1,'"'); d_pos+=labellen; if(!multi) break; } return ret; } void PacketReader::getLabelFromContent(const vector& content, uint16_t& frompos, string& ret, int recurs) { if(recurs > 1000) // the forward reference-check below should make this test 100% obsolete throw MOADNSException("Loop"); for(;;) { unsigned char labellen=content.at(frompos++); if(!labellen) { if(ret.empty()) ret.append(1,'.'); break; } if((labellen & 0xc0) == 0xc0) { uint16_t offset=256*(labellen & ~0xc0) + (unsigned int)content.at(frompos++) - sizeof(dnsheader); // cout<<"This is an offset, need to go to: "<= frompos-2) throw MOADNSException("forward reference during label decompression"); return getLabelFromContent(content, offset, ret, ++recurs); } else { // XXX FIXME THIS MIGHT BE VERY SLOW! ret.reserve(ret.size() + labellen + 2); for(string::size_type n = 0 ; n < labellen; ++n, frompos++) { if(content.at(frompos)=='.' || content.at(frompos)=='\\') { ret.append(1, '\\'); ret.append(1, content[frompos]); } else if(content.at(frompos)==' ') { ret+="\\032"; } else ret.append(1, content[frompos]); } ret.append(1,'.'); } } } void PacketReader::xfrBlob(string& blob) { if(d_recordlen && !(d_pos == (d_startrecordpos + d_recordlen))) blob.assign(&d_content.at(d_pos), &d_content.at(d_startrecordpos + d_recordlen - 1 ) + 1); else blob.clear(); d_pos = d_startrecordpos + d_recordlen; } void PacketReader::xfrBlob(string& blob, int length) { if(length) { blob.assign(&d_content.at(d_pos), &d_content.at(d_pos + length - 1 ) + 1 ); d_pos += length; } else blob.clear(); } void PacketReader::xfrHexBlob(string& blob, bool keepReading) { xfrBlob(blob); } string simpleCompress(const string& elabel, const string& root) { string label=elabel; // FIXME: this relies on the semi-canonical escaped output from getLabelFromContent boost::replace_all(label, "\\.", "."); boost::replace_all(label, "\\032", " "); boost::replace_all(label, "\\\\", "\\"); typedef vector > parts_t; parts_t parts; vstringtok(parts, label, "."); string ret; ret.reserve(label.size()+4); for(parts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { if(!root.empty() && !strncasecmp(root.c_str(), label.c_str() + i->first, 1 + label.length() - i->first)) { // also match trailing 0, hence '1 +' const unsigned char rootptr[2]={0xc0,0x11}; ret.append((const char *) rootptr, 2); return ret; } ret.append(1, (char)(i->second - i->first)); ret.append(label.c_str() + i->first, i->second - i->first); } ret.append(1, (char)0); return ret; } void simpleExpandTo(const string& label, unsigned int frompos, string& ret) { unsigned int labellen=0; while((labellen=label.at(frompos++))) { ret.append(label.c_str()+frompos, labellen); ret.append(1,'.'); frompos+=labellen; } } /** Simple DNSPacketMangler. Ritual is: get a pointer into the packet and moveOffset() to beyond your needs * If you survive that, feel free to read from the pointer */ class DNSPacketMangler { public: explicit DNSPacketMangler(std::string& packet) : d_packet(packet), d_notyouroffset(12), d_offset(d_notyouroffset) {} void skipLabel() { uint8_t len; while((len=get8BitInt())) { if(len >= 0xc0) { // extended label get8BitInt(); return; } skipBytes(len); } } void skipBytes(uint16_t bytes) { moveOffset(bytes); } uint16_t get16BitInt() { const char* p = d_packet.c_str() + d_offset; moveOffset(2); uint16_t ret; memcpy(&ret, (void*)p, 2); return ntohs(ret); } uint8_t get8BitInt() { const char* p = d_packet.c_str() + d_offset; moveOffset(1); return *p; } void skipRData() { int toskip = get16BitInt(); moveOffset(toskip); } void decreaseAndSkip32BitInt(uint32_t decrease) { const char *p = (const char*)d_packet.c_str() + d_offset; moveOffset(4); uint32_t tmp; memcpy(&tmp, (void*) p, sizeof(tmp)); tmp = ntohl(tmp); tmp-=decrease; tmp = htonl(tmp); d_packet.replace(d_offset-4, sizeof(tmp), (const char*)&tmp, sizeof(tmp)); } private: void moveOffset(uint16_t by) { d_notyouroffset += by; if(d_notyouroffset > d_packet.length()) throw std::out_of_range("dns packet out of range: "+lexical_cast(d_notyouroffset) +" > " + lexical_cast(d_packet.length()) ); } std::string& d_packet; uint32_t d_notyouroffset; // only 'moveOffset' can touch this const uint32_t& d_offset; // look.. but don't touch }; // method of operation: silently fail if it doesn't work - we're only trying to be nice, don't fall over on it void ageDNSPacket(std::string& packet, uint32_t seconds) { if(packet.length() < sizeof(dnsheader)) return; try { dnsheader dh; memcpy((void*)&dh, (const dnsheader*)packet.c_str(), sizeof(dh)); int numrecords = ntohs(dh.ancount) + ntohs(dh.nscount) + ntohs(dh.arcount); DNSPacketMangler dpm(packet); int n; for(n=0; n < ntohs(dh.qdcount) ; ++n) { dpm.skipLabel(); dpm.skipBytes(4); // qtype, qclass } // cerr<<"Skipped "< #include "logger.hh" #include #include "dns.hh" #include "base64.hh" mapWebServer::d_functions; void *WebServer::d_that; string WebServer::d_password; int WebServer::B64Decode(const std::string& strInput, std::string& strOutput) { return ::B64Decode(strInput, strOutput); } void WebServer::registerHandler(const string&s, HandlerFunction *ptr) { d_functions[s]=ptr; } void WebServer::setCaller(void *that) { d_that=that; } void *WebServer::serveConnection(void *p) { pthread_detach(pthread_self()); Session *client=static_cast(p); try { string line; client->setTimeout(5); client->getLine(line); stripLine(line); if(line.empty()) throw Exception("Invalid web request"); // L<<"page: "< parts; stringtok(parts,line); string method, uri; if(parts.size()>1) { method=parts[0]; uri=parts[1]; } vectorvariables; parts.clear(); stringtok(parts,uri,"?"); // L<<"baseUrl: '"<urlParts; stringtok(urlParts,parts[0],"/"); string baseUrl; if(urlParts.empty()) baseUrl=""; else baseUrl=urlParts[0]; // L<<"baseUrl real: '"<1) { stringtok(variables,parts[1],"&"); } mapvarmap; for(vector::const_iterator i=variables.begin(); i!=variables.end();++i) { parts.clear(); stringtok(parts,*i,"="); if(parts.size()>1) varmap[parts[0]]=parts[1]; else varmap[parts[0]]=""; } bool authOK=0; int postlen = 0; // read & ignore other lines do { client->getLine(line); stripLine(line); // L<cparts; stringtok(cparts,plain,":"); // L<get(postlen); // cout<<"Post: '"<putLine("HTTP/1.1 401 OK\n"); client->putLine("WWW-Authenticate: Basic realm=\"PowerDNS\"\n"); client->putLine("Connection: close\n"); client->putLine("Content-type: text/html; charset=UTF-8\n\n"); client->putLine("Please enter a valid password!\n"); client->close(); delete client; return 0; } HandlerFunction *fptr; if(d_functions.count(baseUrl) && (fptr=d_functions[baseUrl])) { bool custom=false; string ret=(*fptr)(method, post, varmap, d_that, &custom); if(!custom) { client->putLine("HTTP/1.1 200 OK\n"); client->putLine("Connection: close\n"); client->putLine("Content-type: text/html; charset=UTF-8\n\n"); } client->putLine(ret); } else { client->putLine("HTTP/1.1 404 Not found\n"); client->putLine("Connection: close\n"); client->putLine("Content-type: text/html; charset=UTF-8\n\n"); // FIXME: CSS problem? client->putLine("

Did not find file '"+baseUrl+"'\n"); } client->close(); delete client; client=0; return 0; } catch(SessionTimeoutException &e) { // L<close(); delete client; client=0; } return 0; } WebServer::WebServer(const string &listenaddress, int port, const string &password) { d_listenaddress=listenaddress; d_port=port; d_password=password; d_server = 0; // on exception, this class becomes a NOOP later on try { d_server = new Server(d_port, d_listenaddress); } catch(SessionException &e) { L<d_local.toStringWithPort() <accept())) { pthread_create(&tid, 0 , &serveConnection, (void *)client); } } catch(SessionTimeoutException &e) { // L< # include # include # include # include # include # include # include #endif // WIN32 #include #include #include "statbag.hh" #include "namespaces.hh" #include "dnspacket.hh" /** This is the main class. It opens a socket on udp port 53 and waits for packets. Those packets can be retrieved with the receive() member function, which returns a DNSPacket. Some sample code in main(): \code typedef Distributor DNSDistributor; DNSDistributor D(6); // the big dispatcher! pthread_t qtid, atid; N=new UDPNameserver; pthread_create(&qtid,0,qthread,static_cast(&D)); // receives packets pthread_create(&atid,0,athread,static_cast(&D)); // sends packets \endcode Code for qthread: \code void *qthread(void *p) { DNSDistributor *D=static_cast(p); DNSPacket *P; while((P=N->receive())) // receive a packet { D->question(P); // and give to the distributor, they will delete it } return 0; } \endcode */ class UDPNameserver { public: UDPNameserver(); //!< Opens the socket DNSPacket *receive(DNSPacket *prefilled=0); //!< call this in a while or for(;;) loop to get packets static void send(DNSPacket *); //!< send a DNSPacket. Will call DNSPacket::truncate() if over 512 bytes private: vector d_sockets; void bindIPv4(); void bindIPv6(); vector d_rfds; }; bool AddressIsUs(const ComboAddress& remote); #endif pdns-3.3/pdns/distributor.hh0000644000014601777760000002407112136555572017441 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DISTRIBUTOR_HH #define DISTRIBUTOR_HH #include #include #include #include #include #include #ifndef WIN32 # include #endif // WIN32 #include "logger.hh" #include "dns.hh" #include "dnsbackend.hh" #include "ahuexception.hh" #include "arguments.hh" #include "statbag.hh" extern StatBag S; /** the Distributor template class enables you to multithread slow question/answer processes. Questions are posed to the Distributor, which can either hand back the answer, or give it directly to a callback. Only the latter mode of operation is used in PowerDNS. The Distributor takes care that there are enough Backends alive at any one time and will try to spawn additional ones should they die. The Backend needs to count the number of living instances and supply this number to the Distributor using its numBackends() method. This is silly. If an exception escapes a Backend, the distributor retires it. */ template class Distributor { public: Distributor(int n=10); //!< Create a new Distributor with \param n threads struct AnswerData { Answer *A; time_t created; }; int question(Question *, void (*)(const AnswerData &)=0); //!< Submit a question to the Distributor Answer *answer(void); //!< Wait for any answer from the Distributor Answer *wait(Question *); //!< wait for an answer to a specific question int timeoutWait(int id, Answer *, int); //!< wait for a specific answer, with timeout static void* makeThread(void *); //!< helper function to create our n threads void getQueueSizes(int &questions, int &answers); //!< Returns length of question queue int getNumBusy() { return d_num_threads-d_idle_threads; } struct QuestionData { Question *Q; void (*callback)(const AnswerData &); int id; }; typedef pair tuple_t; bool isOverloaded() { return d_overloaded; } private: bool d_overloaded; std::queue questions; pthread_mutex_t q_lock; deque answers; pthread_mutex_t a_lock; Semaphore numquestions; Semaphore numanswers; pthread_mutex_t to_mut; pthread_cond_t to_cond; int nextid; time_t d_last_started; int d_num_threads; AtomicCounter d_idle_threads; Backend *b; }; //template::nextid; templateDistributor::Distributor(int n) { b=0; d_overloaded = false; nextid=0; // d_idle_threads=0; d_last_started=time(0); // sem_init(&numquestions,0,0); pthread_mutex_init(&q_lock,0); // sem_init(&numanswers,0,0); pthread_mutex_init(&a_lock,0); pthread_mutex_init(&to_mut,0); pthread_cond_init(&to_cond,0); pthread_t tid; d_num_threads=n; L<(this)); Utility::usleep(50000); // we've overloaded mysql in the past :-) } L<void *Distributor::makeThread(void *p) { pthread_detach(pthread_self()); try { Backend *b=new Backend(); // this will answer our questions Distributor *us=static_cast(p); int qcount; // this is so gross #ifndef SMTPREDIR int queuetimeout=::arg().asNum("queue-limit"); #endif // ick ick ick! static int overloadQueueLength=::arg().asNum("overload-queue-length"); for(;;) { ++(us->d_idle_threads); us->numquestions.getValue( &qcount ); us->numquestions.wait(); --(us->d_idle_threads); pthread_mutex_lock(&us->q_lock); QuestionData QD=us->questions.front(); us->questions.pop(); pthread_mutex_unlock(&us->q_lock); Question *q=QD.Q; if(us->d_overloaded && qcount <= overloadQueueLength/10) { us->d_overloaded=false; } Answer *a; #ifndef SMTPREDIR if(queuetimeout && q->d_dt.udiff()>queuetimeout*1000) { delete q; S.inc("timedout-packets"); continue; } #endif // this is the only point where we interact with the backend (synchronous) try { a=b->question(q); // a can be NULL! delete q; } catch(const AhuException &e) { L<a_lock); us->answers.push_back(tuple); pthread_mutex_unlock(&us->a_lock); // L<<"We have an answer to send! Trying to get to to_mut lock"<to_mut); // L<<"Yes, we got the lock, we can transmit! First we post"<numanswers.post(); // L<<"And now we broadcast!"<to_cond); // for timeoutWait(); pthread_mutex_unlock(&us->to_mut); } } delete b; } catch(const AhuException &AE) { L<int Distributor::question(Question* q, void (*callback)(const AnswerData &)) { if(d_num_threads==1 && callback) { // short circuit if(!b) { L<question(q); // a can be NULL! } catch(const AhuException &e) { L<5) { d_last_started=time(0); L<<"Distributor misses a thread ("<(this)); } QuestionData QD; QD.Q=q; QD.id=nextid++; QD.callback=callback; pthread_mutex_lock(&q_lock); questions.push(QD); pthread_mutex_unlock(&q_lock); numquestions.post(); static int overloadQueueLength=::arg().asNum("overload-queue-length"); if(!(nextid%50)) { int val; numquestions.getValue( &val ); if(!d_overloaded) d_overloaded = overloadQueueLength && (val > overloadQueueLength); if(val>::arg().asNum("max-queue-length")) { L<Answer* Distributor::answer() { numanswers.wait(); tuple_t tuple; pthread_mutex_lock(&a_lock); tuple=answers.front(); answers.pop_front(); pthread_mutex_unlock(&a_lock); return tuple.second.A; } //! Wait synchronously for the answer of the question just asked. For this to work, no answer() functions must be called templateAnswer* Distributor::wait(Question *q) { for(;;) { numanswers.wait(); pthread_mutex_lock(&a_lock); // search if the answer is there tuple_t tuple=answers.front(); if(tuple.first==q) { answers.pop_front(); pthread_mutex_unlock(&a_lock); return tuple.second.A; } // if not, loop again pthread_mutex_unlock(&a_lock); numanswers.post(); } // FIXME: write this } templatevoid Distributor::getQueueSizes(int &questions, int &answers) { numquestions.getValue( &questions ); numanswers.getValue( &answers ); } #endif // DISTRIBUTOR_HH pdns-3.3/pdns/unix_semaphore.cc0000644000014601777760000000670212136555572020104 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2005 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include #include #include #include #include "ahuexception.hh" #include "logger.hh" #include "misc.hh" #include #include #include #if DARWIN || _AIX || __APPLE__ // Darwin 6.0 Compatible implementation, uses pthreads so it portable across more platforms. #define SEM_VALUE_MAX 32767 #define SEM_MAGIC ((uint32_t) 0x09fa4012) Semaphore::Semaphore(unsigned int value) { if (value > SEM_VALUE_MAX) { throw AhuException("Cannot create semaphore: value too large"); } // Initialize if (pthread_mutex_init(&m_lock, NULL) != 0) { throw AhuException("Cannot create semaphore: cannot allocate mutex"); } if (pthread_cond_init(&m_gtzero, NULL) != 0) { pthread_mutex_destroy(&m_lock); throw AhuException("Cannot create semaphore: cannot allocate condition"); } m_count = (uint32_t) value; m_nwaiters = 0; m_magic = SEM_MAGIC; } int Semaphore::post() { pthread_mutex_lock(&m_lock); m_count++; if (m_nwaiters > 0) { pthread_cond_signal(&m_gtzero); } pthread_mutex_unlock(&m_lock); return 0; } int Semaphore::wait() { pthread_mutex_lock(&m_lock); while (m_count == 0) { m_nwaiters++; pthread_cond_wait(&m_gtzero, &m_lock); m_nwaiters--; } m_count--; pthread_mutex_unlock(&m_lock); return 0; } int Semaphore::tryWait() { int retval = 0; pthread_mutex_lock(&m_lock); if (m_count > 0) { m_count--; } else { errno = EAGAIN; retval = -1; } pthread_mutex_unlock(&m_lock); return retval; } int Semaphore::getValue(Semaphore::sem_value_t *sval) { pthread_mutex_lock(&m_lock); *sval = m_count; pthread_mutex_unlock(&m_lock); return 0; } Semaphore::~Semaphore() { // Make sure there are no waiters. pthread_mutex_lock(&m_lock); if (m_nwaiters > 0) { pthread_mutex_unlock(&m_lock); //errno = EBUSY; //return -1; } pthread_mutex_unlock(&m_lock); // Destroy it. pthread_mutex_destroy(&m_lock); pthread_cond_destroy(&m_gtzero); m_magic = 0; //return 0; } #else /* not DARWIN from here on */ Semaphore::Semaphore(unsigned int value) { m_pSemaphore=new sem_t; if (sem_init(m_pSemaphore, 0, value) == -1) { theL() << Logger::Error << "Cannot create semaphore: " << stringerror() << endl; exit(1); } } int Semaphore::post() { return sem_post(m_pSemaphore); } int Semaphore::wait() { int ret; do ret = sem_wait(m_pSemaphore); while (ret == -1 && errno == EINTR); return ret; } int Semaphore::tryWait() { return sem_trywait(m_pSemaphore); } int Semaphore::getValue(Semaphore::sem_value_t *sval) { return sem_getvalue(m_pSemaphore, sval); } Semaphore::~Semaphore() { } #endif pdns-3.3/pdns/syncres.hh0000644000014601777760000003674312136555572016566 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_SYNCRES_HH #define PDNS_SYNCRES_HH #include #include "dns.hh" #include "qtype.hh" #include #include #include #include #include #include #include "misc.hh" #include "lwres.hh" #include #include "sstuff.hh" #include "recursor_cache.hh" #include "recpacketcache.hh" #include #include #include #include "mtasker.hh" #include "iputils.hh" void primeHints(void); struct NegCacheEntry { string d_name; QType d_qtype; string d_qname; uint32_t d_ttd; uint32_t getTTD() const { return d_ttd; } }; template class Throttle : public boost::noncopyable { public: Throttle() { d_limit=3; d_ttl=60; d_last_clean=time(0); } bool shouldThrottle(time_t now, const Thing& t) { if(now > d_last_clean + 300 ) { d_last_clean=now; for(typename cont_t::iterator i=d_cont.begin();i!=d_cont.end();) { if( i->second.ttd < now) { d_cont.erase(i++); } else ++i; } } typename cont_t::iterator i=d_cont.find(t); if(i==d_cont.end()) return false; if(now > i->second.ttd || i->second.count-- < 0) { d_cont.erase(i); return false; } return true; // still listed, still blocked } void throttle(time_t now, const Thing& t, unsigned int ttl=0, unsigned int tries=0) { typename cont_t::iterator i=d_cont.find(t); entry e={ now+(ttl ? ttl : d_ttl), tries ? tries : d_limit}; if(i==d_cont.end()) { d_cont[t]=e; } else if(i->second.ttd > e.ttd || (i->second.count) < e.count) d_cont[t]=e; } unsigned int size() { return (unsigned int)d_cont.size(); } private: int d_limit; int d_ttl; time_t d_last_clean; struct entry { time_t ttd; int count; }; typedef map cont_t; cont_t d_cont; }; /** Class that implements a decaying EWMA. This class keeps an exponentially weighted moving average which, additionally, decays over time. The decaying is only done on get. */ class DecayingEwma { public: DecayingEwma() : d_val(0.0) { d_needinit=true; d_last.tv_sec = d_last.tv_usec = 0; d_lastget=d_last; } DecayingEwma(const DecayingEwma& orig) : d_last(orig.d_last), d_lastget(orig.d_lastget), d_val(orig.d_val), d_needinit(orig.d_needinit) { } struct timeval getOrMakeTime(struct timeval* tv) { if(tv) return *tv; else { struct timeval ret; Utility::gettimeofday(&ret, 0); return ret; } } void submit(int val, struct timeval* tv) { struct timeval now=getOrMakeTime(tv); if(d_needinit) { d_last=now; d_lastget=now; d_needinit=false; d_val = val; } else { float diff= makeFloat(d_last - now); d_last=now; double factor=exp(diff)/2.0; // might be '0.5', or 0.0001 d_val=(float)((1-factor)*val+ (float)factor*d_val); } } double get(struct timeval* tv) { struct timeval now=getOrMakeTime(tv); float diff=makeFloat(d_lastget-now); d_lastget=now; float factor=exp(diff/60.0f); // is 1.0 or less return d_val*=factor; } double peek(void) { return d_val; } bool stale(time_t limit) const { return limit > d_lastget.tv_sec; } private: struct timeval d_last; // stores time struct timeval d_lastget; // stores time float d_val; bool d_needinit; }; class SyncRes : public boost::noncopyable { public: enum LogMode { LogNone, Log, Store}; explicit SyncRes(const struct timeval& now); int beginResolve(const string &qname, const QType &qtype, uint16_t qclass, vector&ret); void setId(int id) { if(doLog()) d_prefix="["+itoa(id)+"] "; } static void setDefaultLogMode(LogMode lm) { s_lm = lm; } void setLogMode(LogMode lm) { d_lm = lm; } bool doLog() { return d_lm != LogNone; } void setCacheOnly(bool state=true) { d_cacheonly=state; } void setNoCache(bool state=true) { d_nocache=state; } void setDoEDNS0(bool state=true) { d_doEDNS0=state; } string getTrace() const { return d_trace.str(); } int asyncresolveWrapper(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, LWResult* res); static void doEDNSDumpAndClose(int fd); static unsigned int s_queries; static unsigned int s_outgoingtimeouts; static unsigned int s_throttledqueries; static unsigned int s_dontqueries; static unsigned int s_outqueries; static unsigned int s_tcpoutqueries; static unsigned int s_nodelegated; static unsigned int s_unreachables; static bool s_doAAAAAdditionalProcessing; static bool s_doAdditionalProcessing; static bool s_doIPv6; unsigned int d_outqueries; unsigned int d_tcpoutqueries; unsigned int d_throttledqueries; unsigned int d_timeouts; unsigned int d_unreachables; // typedef map negcache_t; typedef multi_index_container < NegCacheEntry, indexed_by < ordered_unique< composite_key< NegCacheEntry, member, member >, composite_key_compare > >, sequenced<> > > negcache_t; //! This represents a number of decaying Ewmas, used to store performance per nameserver-name. /** Modelled to work mostly like the underlying DecayingEwma. After you've called get, d_best is filled out with the best address for this collection */ struct DecayingEwmaCollection { void submit(const ComboAddress& remote, int usecs, struct timeval* now) { collection_t::iterator pos; for(pos=d_collection.begin(); pos != d_collection.end(); ++pos) if(pos->first==remote) break; if(pos!=d_collection.end()) { pos->second.submit(usecs, now); } else { DecayingEwma de; de.submit(usecs, now); d_collection.push_back(make_pair(remote, de)); } } double get(struct timeval* now) { if(d_collection.empty()) return 0; double ret=std::numeric_limits::max(); double tmp; for(collection_t::iterator pos=d_collection.begin(); pos != d_collection.end(); ++pos) { if((tmp=pos->second.get(now)) < ret) { ret=tmp; d_best=pos->first; } } return ret; } bool stale(time_t limit) const { for(collection_t::const_iterator pos=d_collection.begin(); pos != d_collection.end(); ++pos) if(!pos->second.stale(limit)) return false; return true; } typedef vector > collection_t; collection_t d_collection; ComboAddress d_best; }; typedef map nsspeeds_t; struct EDNSStatus { EDNSStatus() : mode(UNKNOWN), modeSetAt(0), EDNSPingHitCount(0) {} enum EDNSMode { CONFIRMEDPINGER=-1, UNKNOWN=0, EDNSNOPING=1, EDNSPINGOK=2, EDNSIGNORANT=3, NOEDNS=4 } mode; time_t modeSetAt; int EDNSPingHitCount; }; typedef map ednsstatus_t; static bool s_noEDNSPing; static bool s_noEDNS; struct AuthDomain { vector d_servers; bool d_rdForward; typedef multi_index_container < DNSResourceRecord, indexed_by < ordered_non_unique< composite_key< DNSResourceRecord, member, member >, composite_key_compare > > > > records_t; records_t d_records; }; typedef map domainmap_t; typedef Throttle > throttle_t; struct timeval d_now; static unsigned int s_maxnegttl; static unsigned int s_maxcachettl; static unsigned int s_packetcachettl; static unsigned int s_packetcacheservfailttl; static bool s_nopacketcache; static string s_serverID; struct StaticStorage { negcache_t negcache; nsspeeds_t nsSpeeds; ednsstatus_t ednsstatus; throttle_t throttle; domainmap_t* domainmap; }; private: struct GetBestNSAnswer; int doResolveAt(set nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, vector&ret, int depth, set&beenthere); int doResolve(const string &qname, const QType &qtype, vector&ret, int depth, set& beenthere); bool doOOBResolve(const string &qname, const QType &qtype, vector&ret, int depth, int &res); domainmap_t::const_iterator getBestAuthZone(string* qname); bool doCNAMECacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res); bool doCacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res); void getBestNSFromCache(const string &qname, set&bestns, bool* flawedNSSet, int depth, set& beenthere); void addCruft(const string &qname, vector& ret); string getBestNSNamesFromCache(const string &qname,set& nsset, bool* flawedNSSet, int depth, set&beenthere); void addAuthorityRecords(const string& qname, vector& ret, int depth); inline vector shuffleInSpeedOrder(set &nameservers, const string &prefix); bool moreSpecificThan(const string& a, const string &b); vector getAddrs(const string &qname, int depth, set& beenthere); private: ostringstream d_trace; string d_prefix; bool d_cacheonly; bool d_nocache; bool d_doEDNS0; static LogMode s_lm; LogMode d_lm; struct GetBestNSAnswer { string qname; set bestns; bool operator<(const GetBestNSAnswer &b) const { if(qname chain_t; mutable chain_t chain; int fd; bool operator<(const PacketID& b) const { int ourSock= sock ? sock->getHandle() : 0; int bSock = b.sock ? b.sock->getHandle() : 0; if( tie(remote, ourSock, type) < tie(b.remote, bSock, b.type)) return true; if( tie(remote, ourSock, type) > tie(b.remote, bSock, b.type)) return false; if(pdns_ilexicographical_compare(domain, b.domain)) return true; if(pdns_ilexicographical_compare(b.domain, domain)) return false; return tie(fd, id) < tie(b.fd, b.id); } }; struct PacketIDBirthdayCompare: public std::binary_function { bool operator()(const PacketID& a, const PacketID& b) const { int ourSock= a.sock ? a.sock->getHandle() : 0; int bSock = b.sock ? b.sock->getHandle() : 0; if( tie(a.remote, ourSock, a.type) < tie(b.remote, bSock, b.type)) return true; if( tie(a.remote, ourSock, a.type) > tie(b.remote, bSock, b.type)) return false; return pdns_ilexicographical_compare(a.domain, b.domain); } }; extern __thread MemRecursorCache* t_RC; extern __thread RecursorPacketCache* t_packetCache; typedef MTasker MT_t; extern __thread MT_t* MT; struct RecursorStats { uint64_t servFails; uint64_t nxDomains; uint64_t noErrors; uint64_t answers0_1, answers1_10, answers10_100, answers100_1000, answersSlow; uint64_t avgLatencyUsec; uint64_t qcounter; uint64_t ipv6qcounter; uint64_t tcpqcounter; uint64_t unauthorizedUDP; uint64_t unauthorizedTCP; uint64_t tcpClientOverflow; uint64_t clientParseError; uint64_t serverParseError; uint64_t unexpectedCount; uint64_t caseMismatchCount; uint64_t spoofCount; uint64_t resourceLimits; uint64_t overCapacityDrops; uint64_t ipv6queries; uint64_t chainResends; uint64_t nsSetInvalidations; uint64_t ednsPingMatches; uint64_t ednsPingMismatches; uint64_t noPingOutQueries, noEdnsOutQueries; uint64_t packetCacheHits; uint64_t noPacketError; time_t startupTime; unsigned int maxMThreadStackUsage; }; //! represents a running TCP/IP client session class TCPConnection : public boost::noncopyable { public: TCPConnection(int fd, const ComboAddress& addr); ~TCPConnection(); int getFD() { return d_fd; } enum stateenum {BYTE0, BYTE1, GETQUESTION, DONE} state; int qlen; int bytesread; const ComboAddress d_remote; char data[65535]; // damn static unsigned int getCurrentConnections() { return s_currentConnections; } private: const int d_fd; static AtomicCounter s_currentConnections; //!< total number of current TCP connections }; struct RemoteKeeper { typedef vector remotes_t; remotes_t remotes; int d_remotepos; void addRemote(const ComboAddress& remote) { if(!remotes.size()) return; remotes[(d_remotepos++) % remotes.size()]=remote; } }; extern __thread RemoteKeeper* t_remotes; string doQueueReloadLuaScript(vector::const_iterator begin, vector::const_iterator end); string doTraceRegex(vector::const_iterator begin, vector::const_iterator end); void parseACLs(); extern RecursorStats g_stats; extern unsigned int g_numThreads; std::string reloadAuthAndForwards(); ComboAddress parseIPAndPort(const std::string& input, uint16_t port); ComboAddress getQueryLocalAddress(int family, uint16_t port); typedef boost::function pipefunc_t; void broadcastFunction(const pipefunc_t& func, bool skipSelf = false); void distributeAsyncFunction(const pipefunc_t& func); int directResolve(const std::string& qname, const QType& qtype, int qclass, vector& ret); template T broadcastAccFunction(const boost::function& func, bool skipSelf=false); SyncRes::domainmap_t* parseAuthAndForwards(); uint64_t* pleaseGetNsSpeedsSize(); uint64_t* pleaseGetCacheSize(); uint64_t* pleaseGetNegCacheSize(); uint64_t* pleaseGetCacheHits(); uint64_t* pleaseGetCacheMisses(); uint64_t* pleaseGetConcurrentQueries(); uint64_t* pleaseGetThrottleSize(); uint64_t* pleaseGetPacketCacheHits(); uint64_t* pleaseGetPacketCacheSize(); uint64_t* pleaseWipeCache(const std::string& canon); uint64_t* pleaseWipeAndCountNegCache(const std::string& canon); #endif pdns-3.3/pdns/no-dnssec.schema.sqlite3.sql0000644000014601777760000000206212155271037021766 0ustar00jenkinsnogroup00000000000000create table domains ( id INTEGER PRIMARY KEY, name VARCHAR(255) NOT NULL COLLATE NOCASE, master VARCHAR(128) DEFAULT NULL, last_check INTEGER DEFAULT NULL, type VARCHAR(6) NOT NULL, notified_serial INTEGER DEFAULT NULL, account VARCHAR(40) DEFAULT NULL ); CREATE UNIQUE INDEX name_index ON domains(name); CREATE TABLE records ( id INTEGER PRIMARY KEY, domain_id INTEGER DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(10) DEFAULT NULL, content VARCHAR(65535) DEFAULT NULL, ttl INTEGER DEFAULT NULL, prio INTEGER DEFAULT NULL, change_date INTEGER DEFAULT NULL ); CREATE INDEX rec_name_index ON records(name); CREATE INDEX nametype_index ON records(name,type); CREATE INDEX domain_id ON records(domain_id); create table supermasters ( ip VARCHAR(64) NOT NULL, nameserver VARCHAR(255) NOT NULL COLLATE NOCASE, account VARCHAR(40) DEFAULT NULL ); pdns-3.3/pdns/base32.cc0000644000014601777760000000661012136555572016133 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include #include #include "base32.hh" #include "namespaces.hh" /* based on freebsd:src/contrib/opie/libopie/btoe.c extract: get bit ranges from a char* */ /* NOTE: length should not exceed 8; all callers inside PowerDNS only pass length=5 though */ unsigned char extract_bits(const char *s, int start, int length) { uint16_t x; unsigned char cl, cc; if(!length) return 0; cl = s[start / 8]; if(start / 8 < (start + length-1)/8) cc = s[start / 8 + 1]; else cc = 0; x = (uint16_t) (cl << 8 | cc); x = x >> (16 - (length + (start % 8))); x = (x & (0xffff >> (16 - length))); return (x); } /* same, set bit ranges in a char* */ static void set_bits(char* s, int x, int start, int length) { unsigned char cl, cc, cr; uint32_t y; int shift; shift = ((8 - ((start + length) % 8)) % 8); y = (uint32_t) x << shift; cl = (y >> 16) & 0xff; cc = (y >> 8) & 0xff; cr = y & 0xff; if (shift + length > 16) { s[start / 8] |= cl; s[start / 8 + 1] |= cc; s[start / 8 + 2] |= cr; } else { if (shift + length > 8) { s[start / 8] |= cc; s[start / 8 + 1] |= cr; } else { s[start / 8] |= cr; } } } /* convert a base32 hex character to its decoded equivalent */ static int unbase32hex(char c) { if(c >= '0' && c<='9') return c-'0'; if(c >= 'a' && c<='z') return 10 + (c-'a'); if(c >= 'A' && c<='Z') return 10 + (c-'A'); if(c=='=') return '='; return -1; } /* convert a binary string to base32hex */ string toBase32Hex(const std::string& input) { static const char base32hex[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV="; string ret; ret.reserve(4+ 8*input.length()/5); // optimization // process input in groups of 5 8-bit chunks, emit 8 5-bit chunks for(string::size_type offset = 0 ; offset < input.length(); offset+=5) { int todo = input.length() - offset; int stuffing; // how much '=' to add at the end switch(todo) { case 1: stuffing = 6; break; case 2: stuffing = 4; break; case 3: stuffing = 3; break; case 4: stuffing = 1; break; default: // -> 0 or more than 5, no stuffing stuffing = 0; break; } for(int n=0; n < 8 - stuffing; ++n) ret.append(1, base32hex[extract_bits(input.c_str()+offset, n*5, 5)]); ret.append(stuffing, '='); } return ret; } // convert base32hex encoded string to normal string string fromBase32Hex(const std::string& input) { string ret; char block[5]={0,0,0,0,0}; // we process 5 8-bit chunks at a time string::size_type n, toWrite=0; for(n = 0; n < input.length(); ++n) { int c=unbase32hex(input[n]); if(c == '=' || c < 0) // stop at stuffing or error break; set_bits(block, c , (n % 8) * 5, 5); if(++toWrite == 8) { ret.append(block, sizeof(block)); memset(block, 0, sizeof(block)); toWrite = 0; } } ret.append(block, (toWrite*5)/8); return ret; } #if 0 int main(int argc, char **argv) { if(argc!=3 || (argc==3 && strcmp(argv[1],"from") && strcmp(argv[1],"to"))) { printf("syntax: base32 from|to string\n"); exit(0); } if(!strcmp(argv[1],"to")) { printf("input: '%s'\noutput: '%s'\n", argv[2], toBase32Hex(argv[2]).c_str()); } else { cout<<"input: '"< #include #include #include #include #include "qtype.hh" #include "misc.hh" #include "lock.hh" vector QType::names; // XXX FIXME we need to do something with initializer order here! QType::init QType::initializer; QType::QType() { } uint16_t QType::getCode() const { return code; } const string QType::getName() const { vector::iterator pos; for(pos=names.begin();possecond==code) return pos->first; return "TYPE"+itoa(code); } QType &QType::operator=(uint16_t n) { code=n; return *this; } int QType::chartocode(const char *p) { static QType qt; vector::iterator pos; for(pos=names.begin(); pos < names.end(); ++pos) if(pos->first == p) return pos->second; if(*p=='#') { return atoi(p+1); } if(boost::starts_with(p, "TYPE")) return atoi(p+4); return 0; } QType &QType::operator=(const char *p) { code=chartocode(p); return *this; } QType &QType::operator=(const string &s) { code=chartocode(s.c_str()); return *this; } QType::QType(uint16_t n) { QType(); code=n; } pdns-3.3/pdns/reczones.cc0000644000014601777760000003274512165455411016705 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2003 - 2010 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "syncres.hh" #include "arguments.hh" #include "zoneparser-tng.hh" #include "logger.hh" #include "dnsrecords.hh" void primeHints(void) { // prime root cache setnsset; if(!t_RC) t_RC = new MemRecursorCache(); if(::arg()["hint-file"].empty()) { static const char*ips[]={"198.41.0.4", "192.228.79.201", "192.33.4.12", "199.7.91.13", "192.203.230.10", "192.5.5.241", "192.112.36.4", "128.63.2.53", "192.36.148.17","192.58.128.30", "193.0.14.129", "199.7.83.42", "202.12.27.33"}; static const char *ip6s[]={ "2001:503:ba3e::2:30", NULL, NULL, NULL, NULL, "2001:500:2f::f", NULL, "2001:500:1::803f:235", "2001:7fe::53", "2001:503:c27::2:30", "2001:7fd::1", "2001:500:3::42", "2001:dc3::35" }; DNSResourceRecord arr, aaaarr, nsrr; arr.qtype=QType::A; aaaarr.qtype=QType::AAAA; nsrr.qtype=QType::NS; arr.ttl=aaaarr.ttl=nsrr.ttl=time(0)+3600000; for(char c='a';c<='m';++c) { static char templ[40]; strncpy(templ,"a.root-servers.net.", sizeof(templ) - 1); *templ=c; aaaarr.qname=arr.qname=nsrr.content=templ; arr.content=ips[c-'a']; set aset; aset.insert(arr); t_RC->replace(time(0), string(templ), QType(QType::A), aset, true); // auth, nuke it all if (ip6s[c-'a'] != NULL) { aaaarr.content=ip6s[c-'a']; set aaaaset; aaaaset.insert(aaaarr); t_RC->replace(time(0), string(templ), QType(QType::AAAA), aaaaset, true); } nsset.insert(nsrr); } } else { ZoneParserTNG zpt(::arg()["hint-file"]); DNSResourceRecord rr; while(zpt.get(rr)) { rr.ttl+=time(0); if(rr.qtype.getCode()==QType::A) { set aset; aset.insert(rr); t_RC->replace(time(0), rr.qname, QType(QType::A), aset, true); // auth, etc see above } else if(rr.qtype.getCode()==QType::AAAA) { set aaaaset; aaaaset.insert(rr); t_RC->replace(time(0), rr.qname, QType(QType::AAAA), aaaaset, true); } else if(rr.qtype.getCode()==QType::NS) { rr.content=toLower(rr.content); nsset.insert(rr); } } } t_RC->replace(time(0),".", QType(QType::NS), nsset, true); // and stuff in the cache (auth) } static void makeNameToIPZone(SyncRes::domainmap_t* newMap, const string& hostname, const string& ip) { SyncRes::AuthDomain ad; DNSResourceRecord rr; rr.qname=toCanonic("", hostname); rr.d_place=DNSResourceRecord::ANSWER; rr.ttl=86400; rr.qtype=QType::SOA; rr.content="localhost. root 1 604800 86400 2419200 604800"; ad.d_records.insert(rr); rr.qtype=QType::NS; rr.content="localhost."; ad.d_records.insert(rr); rr.qtype=QType::A; rr.content=ip; ad.d_records.insert(rr); if(newMap->count(rr.qname)) { L<& parts) { string address=parts[0]; vector ipparts; stringtok(ipparts, address,"."); SyncRes::AuthDomain ad; DNSResourceRecord rr; for(int n=ipparts.size()-1; n>=0 ; --n) { rr.qname.append(ipparts[n]); rr.qname.append(1,'.'); } rr.qname.append("in-addr.arpa."); rr.d_place=DNSResourceRecord::ANSWER; rr.ttl=86400; rr.qtype=QType::SOA; rr.content="localhost. root. 1 604800 86400 2419200 604800"; ad.d_records.insert(rr); rr.qtype=QType::NS; rr.content="localhost."; ad.d_records.insert(rr); rr.qtype=QType::PTR; if(ipparts.size()==4) // otherwise this is a partial zone for(unsigned int n=1; n < parts.size(); ++n) { rr.content=toCanonic("", parts[n]); ad.d_records.insert(rr); } if(newMap->count(rr.qname)) { L< both; try { // case 2 both=splitField(input,':'); uint16_t newport=boost::lexical_cast(both.second); return ComboAddress(both.first, newport); } catch(...){} if(input[0]=='[') { // case 4 both=splitField(input.substr(1),']'); return ComboAddress(both.first, both.second.empty() ? port : boost::lexical_cast(both.second.substr(1))); } return ComboAddress(input, port); // case 3 } void convertServersForAD(const std::string& input, SyncRes::AuthDomain& ad, const char* sepa, bool verbose=true) { vector servers; stringtok(servers, input, sepa); ad.d_servers.clear(); for(vector::const_iterator iter = servers.begin(); iter != servers.end(); ++iter) { if(verbose && iter != servers.begin()) L<<", "; ComboAddress addr=parseIPAndPort(*iter, 53); if(verbose) L<negcache.clear(); return 0; } void* pleaseUseNewSDomainsMap(SyncRes::domainmap_t* newmap) { t_sstorage->domainmap = newmap; return 0; } string reloadAuthAndForwards() { SyncRes::domainmap_t* original=t_sstorage->domainmap; try { L<domainmap->begin(); i != t_sstorage->domainmap->end(); ++i) { for(SyncRes::AuthDomain::records_t::const_iterator j = i->second.d_records.begin(); j != i->second.d_records.end(); ++j) broadcastAccFunction(boost::bind(pleaseWipeCache, j->qname)); } string configname=::arg()["config-dir"]+"/recursor.conf"; cleanSlashes(configname); if(!::arg().preParseFile(configname.c_str(), "forward-zones")) L<begin(); i != newDomainMap->end(); ++i) { for(SyncRes::AuthDomain::records_t::const_iterator j = i->second.d_records.begin(); j != i->second.d_records.end(); ++j) broadcastAccFunction(boost::bind(pleaseWipeCache, j->qname)); } // this is pretty blunt broadcastFunction(pleaseWipeNegCache); broadcastFunction(boost::bind(pleaseUseNewSDomainsMap, newDomainMap)); delete original; return "ok\n"; } catch(std::exception& e) { L< parts_t; parts_t parts; const char *option_names[3]={"auth-zones", "forward-zones", "forward-zones-recurse"}; for(int n=0; n < 3 ; ++n ) { parts.clear(); stringtok(parts, ::arg()[option_names[n]], ",\t\n\r"); for(parts_t::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) { SyncRes::AuthDomain ad; pair headers=splitField(*iter, '='); trim(headers.first); trim(headers.second); headers.first=toCanonic("", headers.first); if(n==0) { L< fp=shared_ptr(rfp, fclose); string line; int linenum=0; uint64_t before = newMap->size(); while(linenum++, stringfgets(fp.get(), line)) { string domain, instructions; tie(domain, instructions)=splitField(line, '='); trim(domain); trim(instructions); if(domain.empty() && instructions.empty()) { // empty line continue; } if(boost::starts_with(domain,"+")) { domain=domain.c_str()+1; ad.d_rdForward = true; } else ad.d_rdForward = false; if(domain.empty()) { delete newMap; throw AhuException("Error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); } try { convertServersForAD(instructions, ad, ",; ", false); } catch(...) { delete newMap; throw AhuException("Conversion error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); } (*newMap)[toCanonic("", domain)]=ad; } L<size() - before<<" forwarding instructions from file '"<<::arg()["forward-zones-file"]<<"'"<(n); makeIPToNamesZone(newMap,parts); } } return newMap; } pdns-3.3/pdns/no-dnssec.schema.mysql.sql0000644000014601777760000000176512165337676021575 0ustar00jenkinsnogroup00000000000000create table domains ( id INT auto_increment, name VARCHAR(255) NOT NULL, master VARCHAR(128) DEFAULT NULL, last_check INT DEFAULT NULL, type VARCHAR(6) NOT NULL, notified_serial INT DEFAULT NULL, account VARCHAR(40) DEFAULT NULL, primary key (id) ) Engine=InnoDB; CREATE UNIQUE INDEX name_index ON domains(name); CREATE TABLE records ( id INT auto_increment, domain_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(10) DEFAULT NULL, content VARCHAR(64000) DEFAULT NULL, ttl INT DEFAULT NULL, prio INT DEFAULT NULL, change_date INT DEFAULT NULL, primary key(id) ) Engine=InnoDB; CREATE INDEX nametype_index ON records(name,type); CREATE INDEX domain_id ON records(domain_id); create table supermasters ( ip VARCHAR(64) NOT NULL, nameserver VARCHAR(255) NOT NULL, account VARCHAR(40) DEFAULT NULL ) Engine=InnoDB; pdns-3.3/pdns/pdns_recursor.cc0000644000014601777760000021030212147373147017735 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2003 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef WIN32 # include # include # include #else #include "ntservice.hh" #include "recursorservice.hh" #endif // WIN32 #include #include "json_ws.hh" #include #include "recpacketcache.hh" #include "utility.hh" #include "dns_random.hh" #include #include #include #include #include "recursor_cache.hh" #include "cachecleaner.hh" #include #include #include #include "misc.hh" #include "mtasker.hh" #include #include "arguments.hh" #include "syncres.hh" #include #include #include "sstuff.hh" #include #include #include #include #include #include #include #include "dnsparser.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "zoneparser-tng.hh" #include "rec_channel.hh" #include "logger.hh" #include "iputils.hh" #include "mplexer.hh" #include "config.h" #include "lua-recursor.hh" #include "version.hh" #ifndef RECURSOR #include "statbag.hh" StatBag S; #endif __thread FDMultiplexer* t_fdm; __thread unsigned int t_id; unsigned int g_maxTCPPerClient; unsigned int g_networkTimeoutMsec; bool g_logCommonErrors; __thread shared_ptr* t_pdl; __thread RemoteKeeper* t_remotes; __thread shared_ptr* t_traceRegex; RecursorControlChannel s_rcc; // only active in thread 0 // for communicating with our threads struct ThreadPipeSet { int writeToThread; int readToThread; int writeFromThread; int readFromThread; }; vector g_pipes; // effectively readonly after startup SyncRes::domainmap_t* g_initialDomainMap; // new threads needs this to be setup #include "namespaces.hh" __thread MemRecursorCache* t_RC; __thread RecursorPacketCache* t_packetCache; RecursorStats g_stats; bool g_quiet; bool g_weDistributeQueries; // if true, only 1 thread listens on the incoming query sockets static __thread NetmaskGroup* t_allowFrom; static NetmaskGroup* g_initialAllowFrom; // new thread needs to be setup with this NetmaskGroup* g_dontQuery; string s_programname="pdns_recursor"; typedef vector tcpListenSockets_t; tcpListenSockets_t g_tcpListenSockets; // shared across threads, but this is fine, never written to from a thread. All threads listen on all sockets int g_tcpTimeout; unsigned int g_maxMThreads; struct timeval g_now; // timestamp, updated (too) frequently map g_listenSocketsAddresses; // is shared across all threads right now __thread MT_t* MT; // the big MTasker unsigned int g_numThreads; #define LOCAL_NETS "127.0.0.0/8, 10.0.0.0/8, 100.64.0.0/10, 169.254.0.0/16, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10" //! used to send information to a newborn mthread struct DNSComboWriter { DNSComboWriter(const char* data, uint16_t len, const struct timeval& now) : d_mdp(data, len), d_now(now), d_tcp(false), d_socket(-1) {} MOADNSParser d_mdp; void setRemote(const ComboAddress* sa) { d_remote=*sa; } void setSocket(int sock) { d_socket=sock; } string getRemote() const { return d_remote.toString(); } struct timeval d_now; ComboAddress d_remote; bool d_tcp; int d_socket; shared_ptr d_tcpConnection; }; ArgvMap &arg() { static ArgvMap theArg; return theArg; } void handleTCPClientWritable(int fd, FDMultiplexer::funcparam_t& var); // -1 is error, 0 is timeout, 1 is success int asendtcp(const string& data, Socket* sock) { PacketID pident; pident.sock=sock; pident.outMSG=data; t_fdm->addWriteFD(sock->getHandle(), handleTCPClientWritable, pident); string packet; int ret=MT->waitEvent(pident, &packet, g_networkTimeoutMsec); if(!ret || ret==-1) { // timeout t_fdm->removeWriteFD(sock->getHandle()); } else if(packet.size() !=data.size()) { // main loop tells us what it sent out, or empty in case of an error return -1; } return ret; } void handleTCPClientReadable(int fd, FDMultiplexer::funcparam_t& var); // -1 is error, 0 is timeout, 1 is success int arecvtcp(string& data, int len, Socket* sock) { data.clear(); PacketID pident; pident.sock=sock; pident.inNeeded=len; t_fdm->addReadFD(sock->getHandle(), handleTCPClientReadable, pident); int ret=MT->waitEvent(pident,&data, g_networkTimeoutMsec); if(!ret || ret==-1) { // timeout t_fdm->removeReadFD(sock->getHandle()); } else if(data.empty()) {// error, EOF or other return -1; } return ret; } vector g_localQueryAddresses4, g_localQueryAddresses6; const ComboAddress g_local4("0.0.0.0"), g_local6("::"); //! pick a random query local address ComboAddress getQueryLocalAddress(int family, uint16_t port) { ComboAddress ret; if(family==AF_INET) { if(g_localQueryAddresses4.empty()) ret = g_local4; else ret = g_localQueryAddresses4[dns_random(g_localQueryAddresses4.size())]; ret.sin4.sin_port = htons(port); } else { if(g_localQueryAddresses6.empty()) ret = g_local6; else ret = g_localQueryAddresses6[dns_random(g_localQueryAddresses6.size())]; ret.sin6.sin6_port = htons(port); } return ret; } void handleUDPServerResponse(int fd, FDMultiplexer::funcparam_t&); void setSocketBuffer(int fd, int optname, uint32_t size) { uint32_t psize=0; socklen_t len=sizeof(psize); if(!getsockopt(fd, SOL_SOCKET, optname, (char*)&psize, &len) && psize > size) { L< socks_t; socks_t d_socks; // returning -1 means: temporary OS error (ie, out of files), -2 means OS error int getSocket(const ComboAddress& toaddr, int* fd) { *fd=makeClientSocket(toaddr.sin4.sin_family); if(*fd < 0) // temporary error - receive exception otherwise return -1; if(connect(*fd, (struct sockaddr*)(&toaddr), toaddr.getSocklen()) < 0) { int err = errno; // returnSocket(*fd); Utility::closesocket(*fd); if(err==ENETUNREACH) // Seth "My Interfaces Are Like A Yo Yo" Arnold special return -2; return -1; } d_socks.insert(*fd); d_numsocks++; return 0; } void returnSocket(int fd) { socks_t::iterator i=d_socks.find(fd); if(i==d_socks.end()) { throw AhuException("Trying to return a socket (fd="+lexical_cast(fd)+") not in the pool"); } returnSocketLocked(i); } // return a socket to the pool, or simply erase it void returnSocketLocked(socks_t::iterator& i) { if(i==d_socks.end()) { throw AhuException("Trying to return a socket not in the pool"); } try { t_fdm->removeReadFD(*i); } catch(FDMultiplexerException& e) { // we sometimes return a socket that has not yet been assigned to t_fdm } Utility::closesocket(*i); d_socks.erase(i++); --d_numsocks; } // returns -1 for errors which might go away, throws for ones that won't static int makeClientSocket(int family) { int ret=(int)socket(family, SOCK_DGRAM, 0); if(ret < 0 && errno==EMFILE) // this is not a catastrophic error return ret; if(ret<0) throw AhuException("Making a socket for resolver (family = "+lexical_cast(family)+"): "+stringerror()); Utility::setCloseOnExec(ret); int tries=10; while(--tries) { uint16_t port; if(tries==1) // fall back to kernel 'random' port = 0; else port = 1025 + dns_random(64510); ComboAddress sin=getQueryLocalAddress(family, port); // does htons for us if (::bind(ret, (struct sockaddr *)&sin, sin.getSocklen()) >= 0) break; } if(!tries) throw AhuException("Resolver binding to local query client socket: "+stringerror()); Utility::setNonBlocking(ret); return ret; } }; static __thread UDPClientSocks* t_udpclientsocks; /* these two functions are used by LWRes */ // -2 is OS error, -1 is error that depends on the remote, > 0 is success int asendto(const char *data, int len, int flags, const ComboAddress& toaddr, uint16_t id, const string& domain, uint16_t qtype, int* fd) { PacketID pident; pident.domain = domain; pident.remote = toaddr; pident.type = qtype; // see if there is an existing outstanding request we can chain on to, using partial equivalence function pair chain=MT->d_waiters.equal_range(pident, PacketIDBirthdayCompare()); for(; chain.first != chain.second; chain.first++) { if(chain.first->key.fd > -1) { // don't chain onto existing chained waiter! /* cerr<<"Orig: "<key.domain<<", "<key.remote.toString()<<", id="<key.id <<", count="<key.chain.size()<<", origfd: "<key.fd<key.chain.insert(id); // we can chain *fd=-1; // gets used in waitEvent / sendEvent later on return 1; } } int ret=t_udpclientsocks->getSocket(toaddr, fd); if(ret < 0) return ret; pident.fd=*fd; pident.id=id; t_fdm->addReadFD(*fd, handleUDPServerResponse, pident); ret = send(*fd, data, len, 0); int tmp = errno; if(ret < 0) t_udpclientsocks->returnSocket(*fd); errno = tmp; // this is for logging purposes only return ret; } // -1 is error, 0 is timeout, 1 is success int arecvfrom(char *data, int len, int flags, const ComboAddress& fromaddr, int *d_len, uint16_t id, const string& domain, uint16_t qtype, int fd, struct timeval* now) { static optional nearMissLimit; if(!nearMissLimit) nearMissLimit=::arg().asNum("spoof-nearmiss-max"); PacketID pident; pident.fd=fd; pident.id=id; pident.domain=domain; pident.type = qtype; pident.remote=fromaddr; string packet; int ret=MT->waitEvent(pident, &packet, g_networkTimeoutMsec, now); if(ret > 0) { if(packet.empty()) // means "error" return -1; *d_len=(int)packet.size(); memcpy(data,packet.c_str(),min(len,*d_len)); if(*nearMissLimit && pident.nearMisses > *nearMissLimit) { L< "<<*nearMissLimit<<") bogus answers for '"<= 0) t_udpclientsocks->returnSocket(fd); } return ret; } string s_pidfname; static void writePid(void) { ofstream of(s_pidfname.c_str(), std::ios_base::app); if(of) of<< Utility::getpid() < tcpClientCounts_t; tcpClientCounts_t __thread* t_tcpClientCounts; TCPConnection::TCPConnection(int fd, const ComboAddress& addr) : d_remote(addr), d_fd(fd) { ++s_currentConnections; (*t_tcpClientCounts)[d_remote]++; } TCPConnection::~TCPConnection() { if(Utility::closesocket(d_fd) < 0) unixDie("closing socket for TCPConnection"); if(t_tcpClientCounts->count(d_remote) && !(*t_tcpClientCounts)[d_remote]--) t_tcpClientCounts->erase(d_remote); --s_currentConnections; } AtomicCounter TCPConnection::s_currentConnections; void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var); void updateRcodeStats(int res) { switch(res) { case RCode::ServFail: g_stats.servFails++; break; case RCode::NXDomain: g_stats.nxDomains++; break; case RCode::NoError: g_stats.noErrors++; break; } } void startDoResolve(void *p) { DNSComboWriter* dc=(DNSComboWriter *)p; string loginfo=""; try { loginfo=" (while setting loginfo)"; loginfo=" ("+dc->d_mdp.d_qname+"/"+lexical_cast(dc->d_mdp.d_qtype)+" from "+(dc->d_remote.toString())+")"; uint32_t maxanswersize= dc->d_tcp ? 65535 : 512; EDNSOpts edo; if(getEDNSOpts(dc->d_mdp, &edo)) { maxanswersize = min(edo.d_packetsize, (uint16_t) (dc->d_tcp ? 65535 : 1680)); } vector ret; vector packet; DNSPacketWriter pw(packet, dc->d_mdp.d_qname, dc->d_mdp.d_qtype, dc->d_mdp.d_qclass); pw.getHeader()->aa=0; pw.getHeader()->ra=1; pw.getHeader()->qr=1; pw.getHeader()->tc=0; pw.getHeader()->id=dc->d_mdp.d_header.id; pw.getHeader()->rd=dc->d_mdp.d_header.rd; SyncRes sr(dc->d_now); bool tracedQuery=false; // we could consider letting Lua know about this too if(t_traceRegex->get() && (*t_traceRegex)->match(dc->d_mdp.d_qname)) { sr.setLogMode(SyncRes::Store); tracedQuery=true; } if(!g_quiet || tracedQuery) L<getTid()<<"] " << (dc->d_tcp ? "TCP " : "") << "question for '"<d_mdp.d_qname<<"|" <d_mdp.d_qtype)<<"' from "<getRemote()<getTid()); if(!dc->d_mdp.d_header.rd) sr.setCacheOnly(); int res; bool variableAnswer = false; // if there is a RecursorLua active, and it 'took' the query in preResolve, we don't launch beginResolve if(!t_pdl->get() || !(*t_pdl)->preresolve(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer)) { res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret); if(t_pdl->get()) { if(res == RCode::NoError) { vector::const_iterator i; for(i=ret.begin(); i!=ret.end(); ++i) if(i->qtype.getCode() == dc->d_mdp.d_qtype && i->d_place == DNSResourceRecord::ANSWER) break; if(i == ret.end()) (*t_pdl)->nodata(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer); } else if(res == RCode::NXDomain) (*t_pdl)->nxdomain(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer); (*t_pdl)->postresolve(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer); } } uint32_t minTTL=std::numeric_limits::max(); if(tracedQuery || res < 0 || res == RCode::ServFail || pw.getHeader()->rcode == RCode::ServFail) { string trace(sr.getTrace()); if(!trace.empty()) { vector lines; boost::split(lines, trace, boost::is_any_of("\n")); BOOST_FOREACH(const string& line, lines) { if(!line.empty()) L<rcode=RCode::ServFail; // no commit here, because no record g_stats.servFails++; } else { pw.getHeader()->rcode=res; updateRcodeStats(res); if(ret.size()) { orderAndShuffle(ret); for(vector::const_iterator i=ret.begin(); i!=ret.end(); ++i) { pw.startRecord(i->qname, i->qtype.getCode(), i->ttl, i->qclass, (DNSPacketWriter::Place)i->d_place); minTTL = min(minTTL, i->ttl); if(i->qtype.getCode() == QType::A) { // blast out A record w/o doing whole dnswriter thing uint32_t ip=0; IpToU32(i->content, &ip); pw.xfr32BitInt(htonl(ip)); } else { shared_ptr drc(DNSRecordContent::mastermake(i->qtype.getCode(), i->qclass, i->content)); drc->toPacket(pw); } if(pw.size() > maxanswersize) { pw.rollback(); if(i->d_place==DNSResourceRecord::ANSWER) // only truncate if we actually omitted parts of the answer pw.getHeader()->tc=1; goto sendit; // need to jump over pw.commit } } pw.commit(); } } sendit:; if(!dc->d_tcp) { sendto(dc->d_socket, (const char*)&*packet.begin(), packet.size(), 0, (struct sockaddr *)(&dc->d_remote), dc->d_remote.getSocklen()); if(!SyncRes::s_nopacketcache && !variableAnswer ) { t_packetCache->insertResponsePacket(string((const char*)&*packet.begin(), packet.size()), g_now.tv_sec, min(minTTL, (pw.getHeader()->rcode == RCode::ServFail) ? SyncRes::s_packetcacheservfailttl : SyncRes::s_packetcachettl ) ); } } else { char buf[2]; buf[0]=packet.size()/256; buf[1]=packet.size()%256; Utility::iovec iov[2]; iov[0].iov_base=(void*)buf; iov[0].iov_len=2; iov[1].iov_base=(void*)&*packet.begin(); iov[1].iov_len = packet.size(); int ret=Utility::writev(dc->d_socket, iov, 2); bool hadError=true; if(ret == 0) L<getRemote()<getRemote()<<": "<< strerror(errno) <getRemote()<<" for "<d_mdp.d_qname<<" (size="<< (2 + packet.size()) <<", sent "<d_socket = -1; } else { dc->d_tcpConnection->state=TCPConnection::BYTE0; Utility::gettimeofday(&g_now, 0); // needs to be updated t_fdm->addReadFD(dc->d_socket, handleRunningTCPQuestion, dc->d_tcpConnection); t_fdm->setReadTTD(dc->d_socket, g_now, g_tcpTimeout); } } if(!g_quiet) { L<getTid()<<"] answer to "<<(dc->d_mdp.d_header.rd?"":"non-rd ")<<"question '"<d_mdp.d_qname<<"|"<d_mdp.d_qtype); L<<"': "<ancount)<<" answers, "<arcount)<<" additional, took "<d_mdp.d_qname<<", "<getMaxStackUsage(), g_stats.maxMThreadStackUsage); } void makeControlChannelSocket(int processNum=-1) { string sockname=::arg()["socket-dir"]+"/pdns_recursor"; if(processNum >= 0) sockname += "."+lexical_cast(processNum); sockname+=".controlsocket"; s_rcc.listen(sockname); #ifndef WIN32 int sockowner = -1; int sockgroup = -1; if (!::arg().isEmpty("socket-group")) sockgroup=::arg().asGid("socket-group"); if (!::arg().isEmpty("socket-owner")) sockowner=::arg().asUid("socket-owner"); if (sockgroup > -1 || sockowner > -1) { if(chown(sockname.c_str(), sockowner, sockgroup) < 0) { unixDie("Failed to chown control socket"); } } // do mode change if socket-mode is given if(!::arg().isEmpty("socket-mode")) { mode_t sockmode=::arg().asMode("socket-mode"); chmod(sockname.c_str(), sockmode); } #endif } void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) { shared_ptr conn=any_cast >(var); if(conn->state==TCPConnection::BYTE0) { int bytes=recv(conn->getFD(), conn->data, 2, 0); if(bytes==1) conn->state=TCPConnection::BYTE1; if(bytes==2) { conn->qlen=(((unsigned char)conn->data[0]) << 8)+ (unsigned char)conn->data[1]; conn->bytesread=0; conn->state=TCPConnection::GETQUESTION; } if(!bytes || bytes < 0) { t_fdm->removeReadFD(fd); return; } } else if(conn->state==TCPConnection::BYTE1) { int bytes=recv(conn->getFD(), conn->data+1, 1, 0); if(bytes==1) { conn->state=TCPConnection::GETQUESTION; conn->qlen=(((unsigned char)conn->data[0]) << 8)+ (unsigned char)conn->data[1]; conn->bytesread=0; } if(!bytes || bytes < 0) { if(g_logCommonErrors) L<d_remote.toString() <<" disconnected after first byte"<removeReadFD(fd); return; } } else if(conn->state==TCPConnection::GETQUESTION) { int bytes=recv(conn->getFD(), conn->data + conn->bytesread, conn->qlen - conn->bytesread, 0); if(!bytes || bytes < 0) { L<d_remote.toString() <<" disconnected while reading question body"<removeReadFD(fd); return; } conn->bytesread+=bytes; if(conn->bytesread==conn->qlen) { t_fdm->removeReadFD(fd); // should no longer awake ourselves when there is data to read DNSComboWriter* dc=0; try { dc=new DNSComboWriter(conn->data, conn->qlen, g_now); } catch(MOADNSException &mde) { g_stats.clientParseError++; if(g_logCommonErrors) L<d_remote.toString() <d_tcpConnection = conn; // carry the torch dc->setSocket(conn->getFD()); // this is the only time a copy is made of the actual fd dc->d_tcp=true; dc->setRemote(&conn->d_remote); if(dc->d_mdp.d_header.qr) { delete dc; L<makeThread(startDoResolve, dc); // deletes dc, will set state to BYTE0 again return; } } } } //! Handle new incoming TCP connection void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& ) { ComboAddress addr; socklen_t addrlen=sizeof(addr); int newsock=(int)accept(fd, (struct sockaddr*)&addr, &addrlen); if(newsock>0) { if(MT->numProcesses() > g_maxMThreads) { g_stats.overCapacityDrops++; Utility::closesocket(newsock); return; } t_remotes->addRemote(addr); if(t_allowFrom && !t_allowFrom->match(&addr)) { if(!g_quiet) L<getTid()<<"] dropping TCP query from "<count(addr) && (*t_tcpClientCounts)[addr] >= g_maxTCPPerClient) { g_stats.tcpClientOverflow++; Utility::closesocket(newsock); // don't call TCPConnection::closeAndCleanup here - did not enter it in the counts yet! return; } Utility::setNonBlocking(newsock); shared_ptr tc(new TCPConnection(newsock, addr)); tc->state=TCPConnection::BYTE0; t_fdm->addReadFD(tc->getFD(), handleRunningTCPQuestion, tc); struct timeval now; Utility::gettimeofday(&now, 0); t_fdm->setReadTTD(tc->getFD(), now, g_tcpTimeout); } } string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, int fd) { ++g_stats.qcounter; if(fromaddr.sin4.sin_family==AF_INET6) g_stats.ipv6qcounter++; string response; try { uint32_t age; if(!SyncRes::s_nopacketcache && t_packetCache->getResponsePacket(question, g_now.tv_sec, &response, &age)) { if(!g_quiet) L<= sizeof(struct dnsheader)) { struct dnsheader dh; memcpy(&dh, response.c_str(), sizeof(dh)); updateRcodeStats(dh.rcode); } g_stats.avgLatencyUsec=(uint64_t)((1-0.0001)*g_stats.avgLatencyUsec + 0); // we assume 0 usec return 0; } } catch(std::exception& e) { L<numProcesses() > g_maxMThreads) { g_stats.overCapacityDrops++; return 0; } DNSComboWriter* dc = new DNSComboWriter(question.c_str(), question.size(), g_now); dc->setSocket(fd); dc->setRemote(&fromaddr); dc->d_tcp=false; MT->makeThread(startDoResolve, (void*) dc); // deletes dc return 0; } void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var) { int len; char data[1500]; ComboAddress fromaddr; socklen_t addrlen=sizeof(fromaddr); if((len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen)) >= 0) { t_remotes->addRemote(fromaddr); if(t_allowFrom && !t_allowFrom->match(&fromaddr)) { if(!g_quiet) L<getTid()<<"] dropping UDP query from "<qr) { if(g_logCommonErrors) L< > > deferredAdd_t; deferredAdd_t deferredAdd; void makeTCPServerSockets() { int fd; vectorlocals; stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) throw AhuException("No local address specified"); for(vector::const_iterator i=locals.begin();i!=locals.end();++i) { ServiceTuple st; st.port=::arg().asNum("local-port"); parseService(*i, st); ComboAddress sin; memset((char *)&sin,0, sizeof(sin)); sin.sin4.sin_family = AF_INET; if(!IpToU32(st.host, (uint32_t*)&sin.sin4.sin_addr.s_addr)) { sin.sin6.sin6_family = AF_INET6; if(makeIPv6sockaddr(st.host, &sin.sin6) < 0) throw AhuException("Unable to resolve local address for TCP server on '"+ st.host +"'"); } fd=socket(sin.sin6.sin6_family, SOCK_STREAM, 0); Utility::setCloseOnExec(fd); if(fd<0) throw AhuException("Making a TCP server socket for resolver: "+stringerror()); int tmp=1; if(setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { L<= 0) { if(i==locals.begin()) L<locals; stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) throw AhuException("No local address specified"); if(::arg()["local-address"]=="0.0.0.0") { L<::const_iterator i=locals.begin();i!=locals.end();++i) { ServiceTuple st; st.port=::arg().asNum("local-port"); parseService(*i, st); ComboAddress sin; memset(&sin, 0, sizeof(sin)); sin.sin4.sin_family = AF_INET; if(!IpToU32(st.host.c_str() , (uint32_t*)&sin.sin4.sin_addr.s_addr)) { sin.sin6.sin6_family = AF_INET6; if(makeIPv6sockaddr(st.host, &sin.sin6) < 0) throw AhuException("Unable to resolve local address for UDP server on '"+ st.host +"'"); } int fd=socket(sin.sin4.sin_family, SOCK_DGRAM, 0); Utility::setCloseOnExec(fd); if(fd < 0) { throw AhuException("Making a UDP server socket for resolver: "+netstringerror()); } setSocketReceiveBuffer(fd, 200000); sin.sin4.sin_port = htons(st.port); int socklen=sin.sin4.sin_family==AF_INET ? sizeof(sin.sin4) : sizeof(sin.sin6); if (::bind(fd, (struct sockaddr *)&sin, socklen)<0) throw AhuException("Resolver binding to server socket on port "+ lexical_cast(st.port) +" for "+ st.host+": "+stringerror()); Utility::setNonBlocking(fd); deferredAdd.push_back(make_pair(fd, handleNewUDPQuestion)); g_listenSocketsAddresses[fd]=sin; // this is written to only from the startup thread, not from the workers if(sin.sin4.sin_family == AF_INET) L<cacheHits + t_RC->cacheMisses) && SyncRes::s_queries && SyncRes::s_outqueries) { // this only runs once thread 0 has had hits uint64_t cacheHits = broadcastAccFunction(pleaseGetCacheHits); uint64_t cacheMisses = broadcastAccFunction(pleaseGetCacheMisses); L<(pleaseGetCacheSize)<< " cache entries, "<< broadcastAccFunction(pleaseGetNegCacheSize)<<" negative entries, "<< (int)((cacheHits*100.0)/(cacheHits+cacheMisses))<<"% cache hits"<(pleaseGetThrottleSize) <<", ns speeds: " << broadcastAccFunction(pleaseGetNsSpeedsSize)<(pleaseGetConcurrentQueries)<<" queries running, "<(pleaseGetPacketCacheSize) << " packet cache entries, "<<(int)(100.0*broadcastAccFunction(pleaseGetPacketCacheHits)/SyncRes::s_queries) << "% packet cache hits"< (time_t)(5 + t_id)) { DTime dt; dt.setTimeval(now); t_RC->doPrune(); // this function is local to a thread, so fine anyhow t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries") / g_numThreads); pruneCollection(t_sstorage->negcache, ::arg().asNum("max-cache-entries") / (g_numThreads * 10), 200); if(!((cleanCounter++)%40)) { // this is a full scan! time_t limit=now.tv_sec-300; for(SyncRes::nsspeeds_t::iterator i = t_sstorage->nsSpeeds.begin() ; i!= t_sstorage->nsSpeeds.end(); ) if(i->second.stale(limit)) t_sstorage->nsSpeeds.erase(i++); else ++i; } // L< 1800) { doStats(); last_stat=time(0); } } if(now.tv_sec - last_rootupdate > 7200) { SyncRes sr(now); sr.setDoEDNS0(true); vector ret; sr.setNoCache(); int res=sr.beginResolve(".", QType(QType::NS), 1, ret); if(!res) { L<func = func; tmsg->wantAnswer = true; if(write(tps.writeToThread, &tmsg, sizeof(tmsg)) != sizeof(tmsg)) unixDie("write to thread pipe returned wrong size or error"); string* resp; if(read(tps.readFromThread, &resp, sizeof(resp)) != sizeof(resp)) unixDie("read from thread pipe returned wrong size or error"); if(resp) { // cerr <<"got response: " << *resp << endl; delete resp; } } } void distributeAsyncFunction(const pipefunc_t& func) { static unsigned int counter; unsigned int target = 1 + (++counter % (g_pipes.size()-1)); // cerr<<"Sending to: "<func = func; tmsg->wantAnswer = false; if(write(tps.writeToThread, &tmsg, sizeof(tmsg)) != sizeof(tmsg)) unixDie("write to thread pipe returned wrong size or error"); } void handlePipeRequest(int fd, FDMultiplexer::funcparam_t& var) { ThreadMSG* tmsg; if(read(fd, &tmsg, sizeof(tmsg)) != sizeof(tmsg)) { // fd == readToThread unixDie("read from thread pipe returned wrong size or error"); } void *resp = tmsg->func(); if(tmsg->wantAnswer) if(write(g_pipes[t_id].writeFromThread, &resp, sizeof(resp)) != sizeof(resp)) unixDie("write to thread pipe returned wrong size or error"); delete tmsg; } template void *voider(const boost::function& func) { return func(); } vector& operator+=(vector&a, const vector& b) { a.insert(a.end(), b.begin(), b.end()); return a; } template T broadcastAccFunction(const boost::function& func, bool skipSelf) { unsigned int n = 0; T ret=T(); BOOST_FOREACH(ThreadPipeSet& tps, g_pipes) { if(n++ == t_id) { if(!skipSelf) { T* resp = (T*)func(); // don't write to ourselves! if(resp) { //~ cerr <<"got direct: " << *resp << endl; ret += *resp; delete resp; } } continue; } ThreadMSG* tmsg = new ThreadMSG(); tmsg->func = boost::bind(voider, func); tmsg->wantAnswer = true; if(write(tps.writeToThread, &tmsg, sizeof(tmsg)) != sizeof(tmsg)) unixDie("write to thread pipe returned wrong size or error"); T* resp; if(read(tps.readFromThread, &resp, sizeof(resp)) != sizeof(resp)) unixDie("read from thread pipe returned wrong size or error"); if(resp) { //~ cerr <<"got response: " << *resp << endl; ret += *resp; delete resp; } } return ret; } template string broadcastAccFunction(const boost::function& fun, bool skipSelf); // explicit instantiation template uint64_t broadcastAccFunction(const boost::function& fun, bool skipSelf); // explicit instantiation template vector broadcastAccFunction(const boost::function *()>& fun, bool skipSelf); // explicit instantiation void handleRCC(int fd, FDMultiplexer::funcparam_t& var) { string remote; string msg=s_rcc.recv(&remote); RecursorControlParser rcp; RecursorControlParser::func_t* command; string answer=rcp.getAnswer(msg, &command); try { s_rcc.send(answer, &remote); command(); } catch(std::exception& e) { L<(&var); // cerr<<"handleTCPClientReadable called for fd "<inNeeded: "<inNeeded<<", "<sock->getHandle()< buffer(new char[pident->inNeeded]); int ret=recv(fd, buffer.get(), pident->inNeeded,0); if(ret > 0) { pident->inMSG.append(&buffer[0], &buffer[ret]); pident->inNeeded-=ret; if(!pident->inNeeded) { // cerr<<"Got entire load of "<inMSG.size()<<" bytes"<inMSG; t_fdm->removeReadFD(fd); MT->sendEvent(pid, &msg); } else { // cerr<<"Still have "<inNeeded<<" left to go"<removeReadFD(fd); // pident might now be invalid (it isn't, but still) string empty; MT->sendEvent(tmp, &empty); // this conveys error status } } void handleTCPClientWritable(int fd, FDMultiplexer::funcparam_t& var) { PacketID* pid=any_cast(&var); int ret=send(fd, pid->outMSG.c_str() + pid->outPos, pid->outMSG.size() - pid->outPos,0); if(ret > 0) { pid->outPos+=ret; if(pid->outPos==pid->outMSG.size()) { PacketID tmp=*pid; t_fdm->removeWriteFD(fd); MT->sendEvent(tmp, &tmp.outMSG); // send back what we sent to convey everything is ok } } else { // error or EOF PacketID tmp(*pid); t_fdm->removeWriteFD(fd); string sent; MT->sendEvent(tmp, &sent); // we convey error status by sending empty string } } // resend event to everybody chained onto it void doResends(MT_t::waiters_t::iterator& iter, PacketID resend, const string& content) { if(iter->key.chain.empty()) return; // cerr<<"doResends called!\n"; for(PacketID::chain_t::iterator i=iter->key.chain.begin(); i != iter->key.chain.end() ; ++i) { resend.fd=-1; resend.id=*i; // cerr<<"\tResending "<returnSocket(fd); string empty; MT_t::waiters_t::iterator iter=MT->d_waiters.find(pid); if(iter != MT->d_waiters.end()) doResends(iter, pid, empty); MT->sendEvent(pid, &empty); // this denotes error (does lookup again.. at least L1 will be hot) return; } dnsheader dh; memcpy(&dh, data, sizeof(dh)); PacketID pident; pident.remote=fromaddr; pident.id=dh.id; pident.fd=fd; if(!dh.qr) { L<d_waiters.find(pident); if(iter != MT->d_waiters.end()) { doResends(iter, pident, packet); } retryWithName: if(!MT->sendEvent(pident, &packet)) { // we do a full scan for outstanding queries on unexpected answers. not too bad since we only accept them on the right port number, which is hard enough to guess for(MT_t::waiters_t::iterator mthread=MT->d_waiters.begin(); mthread!=MT->d_waiters.end(); ++mthread) { if(pident.fd==mthread->key.fd && mthread->key.remote==pident.remote && mthread->key.type == pident.type && pdns_iequals(pident.domain, mthread->key.domain)) { mthread->key.nearMisses++; } // be a bit paranoid here since we're weakening our matching if(pident.domain.empty() && !mthread->key.domain.empty() && !pident.type && mthread->key.type && pident.id == mthread->key.id && mthread->key.remote == pident.remote) { // cerr<<"Empty response, rest matches though, sending to a waiter"<key.domain; pident.type = mthread->key.type; goto retryWithName; // note that this only passes on an error, lwres will still reject the packet } } g_stats.unexpectedCount++; // if we made it here, it really is an unexpected answer if(g_logCommonErrors) { L<d_waiters.size()<<" waiters"<= 0) { t_udpclientsocks->returnSocket(fd); } } FDMultiplexer* getMultiplexer() { FDMultiplexer* ret; for(FDMultiplexer::FDMultiplexermap_t::const_iterator i = FDMultiplexer::getMultiplexerMap().begin(); i != FDMultiplexer::getMultiplexerMap().end(); ++i) { try { ret=i->second(); return ret; } catch(FDMultiplexerException &fe) { L<reset(); L<(new RecursorLua(fname)); } } catch(std::exception& e) { L<::const_iterator begin, vector::const_iterator end) { if(begin != end) ::arg().set("lua-dns-script") = *begin; return broadcastAccFunction(doReloadLuaScript); } string* pleaseUseNewTraceRegex(const std::string& newRegex) try { if(newRegex.empty()) { t_traceRegex->reset(); return new string("unset\n"); } else { (*t_traceRegex) = shared_ptr(new Regex(newRegex)); return new string("ok\n"); } } catch(AhuException& ae) { return new string(ae.reason+"\n"); } string doTraceRegex(vector::const_iterator begin, vector::const_iterator end) { return broadcastAccFunction(boost::bind(pleaseUseNewTraceRegex, begin!=end ? *begin : "")); } void* recursorThread(void*); void* pleaseSupplantACLs(NetmaskGroup *ng) { t_allowFrom = ng; return 0; } int g_argc; char** g_argv; void parseACLs() { static bool l_initialized; if(l_initialized) { // only reload configuration file on second call string configname=::arg()["config-dir"]+"/recursor.conf"; cleanSlashes(configname); if(!::arg().preParseFile(configname.c_str(), "allow-from-file")) L<addMask(line); } L<size() <<" allow-from ranges from file '"<<::arg()["allow-from-file"]<<"' - overriding 'allow-from' setting"< ips; stringtok(ips, ::arg()["allow-from"], ", "); L<::const_iterator i = ips.begin(); i!= ips.end(); ++i) { allowFrom->addMask(*i); if(i!=ips.begin()) L<= 0) theL().setFacility(val); else L< ips; stringtok(ips, ::arg()["dont-query"], ", "); ips.push_back("0.0.0.0"); ips.push_back("::"); L<::const_iterator i = ips.begin(); i!= ips.end(); ++i) { g_dontQuery->addMask(*i); if(i!=ips.begin()) L< addrs; if(!::arg()["query-local-address6"].empty()) { SyncRes::s_doIPv6=true; L< 1 ? forks : -1); int newgid=0; if(!::arg()["setgid"].empty()) newgid=Utility::makeGidNumeric(::arg()["setgid"]); int newuid=0; if(!::arg()["setuid"].empty()) newuid=Utility::makeUidNumeric(::arg()["setuid"]); if (!::arg()["chroot"].empty()) { if (chroot(::arg()["chroot"].c_str())<0 || chdir("/") < 0) { L<domainmap = g_initialDomainMap; t_allowFrom = g_initialAllowFrom; t_udpclientsocks = new UDPClientSocks(); t_tcpClientCounts = new tcpClientCounts_t(); primeHints(); t_packetCache = new RecursorPacketCache(); L<(); try { if(!::arg()["lua-dns-script"].empty()) { *t_pdl = shared_ptr(new RecursorLua(::arg()["lua-dns-script"])); L<(); t_remotes = new RemoteKeeper(); t_remotes->remotes.resize(::arg().asNum("remotes-ringbuffer-entries") / g_numThreads); if(!t_remotes->remotes.empty()) memset(&t_remotes->remotes[0], 0, t_remotes->remotes.size() * sizeof(RemoteKeeper::remotes_t::value_type)); MT=new MTasker(::arg().asNum("stack-size")); PacketID pident; t_fdm=getMultiplexer(); if(!t_id) { if(::arg().mustDo("experimental-json-interface")) { L<getName() << "' multiplexer"<addReadFD(g_pipes[t_id].readToThread, handlePipeRequest); if(!g_weDistributeQueries || !t_id) // if we distribute queries, only t_id = 0 listens for(deferredAdd_t::const_iterator i=deferredAdd.begin(); i!=deferredAdd.end(); ++i) t_fdm->addReadFD(i->first, i->second); if(!t_id) { t_fdm->addReadFD(s_rcc.d_fd, handleRCC); // control channel } unsigned int maxTcpClients=::arg().asNum("max-tcp-clients"); bool listenOnTCP(true); counter=0; // used to periodically execute certain tasks for(;;) { while(MT->schedule(&g_now)); // MTasker letting the mthreads do their thing if(!(counter%500)) { MT->makeThread(houseKeeping, 0); } if(!(counter%55)) { typedef vector > expired_t; expired_t expired=t_fdm->getTimeouts(g_now); for(expired_t::iterator i=expired.begin() ; i != expired.end(); ++i) { shared_ptr conn=any_cast >(i->second); if(g_logCommonErrors) L<d_remote.toString() <removeReadFD(i->first); } } counter++; if(!t_id && statsWanted) { doStats(); } Utility::gettimeofday(&g_now, 0); t_fdm->run(&g_now); // 'run' updates g_now for us if(listenOnTCP) { if(TCPConnection::getCurrentConnections() > maxTcpClients) { // shutdown, too many connections for(tcpListenSockets_t::iterator i=g_tcpListenSockets.begin(); i != g_tcpListenSockets.end(); ++i) t_fdm->removeReadFD(*i); listenOnTCP=false; } } else { if(TCPConnection::getCurrentConnections() <= maxTcpClients) { // reenable for(tcpListenSockets_t::iterator i=g_tcpListenSockets.begin(); i != g_tcpListenSockets.end(); ++i) t_fdm->addReadFD(*i, handleNewTCPQuestion); listenOnTCP=true; } } } } catch(AhuException &ae) { L<start( argc, argv, ::arg().mustDo( "ntservice" )); #endif } catch(AhuException &ae) { L< #include #include #include #include #include #include "anadns.hh" #include "namespaces.hh" #include "namespaces.hh" StatBag S; struct Entry { uint32_t ip; uint16_t port; uint16_t id; bool operator<(const struct Entry& rhs) const { return tie(ip, port, id) < tie(rhs.ip, rhs.port, rhs.id); } }; typedef map emap_t; emap_t ecount; int main(int argc, char** argv) try { cout << "begin;"; for(int n=1 ; n < argc; ++n) { PcapPacketReader pr(argv[n]); Entry entry; while(pr.getUDPPacket()) { if(ntohs(pr.d_udp->uh_dport)==53 && pr.d_len > 12) { try { dnsheader* dh= (dnsheader*) pr.d_payload; if(dh->rd || dh->qr) continue; MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); memcpy(&entry.ip, &pr.d_ip->ip_src, 4); entry.port = pr.d_udp->uh_sport; entry.id=dh->id; // ecount[entry]++; string::size_type pos = 0; for(pos = 0; pos < mdp.d_qname.size() ; ++pos ) { char c=mdp.d_qname[pos] ; if(!isalnum(c) && c!='-' && c!='.') break; } if(pos ==mdp.d_qname.size()) { cout << "insert into dnsstats (source, port, id, query, qtype, tstampSec, tstampUsec, arcount) values ('" << U32ToIP(ntohl(entry.ip)) <<"', "<< ntohs(entry.port) <<", "<< ntohs(dh->id); cout <<", '"<arcount) <<");\n"; } } catch(MOADNSException& mde) { // cerr<<"error parsing packet: "<second > 1) cout << U32ToIP(ntohl(i->first.ip)) <<":"<first.port)<<" -> "<second < #include #include #include #include #include #include #include #include "dns.hh" #include "dnsbackend.hh" #include "dnspacket.hh" #include "nameserver.hh" #include "distributor.hh" #include "logger.hh" #include "arguments.hh" #include "statbag.hh" #include "namespaces.hh" extern StatBag S; /** \mainpage PowerDNS is a very versatile nameserver that can answer questions from different backends. To implement your own backend, see the documentation for the DNSBackend class. \section copyright Copyright and License PowerDNS is (C) 2001-2008 PowerDNS.COM BV. It is distributed according to the terms of the General Public License version 2. \section overview High level overview The Distributor contains a configurable number of PacketHandler instances, each in its own thread, for connection pooling. PacketHandler instances are recycled of they let escape an AhuException. The PacketHandler implements the RFC1034 algorithm and converts question packets into DNSBackend queries. A DNSBackend is an entity that returns DNSResourceRecord objects in return to explicit questions for domains with a specified QType PowerDNS uses the UeberBackend as its DNSBackend. The UeberBackend by default has no DNSBackends within itself, those are loaded using the pdns_control tool. This way DNSBackend implementations can be kept completely separate (but they often aren't).s If one or more DNSBackends are loaded, the UeberBackend fields the queries to all of them until one answers. \section TCP TCP Operations The TCP operation runs within a single thread called tcpreceiver(), that also queries the PacketHandler. \section Cache Caching On its own, this setup is not suitable for high performance operations. A single DNS query can turn into many DNSBackend questions, each taking many milliseconds to complete. This is why the qthread() first checks the PacketCache to see if an answer is known to a packet asking this question. If so, the entire Distributor is shunted, and the answer is sent back *directly*, within a few microseconds. \section misc Miscellaneous Configuration details are available via the ArgvMap instance arg. Statistics are created by making calls to the StatBag object called S. These statistics are made available via the UeberBackend on the same socket that is used for dynamic module commands. \section Main Main The main() of PowerDNS can be found in receiver.cc - start reading there for further insights into the operation of the nameserver */ #ifdef IP_PKTINFO #define GEN_IP_PKTINFO IP_PKTINFO #endif #ifdef IP_RECVDSTADDR #define GEN_IP_PKTINFO IP_RECVDSTADDR #endif vector g_localaddresses; // not static, our unit tests need to poke this void UDPNameserver::bindIPv4() { vectorlocals; stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) throw AhuException("No local address specified"); int s; for(vector::const_iterator i=locals.begin();i!=locals.end();++i) { string localname(*i); ComboAddress locala; s=socket(AF_INET,SOCK_DGRAM,0); if(s<0) throw AhuException("Unable to acquire a UDP socket: "+string(strerror(errno))); Utility::setCloseOnExec(s); if(!Utility::setNonBlocking(s)) throw AhuException("Unable to set UDP socket to non-blocking: "+stringerror()); memset(&locala,0,sizeof(locala)); locala.sin4.sin_family=AF_INET; if(localname=="0.0.0.0") { int val=1; setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val)); locala.sin4.sin_addr.s_addr = INADDR_ANY; } else { struct hostent *h=0; h=gethostbyname(localname.c_str()); if(!h) throw AhuException("Unable to resolve local address"); locala.sin4.sin_addr.s_addr=*(int*)h->h_addr; } locala.sin4.sin_port=htons(::arg().asNum("local-port")); g_localaddresses.push_back(locala); if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) { L<(ntohs(locala.sin4.sin_port))+": "< locals; stringtok(locals,::arg()["local-ipv6"]," ,"); if(locals.empty()) return; int s; for(vector::const_iterator i=locals.begin();i!=locals.end();++i) { string localname(*i); s=socket(AF_INET6,SOCK_DGRAM,0); if(s<0) throw AhuException("Unable to acquire a UDPv6 socket: "+string(strerror(errno))); Utility::setCloseOnExec(s); if(!Utility::setNonBlocking(s)) throw AhuException("Unable to set UDPv6 socket to non-blocking: "+stringerror()); ComboAddress locala(localname, ::arg().asNum("local-port")); if(IsAnyAddress(locala)) { int val=1; setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val)); // linux supports this, so why not - might fail on other systems setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)); // if this fails, we report an error in tcpreceiver too } g_localaddresses.push_back(locala); if(::bind(s, (sockaddr*)&locala, sizeof(locala))<0) { L<getString(); struct msghdr msgh; struct cmsghdr *cmsg; struct iovec iov; char cbuf[256]; /* Set up iov and msgh structures. */ memset(&msgh, 0, sizeof(struct msghdr)); iov.iov_base = (void*)buffer.c_str(); iov.iov_len = buffer.length(); msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_name = (struct sockaddr*)&p->d_remote; msgh.msg_namelen = p->d_remote.getSocklen(); if(p->d_anyLocal) { if(p->d_anyLocal->sin4.sin_family == AF_INET6) { struct in6_pktinfo *pkt; msgh.msg_control = cbuf; msgh.msg_controllen = CMSG_SPACE(sizeof(*pkt)); cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_level = IPPROTO_IPV6; cmsg->cmsg_type = IPV6_PKTINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(*pkt)); pkt = (struct in6_pktinfo *) CMSG_DATA(cmsg); memset(pkt, 0, sizeof(*pkt)); pkt->ipi6_addr = p->d_anyLocal->sin6.sin6_addr; msgh.msg_controllen = cmsg->cmsg_len; // makes valgrind happy and is slightly better style } else { #ifdef IP_PKTINFO struct in_pktinfo *pkt; msgh.msg_control = cbuf; msgh.msg_controllen = CMSG_SPACE(sizeof(*pkt)); cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_level = IPPROTO_IP; cmsg->cmsg_type = IP_PKTINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(*pkt)); pkt = (struct in_pktinfo *) CMSG_DATA(cmsg); memset(pkt, 0, sizeof(*pkt)); pkt->ipi_spec_dst = p->d_anyLocal->sin4.sin_addr; #endif #ifdef IP_SENDSRCADDR struct in_addr *in; msgh.msg_control = cbuf; msgh.msg_controllen = CMSG_SPACE(sizeof(*in)); cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_level = IPPROTO_IP; cmsg->cmsg_type = IP_SENDSRCADDR; cmsg->cmsg_len = CMSG_LEN(sizeof(*in)); in = (struct in_addr *) CMSG_DATA(cmsg); *in = p->d_anyLocal->sin4.sin_addr; #endif msgh.msg_controllen = cmsg->cmsg_len; } } DLOG(L<getRemote() <<" ("<< buffer.length()<<" octets)"< p->getMaxReplyLen()) { cerr<<"Weird, trying to send a message that needs truncation, "<< buffer.length()<<" > "<getMaxReplyLen()<getSocket(), &msgh, 0) < 0) L<cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_PKTINFO)) { struct in_pktinfo *i = (struct in_pktinfo *) CMSG_DATA(cmsg); destination->sin4.sin_addr = i->ipi_addr; destination->sin4.sin_family = AF_INET; return true; } #endif #ifdef IP_RECVDSTADDR if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_RECVDSTADDR)) { struct in_addr *i = (struct in_addr *) CMSG_DATA(cmsg); destination->sin4.sin_addr = *i; destination->sin4.sin_family = AF_INET; return true; } #endif if ((cmsg->cmsg_level == IPPROTO_IPV6) && (cmsg->cmsg_type == IPV6_PKTINFO)) { struct in6_pktinfo *i = (struct in6_pktinfo *) CMSG_DATA(cmsg); destination->sin6.sin6_addr = i->ipi6_addr; destination->sin4.sin_family = AF_INET6; return true; } } return false; } DNSPacket *UDPNameserver::receive(DNSPacket *prefilled) { ComboAddress remote; extern StatBag S; int len=-1; char mesg[512]; Utility::sock_t sock=-1; struct msghdr msgh; struct iovec iov; char cbuf[256]; iov.iov_base = mesg; iov.iov_len = sizeof(mesg); memset(&msgh, 0, sizeof(struct msghdr)); msgh.msg_control = cbuf; msgh.msg_controllen = sizeof(cbuf); msgh.msg_name = &remote; msgh.msg_namelen = sizeof(remote); msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_flags = 0; int err; vector rfds= d_rfds; BOOST_FOREACH(struct pollfd &pfd, rfds) { pfd.events = POLLIN; pfd.revents = 0; } err = poll(&rfds[0], rfds.size(), -1); if(err < 0) unixDie("Unable to poll for new UDP events"); BOOST_FOREACH(struct pollfd &pfd, rfds) { if(pfd.revents & POLLIN) { sock=pfd.fd; len=0; if((len=recvmsg(sock, &msgh, 0)) < 0 ) { if(errno != EAGAIN) L<d_dt.set(); // timing packet->setSocket(sock); packet->setRemote(&remote); ComboAddress dest; if(HarvestDestinationAddress(&msgh, &dest)) { // cerr<<"Setting d_anyLocal to '"<d_anyLocal = dest; } if(packet->parse(mesg, len)<0) { S.inc("corrupt-packets"); S.ringAccount("remotes-corrupt", packet->getRemote()); if(!prefilled) delete packet; return 0; // unable to parse } return packet; } pdns-3.3/pdns/mtasker.hh0000644000014601777760000000705612136555572016541 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2009 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MTASKER_HH #define MTASKER_HH #ifdef WIN32 # include "win32_mtasker.hh" #else #include #include #include #include #include #include #include #include #include #include "namespaces.hh" using namespace ::boost::multi_index; struct KeyTag {}; //! The main MTasker class /** The main MTasker class. See the main page for more information. \param EventKey Type of the key with which events are to be identified. Defaults to int. \param EventVal Type of the content or value of an event. Defaults to int. Cannot be set to void. \note The EventKey needs to have an operator< defined because it is used as the key of an associative array */ template class MTasker { private: ucontext_t d_kernel; std::queue d_runQueue; std::queue d_zombiesQueue; struct ThreadInfo { ucontext_t* context; char* startOfStack; char* highestStackSeen; }; typedef std::map mthreads_t; mthreads_t d_threads; int d_tid; int d_maxtid; size_t d_stacksize; EventVal d_waitval; enum waitstatusenum {Error=-1,TimeOut=0,Answer} d_waitstatus; public: struct Waiter { EventKey key; ucontext_t *context; struct timeval ttd; int tid; }; typedef multi_index_container< Waiter, indexed_by < ordered_unique >, ordered_non_unique, member > > > waiters_t; waiters_t d_waiters; //! Constructor /** Constructor with a small default stacksize. If any of your threads exceeds this stack, your application will crash. This limit applies solely to the stack, the heap is not limited in any way. If threads need to allocate a lot of data, the use of new/delete is suggested. */ MTasker(size_t stacksize=8192) : d_stacksize(stacksize) { d_maxtid=0; } typedef void tfunc_t(void *); //!< type of the pointer that starts a thread int waitEvent(EventKey &key, EventVal *val=0, unsigned int timeoutMsec=0, struct timeval* now=0); void yield(); int sendEvent(const EventKey& key, const EventVal* val=0); void getEvents(std::vector& events); void makeThread(tfunc_t *start, void* val); bool schedule(struct timeval* now=0); bool noProcesses(); unsigned int numProcesses(); int getTid(); unsigned int getMaxStackUsage(); private: static void threadWrapper(uint32_t self1, uint32_t self2, tfunc_t *tf, int tid, uint32_t val1, uint32_t val2); EventKey d_eventkey; // for waitEvent, contains exact key it was awoken for }; #include "mtasker.cc" #endif // WIN32 #endif // MTASKER_HH pdns-3.3/pdns/dnsbackend.cc0000644000014601777760000002134612145420164017137 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include "dnsbackend.hh" #include "arguments.hh" #include "ueberbackend.hh" #include "logger.hh" #include #include "dnspacket.hh" #include "dns.hh" string DNSBackend::getRemote(DNSPacket *p) { return p->getRemote(); } bool DNSBackend::getRemote(DNSPacket *p, struct sockaddr *sa, Utility::socklen_t *len) { if(p->d_remote.getSocklen() < *len) return false; *len=p->d_remote.getSocklen(); memcpy(sa,&p->d_remote,*len); return true; } void DNSBackend::setArgPrefix(const string &prefix) { d_prefix=prefix; } bool DNSBackend::mustDo(const string &key) { return arg().mustDo(d_prefix+"-"+key); } const string &DNSBackend::getArg(const string &key) { return arg()[d_prefix+"-"+key]; } int DNSBackend::getArgAsNum(const string &key) { return arg().asNum(d_prefix+"-"+key); } void BackendFactory::declare(const string &suffix, const string ¶m, const string &help, const string &value) { string fullname=d_name+suffix+"-"+param; arg().set(fullname,help)=value; } const string &BackendFactory::getName() const { return d_name; } BackendMakerClass &BackendMakers() { static BackendMakerClass bmc; return bmc; } void BackendMakerClass::report(BackendFactory *bf) { d_repository[bf->getName()]=bf; } vector BackendMakerClass::getModules() { load_all(); vector ret; // copy(d_repository.begin(), d_repository.end(),back_inserter(ret)); for(d_repository_t::const_iterator i=d_repository.begin();i!=d_repository.end();++i) ret.push_back(i->first); return ret; } void BackendMakerClass::load_all() { // TODO: Implement this? #ifndef WIN32 DIR *dir=opendir(arg()["module-dir"].c_str()); if(!dir) { L<d_name,"lib",3) && strlen(entry->d_name)>13 && !strcmp(entry->d_name+strlen(entry->d_name)-10,"backend.so")) load(entry->d_name); } closedir(dir); #endif // WIN32 } void BackendMakerClass::load(const string &module) { int res; if(module.find(".")==string::npos) res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so"); else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path res=UeberBackend::loadmodule(module); else res=UeberBackend::loadmodule(arg()["module-dir"]+"/"+module); if(res==false) { L< parts; stringtok(parts,instr,", "); for(vector::const_iterator i=parts.begin();i!=parts.end();++i) { const string &part=*i; string module, name; vectorpparts; stringtok(pparts,part,": "); module=pparts[0]; if(pparts.size()>1) name="-"+pparts[1]; if(d_repository.find(module)==d_repository.end()) { // this is *so* userfriendly load(module); if(d_repository.find(module)==d_repository.end()) throw ArgException("Trying to launch unknown backend '"+module+"'"); } d_repository[module]->declareArguments(name); d_instances.push_back(make_pair(module,name)); } } int BackendMakerClass::numLauncheable() { return d_instances.size(); } vectorBackendMakerClass::all(bool metadataOnly) { vectorret; if(d_instances.empty()) throw AhuException("No database backends configured for launch, unable to function"); try { for(vector >::const_iterator i=d_instances.begin();i!=d_instances.end();++i) { DNSBackend *made; if(metadataOnly) made = d_repository[i->first]->makeMetadataOnly(i->second); else made = d_repository[i->first]->make(i->second); if(!made) throw AhuException("Unable to launch backend '"+i->first+"'"); ret.push_back(made); } } catch(AhuException &ae) { L<::const_iterator i=ret.begin();i!=ret.end();++i) delete *i; throw; } catch(...) { // and cleanup L<::const_iterator i=ret.begin();i!=ret.end();++i) delete *i; throw; } return ret; } /** getSOA() is a function that is called to get the SOA of a domain. Callers should ONLY use getSOA() and no perform a lookup() themselves as backends may decide to special case the SOA record. Returns false if there is definitely no SOA for the domain. May throw a DBException to indicate that the backend is currently unable to supply an answer. WARNING: This function *may* fill out the db attribute of the SOAData, but then again, it may not! If you find a zero in there, you may have been handed a non-live and cached answer, in which case you need to perform a getDomainInfo call! \param domain Domain we want to get the SOA details of \param sd SOAData which is filled with the SOA details */ bool DNSBackend::getSOA(const string &domain, SOAData &sd, DNSPacket *p) { this->lookup(QType(QType::SOA),domain,p); DNSResourceRecord rr; rr.auth = true; int hits=0; while(this->get(rr)) { hits++; fillSOAData(rr.content, sd); sd.domain_id=rr.domain_id; sd.ttl=rr.ttl; sd.scopeMask = rr.scopeMask; } if(!hits) return false; sd.qname = domain; if(sd.nameserver.empty()) sd.nameserver=arg()["default-soa-name"]; if(sd.hostmaster.empty()) { if (!arg().isEmpty("default-soa-mail")) { sd.hostmaster=arg()["default-soa-mail"]; attodot(sd.hostmaster); } else sd.hostmaster="hostmaster."+domain; } if(!sd.serial) { // magic time! DLOG(L<getBeforeAndAfterNamesAbsolute(id, lcqname, dnc, before, after); before=dotConcat(labelReverse(before), lczonename); after=dotConcat(labelReverse(after), lczonename); return ret; } /** * Calculates a SOA serial for the zone and stores it in the third * argument. Returns false if calculation is not possible for some * reason (in this case, the third argument is not inspected). If it * returns true, the value returned in the third argument will be set * as the SOA serial. * * \param domain The name of the domain * \param sd Information about the SOA record already available * \param serial Output parameter. Only inspected when we return true */ bool DNSBackend::calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial) { // we do this by listing the domain and taking the maximum last modified timestamp DNSResourceRecord i; time_t newest=0; if(!(this->list(domain, sd.domain_id))) { DLOG(L<get(i)) { if(i.last_modified>newest) newest=i.last_modified; } serial=newest; // +arg().asNum("soa-serial-offset"); return true; } pdns-3.3/pdns/json.hh0000644000014601777760000000217012136555572016034 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once // it is 2012, deal with it #include #include #include "rapidjson/document.h" std::string returnJSONObject(const std::map& items); std::string makeLogGrepJSON(std::map& varmap, const std::string& fname, const std::string& prefix=""); std::string makeStringFromDocument(const rapidjson::Document& doc); pdns-3.3/pdns/dynmessenger.cc0000644000014601777760000000640112136555572017555 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dynmessenger.hh" #include #include #include #include #include #include #include DynMessenger::DynMessenger(const string &localdir, const string &fname) { d_s=socket(AF_UNIX,SOCK_STREAM,0); Utility::setCloseOnExec(d_s); if(d_s<0) { throw AhuException(string("socket")+strerror(errno)); } memset(&d_local,0,sizeof(d_local)); string localname=localdir; localname+="/lsockXXXXXX"; d_local.sun_family=AF_UNIX; strcpy(d_local.sun_path,localname.c_str()); if(mkstemp(d_local.sun_path)<0) throw AhuException("Unable to generate local temporary file: "+string(strerror(errno))); unlink(d_local.sun_path); if(bind(d_s, (sockaddr*)&d_local,sizeof(d_local))<0) { unlink(d_local.sun_path); throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno))); } if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply! unlink(d_local.sun_path); perror("fchmod"); exit(1); } memset(&d_remote,0,sizeof(d_remote)); d_remote.sun_family=AF_UNIX; strcpy(d_remote.sun_path,fname.c_str()); if(connect(d_s,(sockaddr*)&d_remote,sizeof(d_remote))<0) { unlink(d_local.sun_path); throw AhuException("Unable to connect to remote '"+fname+"': "+string(strerror(errno))); } } DynMessenger::DynMessenger(const ComboAddress& remote, const string &secret) { *d_local.sun_path=0; d_s=socket(AF_INET, SOCK_STREAM,0); Utility::setCloseOnExec(d_s); if(d_s<0) { throw AhuException(string("socket")+strerror(errno)); } if(connect(d_s, (sockaddr*)&remote, remote.getSocklen())<0) { close(d_s); throw AhuException("Unable to connect to remote '"+remote.toStringWithPort()+"': "+string(strerror(errno))); } string login=secret+"\n"; writen2(d_s, login); } DynMessenger::~DynMessenger() { if(*d_local.sun_path && unlink(d_local.sun_path)<0) cerr<<"Warning: unable to unlink local unix domain endpoint: "< #include "ahuexception.hh" #include "arguments.hh" #include "config.h" #include "namespaces.hh" #ifndef RECURSOR #include "statbag.hh" StatBag S; #endif ArgvMap &arg() { static ArgvMap arg; return arg; } static void initArguments(int argc, char** argv) { arg().set("config-dir","Location of configuration directory (recursor.conf)")=SYSCONFDIR; arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR; arg().set("process","When controlling multiple recursors, the target process number")=""; arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5"; arg().setCmd("help","Provide this helpful message"); arg().laxParse(argc,argv); if(arg().getCommands().empty() || arg().mustDo("help")) { cerr<<"syntax: rec_control [options] command, options as below: "<&commands=arg().getCommands(); string command; for(unsigned int i=0; i< commands.size(); ++i) { if(i>0) command+=" "; command+=commands[i]; } rccS.send(command); string receive=rccS.recv(0, arg().asNum("timeout")); cout< #include "iputils.hh" using namespace boost; BOOST_AUTO_TEST_SUITE(iputils_hh) BOOST_AUTO_TEST_CASE(test_ComboAddress) { ComboAddress local("127.0.0.1", 53); BOOST_CHECK(local==local); BOOST_CHECK_EQUAL(local.sin4.sin_family, AF_INET); BOOST_CHECK_EQUAL(local.sin4.sin_port, htons(53)); BOOST_CHECK_EQUAL(local.sin4.sin_addr.s_addr, htonl(0x7f000001UL)); ComboAddress remote("130.161.33.15", 53); BOOST_CHECK(!(local == remote)); } BOOST_AUTO_TEST_CASE(test_Netmask) { ComboAddress local("127.0.0.1", 53); ComboAddress remote("130.161.252.29", 53); Netmask nm("127.0.0.1/24"); BOOST_CHECK(nm.match(local)); BOOST_CHECK(!nm.match(remote)); Netmask nm6("fe80::92fb:a6ff:fe4a:51da/64"); BOOST_CHECK(nm6.match("fe80::92fb:a6ff:fe4a:51db")); BOOST_CHECK(!nm6.match("fe81::92fb:a6ff:fe4a:51db")); Netmask nmp("130.161.252.29/32"); BOOST_CHECK(nmp.match(remote)); Netmask nmp6("fe80::92fb:a6ff:fe4a:51da/128"); BOOST_CHECK(nmp6.match("fe80::92fb:a6ff:fe4a:51da")); BOOST_CHECK(!nmp6.match("fe81::92fb:a6ff:fe4a:51db")); Netmask all("0.0.0.0/0"); BOOST_CHECK(all.match(local) && all.match(remote)); Netmask all6("::/0"); BOOST_CHECK(all6.match("::1") && all6.match("fe80::92fb:a6ff:fe4a:51da")); } BOOST_AUTO_TEST_CASE(test_NetmaskGroup) { NetmaskGroup ng; ng.addMask("127.0.0.0/8"); ng.addMask("10.0.0.0/24"); BOOST_CHECK(ng.match(ComboAddress("127.0.0.1"))); BOOST_CHECK(ng.match(ComboAddress("10.0.0.3"))); BOOST_CHECK(!ng.match(ComboAddress("128.1.2.3"))); BOOST_CHECK(!ng.match(ComboAddress("10.0.1.0"))); BOOST_CHECK(!ng.match(ComboAddress("::1"))); ng.addMask("::1"); BOOST_CHECK(ng.match(ComboAddress("::1"))); BOOST_CHECK(!ng.match(ComboAddress("::2"))); ng.addMask("fe80::/16"); BOOST_CHECK(ng.match(ComboAddress("fe80::1"))); BOOST_CHECK(!ng.match(ComboAddress("fe81::1"))); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/dns_random.hh0000644000014601777760000000021512136555572017205 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_DNS_RANDOM #define PDNS_DNS_RANDOM void dns_random_init(const char data[16]); unsigned int dns_random(unsigned int n); #endif pdns-3.3/pdns/docs/0000755000014601777760000000000012165464055015467 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/docs/dnswasher.80000644000014601777760000000123412136555572017561 0ustar00jenkinsnogroup00000000000000.TH DNSWASHER 8 "September 2012" "PowerDNS" .SH NAME dnswasher \- A PowerDNS nameserver debugging tool .SH SYNOPSIS .B dnswasher \fI[infile]\fR \fI[outfile]\fR .SH DESCRIPTION dnswasher takes an \fIinfile\fR in PCAP format and writtes out \fIoutfile\fR also in PCAP format. It copies all network traffic found in \fIinfile\fR to \fIoutfile\fR except for non DNS traffic. This might be handy when creating bug reports or test cases for DNS software e.g. PowerDNS. .SH OPTIONS None. .SH SEE ALSO pcap(3PCAP), tcpdump(8) .SH AUTHORS This manpage was written by Joerg Jungermann (jj+debian At borkum.net) for the Debian Project and the PowerDNS versatile DNS server. pdns-3.3/pdns/docs/pdnssec.80000644000014601777760000000671112136555572017227 0ustar00jenkinsnogroup00000000000000.TH PDNSSEC 8 "November 2011" "PowerDNS" .SH NAME pdnssec \- PowerDNSSEC command and control .SH SYNOPSIS .B pdnssec \fI[options]\fR command .SH DESCRIPTION \fIpdnssec\fR is a powerful command that is the operator-friendly gateway into PowerDNSSEC configuration. Behind the scenes, \fIpdnssec\fR manipulates a PowerDNS backend database, which also means that for many databases, \fIpdnssec\fR can be run remotely, and can configure key material on different servers. .SH OPTIONS A summary of options is included below. .TP .B \-h [ \-\-help ] .br Show summary of options. .TP .B \-v [ \-\-verbose ] .br Be more verbose. .TP .B \-\-force .br force an action .TP .B \-\-config\-name arg .br Virtual configuration name .TP .B \-\-config\-dir arg (\=/etc/powerdns) .br Location of pdns.conf .TP .B \-\-commands arg .br Commands given as an argument .SH COMMANDS .TP .B activate\-zone\-key ZONE KEY\-ID Activate a key with id KEY-ID within a zone called ZONE. .TP .B add\-zone\-key ZONE [zsk|ksk] [bits] [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384] Create a new key for zone ZONE, and make it a KSK or a ZSK, with the specified algorithm. .TP .B check\-zone ZONE Check a zone for correctness .TP .B deactivate\-zone\-key ZONE KEY\-ID Deactivate a key with id KEY-ID within a zone called ZONE. .TP .B disable\-dnssec ZONE Deactivate all keys and unset PRESIGNED in ZONE .TP .B export\-zone\-dnskey ZONE KEY\-ID Export to standard output DNSKEY and DS of key with key id KEY-ID within zone called ZONE. .TP .B export\-zone\-key ZONE KEY\-ID Export to standard output full (private) key with key id KEY-ID within zone called ZONE. The format used is compatible with BIND and NSD/LDNS. .TP .B hash\-zone\-record ZONE RNAME This convenience command hashes the name 'recordname' according to the NSEC3 settings of ZONE. Refuses to hash for zones with no NSEC3 settings. .TP .B import\-zone\-key ZONE FILE [ksk|zsk] Import from 'filename' a full (private) key for zone called ZONE. The format used is compatible with BIND and NSD/LDNS. KSK or ZSK specifies the flags this key should have on import. .TP .B rectify\-zone ZONE Calculates the 'ordername' and 'auth' fields for a zone called ZONE so they comply with DNSSEC settings. Can be used to fix up migrated data. Can always safely be run, it does no harm. .TP .B remove\-zone\-key ZONE KEY\-ID Remove a key with id KEY-ID from a zone called ZONE. .TP .B secure\-zone ZONE Configures a zone called ZONE with reasonable DNSSEC settings. You should manually run 'pdnssec rectify-zone' afterwards. .TP .B set\-nsec3 ZONE 'params' [narrow] Sets NSEC3 parameters for this zone. A sample commandline is: "pdnssec set-nsec3 powerdnssec.org '1 1 1 ab' narrow". The NSEC3 parameters must be quoted on the command line. .br .B WARNING: .br If running in RSASHA1 mode (algorithm 5 or 7), switching from NSEC to NSEC3 will require a DS update at the parent zone! .TP .B set\-presigned ZONE Switches zone to presigned operation, utilizing in-zone RRSIGs. .TP .B show\-zone ZONE Shows all DNSSEC related settings of a zone called ZONE. .TP .B unset\-nsec3 ZONE Converts a zone to NSEC operations. .br .B WARNING: .br If running in RSASHA1 mode (algorithm 5 or 7), switching from NSEC to NSEC3 will require a DS update at the parent zone! .TP .B unset\-presigned ZONE Disables presigned operation for ZONE. .SH AUTHOR This manual page was written by Matthijs Möhlmann for the Debian Project (but may be used by others) .SH SEE ALSO .BR pdns_server (8), pdns_control (8) pdns-3.3/pdns/docs/pdns_server.80000644000014601777760000000156412165345731020117 0ustar00jenkinsnogroup00000000000000.TH PDNS_SERVER 8 "December 2002" "PowerDNS" .SH NAME pdns_server \- The PowerDNS nameserver .SH SYNOPSIS .B pdns_server [options] .SH DESCRIPTION \fB .SH OPTIONS .TP .B \-\-daemon=\fIyes|no\fR Indicate if the server should run in the background as a real daemon, or in the foreground. .TP .B \-\-guardian=\fIyes|no\fR Run \fBpdns_server\fR inside a guardian. This guardian monitors the performance of the inner \fBpdns_server\fR instance. It is also this guardian that \fBpdns_control\fR talks to. .TP .B \-\-control\-console Run the server in a special monitor mode. This enables detailed logging and exposes the raw control socket. .TP .B \-\-loglevel=\fI\fR Set the logging level. .TP .B \-\-help To view more options that are available use this option. .SH FILES .TP .I Control socket used to communicate with \fBpdns_server\fR. .SH SEE ALSO .BR pdns_control (8) pdns-3.3/pdns/docs/zone2sql.80000644000014601777760000000425112136555572017342 0ustar00jenkinsnogroup00000000000000.TH ZONE2SQL 8 "December 2002" "PowerDNS" .SH NAME zone2sql \- Convert ISC Bind zones to SQL .SH SYNOPSIS .B zone2sql [OPTIONS] .SH DESCRIPTION \fBZone2sql\fR parses Bind \fInamed.conf\fR files and zonefiles and outputs SQL on standard out, which can then be fed to your database. .PP \fBzone2sql\fR understands the Bind master file extension '$GENERATE' and will also honour '$ORIGIN' and '$TTL'. .PP For backends supporting slave operation (currently only the PostgreSQL backend), there is also an option to keep slave zones as slaves, and not convert them to native operation. .PP By default, zone2sql outputs code suitable for the mysqlbackend, but it can also generate SQL for the Generic PostgreSQL and Oracle backends. .SH OPTIONS Input options: .TP .B \-\-named-conf=\fI\fR Read \fI\fR to get the bind configuration .TP .B \-\-zone=\fI\fR Parse only this zone file. Conflicts with \fB\-\-named-conf\fR parameter. .TP .B \-\-zone-name=\fI\fR When parsing a single zone without $ORIGIN statement, set this as the zone name. .PP Output options: .TP .B \-\-bare Output in a bare format, suitable for further parsing. The output is formatted as follows: .RS .nf domain_id'qname''qtype''content'priottl .fi .RE .TP .B \-\-gmysql Output in format suitable for the default configuration of the Generic MySQL backend. .TP .B \-\-gpgsql Output in format suitable for the default configuration of the Generic PostgreSQL backend. .TP .B \-\-mysql Output in format suitable for the default configuration of the MySQL backend (the default output format). .TP .B \-\-oracle Output in format suitable for the default configuration of the Generic Oracle backend. .TP .B \-\-transactions For Oracle and PostgreSQL output, wrap each domain in a transaction for higher speed and integrity. .PP Other options: .TP .B \-\-slave Maintain slave status of zones listed in named.conf as being slaves. The default behaviour is to convert all zones to native operation. .TP .B \-\-on\-error\-resume\-next Ignore missing files during parsing. Dangerous. .TP .B \-\-help List all options .TP .B \-\-verbose Be verbose during conversion. .SH SEE ALSO .BR pdns_server (8) pdns-3.3/pdns/docs/pdns_control.80000644000014601777760000000454212136555572020274 0ustar00jenkinsnogroup00000000000000.TH PDNS_CONTROL 8 "December 2002" "PowerDNS" .SH NAME pdns_control \- Control the pDNS nameserver .SH SYNOPSIS .B pdns_control \fI[options]\fR command .SH DESCRIPTION \fBpdns_control\fR is used to send commands to a running pDNS nameserver. .SH OPTIONS A summary of options is included below. .TP .B \-\-help .br Show summary of options. .TP .B \-\-chroot\=... .br Where PowerDNS is chrooted .TP .B \-\-config\-dir\=... .br Location of configuration directory (pdns.conf) .TP .B \-\-config\-name\=... .br Name of this virtual configuration - will rename the binary image .TP .B \-\-remote\-address\=... .br Remote address to query .TP .B \-\-remote\-port\=... .br Remote port to query .TP .B \-\-secret\=... .br Secret needed to connect to remote PowerDNS .TP .B \-\-socket\-dir\=... Where the controlsocket will live .SH COMMANDS .TP .B ccounts Show the content of the cache .TP .B notify \fI\fR Adds a domain to the notification list, causing PDNS to send out notifications to the nameservers of a domain. Can be used if a slave missed previous notifications or is generally hard of hearing. .TP .B notify-host \fI\fR \fI\fR Same as above but with operator specified IP address as destination, to be used if you know better than PowerDNS. .TP .B cycle Restart the nameserver so it reloads its configuration. .TP .B ping Check if the server is alive. .TP .B purge \fI[]\fR Purge entries from the packet cache. If the record name ends with a dollar ($) all entries that end with that name are removed. If no record is specified the entire cache is purged. .TP .B rediscover Instructs backends that new domains may have appeared in the database, or, in the case of the Bind backend, in named.conf. .TP .B retrieve \fI\fR Retrieve a slave domain from its master. Done nearly immediatly. .TP .B set \fI \fR Set the configuration parameter \fI\fR to \fI\fR. Currently only the \fIquery\-logging\fR can be set. .TP .B show \fI\fR Show a single statistic, as present in the output of the list command. .TP .B quit Tell a running \fBpdns_server\fR to quit. .TP .B status Show usage statistics. .TP .B uptime Show the uptime of the running server. .TP .B version Print the version of the running pdns daemon. .SH FILES .TP .I Control socket used to communicate with \fBpdns_server\fR. .SH SEE ALSO .BR pdns_server (8) pdns-3.3/pdns/docs/dnsreplay.80000644000014601777760000000333512136555572017570 0ustar00jenkinsnogroup00000000000000.TH DNSREPLAY 8 "September 2012" "PowerDNS" .SH NAME dnswasher \- A PowerDNS nameserver debugging tool .SH SYNOPSIS .B dnsreplay \fI[options]\fR \fIfilename\fR \fIip-address\fR \fI[port]\fR .SH DESCRIPTION This program takes recorded questions and answers and replays them to a specified nameserver and reporting afterwards which percentage of answers matched, were worse or better. \fIfilename\fR is expected to be an PCAP file. The queries are send to the DNS server specified as \fIip-address\fR and \fI[port]\fR. \fIip-address\fR is mandatory. If \fI[port]\fR is omitted, 53 will be used. dnsreplay compares the answers and some other metrics with the actual ones with those found in the dumpfile. By default it only replay queries with recursion-desired flag set. .SH OPTIONS .TP .B \-\-help | \-h .br Show summary of options. .TP .B \-\-packet\-limit \fInum\fR .br Stop after replaying \fInum\fR packets. Default for \fInum\fR is 0, which means no limit. .TP .B \-\-quiet \fIflag\fR .br If \fIflag\fR is set to 1. dnsreplay will not be very noisy with its output. This is the default. .TP .B \-\-recursive \fIflag\fR .br If \fIflag\fR is set to 1. dnsreplay will only replay queries with recursion desired flag set. This is the default. .TP .B \-\-speedup \fIfactor\fR .br Replay queries with this speedup factor. Default is 1. .TP .B \-\-timeout-msec \fItime\fR .br Wait at least this many milliseconds for a reply. Default is 500. .SH BUGS dnsreplay has no certain handling for timeouts. It handles around at most 65536 outstanding answers. .SH SEE ALSO pcap(3PCAP), tcpdump(8), dnswascher(8) .SH AUTHORS This manpage was written by Joerg Jungermann (jj+debian At borkum.net) for the Debian Project and the PowerDNS versatile DNS server. pdns-3.3/pdns/docs/dnsscope.80000644000014601777760000000072312136555572017403 0ustar00jenkinsnogroup00000000000000.TH DNSSCOPE 8 "September 2012" "PowerDNS" .SH NAME dnsscope \- A PowerDNS nameserver debugging tool .SH SYNOPSIS .B dnsscope \fI[infile]\fR .SH DESCRIPTION dnsscope takes an \fIinfile\fR in PCAP format. It generates some simple statistics outputs these to STDOUT. .SH OPTIONS None. .SH SEE ALSO pcap(3PCAP), tcpdump(8) .SH AUTHORS This manpage was written by Joerg Jungermann (jj+debian At borkum.net) for the Debian Project and the PowerDNS versatile DNS server. pdns-3.3/pdns/docs/zone2ldap.80000644000014601777760000000356512136555572017472 0ustar00jenkinsnogroup00000000000000.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH PDNS 8 "November 23, 2004" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME zone2ldap \- convert zonefiles to ldif .SH SYNOPSIS .B zone2ldap .RI [ options ] .br .SH DESCRIPTION This manual page documents briefly the .B zone2ldap command. .PP .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, .\" respectively. \fBzone2ldap\fP is a program that converts bind zonefiles to ldif format which can inserted to an LDAP server .SH OPTIONS A summary of options is included below. .TP .B \-\-help .br Show summary of options. .TP .B \-\-basedn\=... .br Base DN to store objects below .TP .B \-\-dnsttl\=[yes|no] .br Add dnsttl attribute to every entry .TP .B \-\-layout\=... .br How to arrange entries in the directory (simple or as tree) .TP .B \-\-named\-conf\=... .br Bind 8 named.conf to parse .TP .B \-\-resume\=[yes|no] .br Continue after errors .TP .B \-\-verbose\=[yes|no] .br Verbose comments on operation .TP .B \-\-zone\-file=... .br Zone file to parse .TP .B \-\-zone\-name=... .br Specify a zone name if zone is set .SH SEE ALSO .BR pdns_server (8) .br .SH AUTHOR This manual page was written by Matthijs Möhlmann , for the Debian project (but may be used by others). pdns-3.3/pdns/docs/dnstcpbench.10000644000014601777760000000723512165464053020051 0ustar00jenkinsnogroup00000000000000'\" t .\" Title: dnstcpbench .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 07/05/2013 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "DNSTCPBENCH" "1" "07/05/2013" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" dnstcpbench \- tool to perform TCP benchmarking of nameservers .SH "SYNOPSIS" .sp \fIdnstcpbench\fR [\-\-help] [\-\-file=filename] [\-\-verbose] [\-\-udp\-first, \-u] [\-\-workers] [\-\-timeout\-msec] remote\-ip\-address [remote\-port] .SH "DESCRIPTION" .sp dnstcpbench reads DNS queries (by default from standard input) and sends them out in parallel to a remote nameserver\&. By default TCP/IP is used, but optionally, UDP is tried first, which allows for the benchmarking of TCP/IP fallback\&. .sp The input format is one query per line: qname single\-space qtype\&. An example: www\&.powerdns\&.com ANY powerdns\&.com MX .sp When benchmarking extended runs, it may be necessary to enable TIME_WAIT recycling, as TCP/IP port tuples may otherwise run out\&. On Linux this is performed by running: .sp .if n \{\ .RS 4 .\} .nf # echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle .fi .if n \{\ .RE .\} .sp The equivalent for IPv6 is not known\&. .SH "OPTIONS" .PP \-f,\-\-file .RS 4 Filename from which to read queries\&. Defaults to standard input if unspecified\&. .RE .PP \-h,\-\-help .RS 4 Provide a helpful message .RE .PP \-\-timeout\-msec .RS 4 Number of milliseconds to wait for an answer .RE .PP \-\-udp\-first, \-u .RS 4 Attempt resolution via UDP first, only do TCP if truncated answer is received .RE .PP \-v,\-\-verbose .RS 4 Be wordy on what the program is doing .RE .PP \-\-workers .RS 4 Number of parallel worker threads to use\&. .RE .sp Remote IP address can be IPv4 or IPv6\&. Remote port defaults to 53\&. .SH "STATISTICAL OUTPUT" .sp The program reports both mean and median numbers for queries per second and UDP and TCP latency\&. Each query only counts once, even if it is tried over UDP first\&. This effectively means that passing \fI\-u\fR can lower query rates if many queries get shunted to TCP\&. .SH "BUGS" .sp Currently the timeout code does not actually perform non\-blocking connects or writes\&. So a slow connect or slow writes will still cause low performance and delays\&. .sp Median queries per second statistics are reported as 0 for sub\-second runs\&. .SH "AUTHOR" .sp Written by PowerDNS\&.COM BV, bert hubert, <\m[blue]\fBbert\&.hubert@netherlabs\&.nl\fR\m[]\&\s-2\u[1]\d\s+2> .SH "RESOURCES" .sp Website: \m[blue]\fBhttp://www\&.powerdns\&.com\fR\m[] .SH "COPYING" .sp Copyright \(co 2013 PowerDNS\&.COM BV\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 2\&. .SH "NOTES" .IP " 1." 4 bert.hubert@netherlabs.nl .RS 4 \%mailto:bert.hubert@netherlabs.nl .RE pdns-3.3/pdns/botan110signers.cc0000644000014601777760000003346412136555572020003 0ustar00jenkinsnogroup00000000000000// utf-8 UTF-8 utf8 UTF8 #include #include #include #include #include #include #include #include #include "dnssecinfra.hh" using namespace Botan; /* Государственный гимн Российской Федерации (Gosudarstvenny Gimn Rossiyskoy Federatsii) "The National Anthem of the Russian Federation" ~ Rossiya - svyashchennaya nasha derzhava, ~ ~ Rossiya - lyubimaya nasha strana. ~ ~ Moguchaya volya, velikaya slava - ~ ~ Tvoyo dostoyanye na vse vremena! ~ */ class GOSTDNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: explicit GOSTDNSCryptoKeyEngine(unsigned int algorithm) : DNSCryptoKeyEngine(algorithm) {} // XXX FIXME NEEDS COPY CONSTRUCTOR SO WE DON'T SHARE KEYS ~GOSTDNSCryptoKeyEngine(){} void create(unsigned int bits); string getName() const { return "Botan 1.10 GOST"; } storvector_t convertToISCVector() const; std::string getPubKeyHash() const; std::string sign(const std::string& hash) const; std::string hash(const std::string& hash) const; bool verify(const std::string& hash, const std::string& signature) const; std::string getPublicKeyString() const; int getBits() const; void fromISCMap(DNSKEYRecordContent& drc, std::map& content); void fromPublicKeyString(const std::string& content); void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) {} static DNSCryptoKeyEngine* maker(unsigned int algorithm) { return new GOSTDNSCryptoKeyEngine(algorithm); } private: shared_ptr d_key; shared_ptr d_pubkey; }; /* ~ Slav'sya, Otechestvo nashe svobodnoye, ~ ~ Bratskikh narodov soyuz vekovoy, ~ ~ Predkami dannaya mudrost' narodnaya! ~ ~ Slav'sya, strana! My gordimsya toboy! ~ */ void GOSTDNSCryptoKeyEngine::create(unsigned int bits) { AutoSeeded_RNG rng; EC_Domain_Params params("1.2.643.2.2.35.1"); d_key = shared_ptr(new GOST_3410_PrivateKey(rng, params)); } int GOSTDNSCryptoKeyEngine::getBits() const { return 256; } /* ~ Ot yuzhnykh morey do polyarnogo kraya ~ ~ Raskinulis' nashi lesa i polya. ~ ~ Odna ty na svete! Odna ty takaya - ~ ~ Khranimaya Bogom rodnaya zemlya! ~ */ DNSCryptoKeyEngine::storvector_t GOSTDNSCryptoKeyEngine::convertToISCVector() const { storvector_t storvect; storvect.push_back(make_pair("Algorithm", "12 (ECC-GOST)")); unsigned char asn1Prefix[]= {0x30, 0x45, 0x02, 0x01, 0x00, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x23, 0x01, 0x06, 0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x1e, 0x01, 0x04, 0x22, 0x04, 0x20}; // this is DER, fixed for a 32 byte key SecureVector buffer=BigInt::encode(d_key->private_value()); string gostasn1((const char*)asn1Prefix, sizeof(asn1Prefix)); gostasn1.append((const char*)&*buffer.begin(), (const char*)&*buffer.end()); storvect.push_back(make_pair("GostAsn1", gostasn1)); return storvect; } /* ~ Slav'sya, Otechestvo nashe svobodnoye, ~ ~ Bratskikh narodov soyuz vekovoy, ~ ~ Predkami dannaya mudrost' narodnaya! ~ ~ Slav'sya, strana! My gordimsya toboy! ~ */ void GOSTDNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap ) { drc.d_algorithm = atoi(stormap["algorithm"].c_str()); string privateKey=stormap["gostasn1"]; //cerr<<"PrivateKey.size() = "<(new GOST_3410_PrivateKey(rng, params, bigint)); //cerr<<"Is the just imported key on the curve? " << d_key->public_point().on_the_curve()<public_point().is_zero()<private_value(); SecureVector buffer=BigInt::encode(x); // cerr<<"And out again! "< msg_le(msg, msg_len); for(size_t i = 0; i != msg_le.size() / 2; ++i) std::swap(msg_le[i], msg_le[msg_le.size()-1-i]); return BigInt(&msg_le[0], msg_le.size()); } } void GOSTDNSCryptoKeyEngine::fromPublicKeyString(const std::string& input) { BigInt x, y; x=decode_le((const byte*)input.c_str(), input.length()/2); y=decode_le((const byte*)input.c_str() + input.length()/2, input.length()/2); EC_Domain_Params params("1.2.643.2.2.35.1"); PointGFp point(params.get_curve(), x,y); d_pubkey = shared_ptr(new GOST_3410_PublicKey(params, point)); d_key.reset(); } std::string GOSTDNSCryptoKeyEngine::getPubKeyHash() const { const BigInt&x = d_key->private_value(); SecureVector buffer=BigInt::encode(x); return string((const char*)buffer.begin(), (const char*)buffer.end()); } std::string GOSTDNSCryptoKeyEngine::getPublicKeyString() const { const BigInt&x =d_key->public_point().get_affine_x(); const BigInt&y =d_key->public_point().get_affine_y(); size_t part_size = std::max(x.bytes(), y.bytes()); MemoryVector bits(2*part_size); x.binary_encode(&bits[part_size - x.bytes()]); y.binary_encode(&bits[2*part_size - y.bytes()]); // Keys are stored in little endian format (WTF) for(size_t i = 0; i != part_size / 2; ++i) { std::swap(bits[i], bits[part_size-1-i]); std::swap(bits[part_size+i], bits[2*part_size-1-i]); } return string((const char*)bits.begin(), (const char*)bits.end()); } /* ~ Shirokiy prostor dlya mechty i dlya zhizni. ~ ~ Gryadushchiye nam otkryvayut goda. ~ ~ Nam silu dayot nasha vernost' Otchizne. ~ ~ Tak bylo, tak yest' i tak budet vsegda! ~ */ std::string GOSTDNSCryptoKeyEngine::sign(const std::string& msg) const { GOST_3410_Signature_Operation ops(*d_key); AutoSeeded_RNG rng; string hash= this->hash(msg); SecureVector signature=ops.sign((byte*)hash.c_str(), hash.length(), rng); #if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,9,12) // see http://bit.ly/gTytUf string reversed((const char*)signature.begin()+ signature.size()/2, signature.size()/2); reversed.append((const char*)signature.begin(), signature.size()/2); return reversed; #else return string((const char*)signature.begin(), (const char*) signature.end()); #endif } std::string GOSTDNSCryptoKeyEngine::hash(const std::string& orig) const { SecureVector result; GOST_34_11 hasher; result= hasher.process(orig); return string((const char*)result.begin(), (const char*) result.end()); } bool GOSTDNSCryptoKeyEngine::verify(const std::string& message, const std::string& signature) const { string hash = this->hash(message); GOST_3410_PublicKey* pk; if(d_pubkey) { pk =d_pubkey.get(); } else pk = d_key.get(); GOST_3410_Verification_Operation ops(*pk); #if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,9,12) // see http://bit.ly/gTytUf string rsignature(signature.substr(32)); rsignature.append(signature.substr(0,32)); return ops.verify ((byte*)hash.c_str(), hash.length(), (byte*)rsignature.c_str(), rsignature.length()); #else return ops.verify ((byte*)hash.c_str(), hash.length(), (byte*)signature.c_str(), signature.length()); #endif } /* ~ Slav'sya, Otechestvo nashe svobodnoye, ~ ~ Bratskikh narodov soyuz vekovoy, ~ ~ Predkami dannaya mudrost' narodnaya! ~ ~ Slav'sya, strana! My gordimsya toboy! ~ */ ////////////////////////////// class ECDSADNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: explicit ECDSADNSCryptoKeyEngine(unsigned int algo) : DNSCryptoKeyEngine(algo) {} ~ECDSADNSCryptoKeyEngine() {} // XXX FIXME NEEDS DEEP COPY CONSTRUCTOR SO WE DON'T SHARE KEYS string getName() const { return "Botan 1.10 ECDSA"; } void create(unsigned int bits); storvector_t convertToISCVector() const; std::string getPubKeyHash() const; std::string sign(const std::string& hash) const; std::string hash(const std::string& hash) const; bool verify(const std::string& hash, const std::string& signature) const; std::string getPublicKeyString() const; int getBits() const; void fromISCMap(DNSKEYRecordContent& drc, std::map& stormap); void fromPublicKeyString(const std::string& content); void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) {} static DNSCryptoKeyEngine* maker(unsigned int algorithm) { return new ECDSADNSCryptoKeyEngine(algorithm); } private: static EC_Domain_Params getECParams(unsigned int algorithm); shared_ptr d_key; shared_ptr d_pubkey; }; EC_Domain_Params ECDSADNSCryptoKeyEngine::getECParams(unsigned int algorithm) { if(algorithm==13) return EC_Domain_Params("1.2.840.10045.3.1.7"); else if(algorithm == 14) return EC_Domain_Params("1.3.132.0.34"); else throw runtime_error("Requested for unknown EC domain parameters for algorithm "+lexical_cast(algorithm)); } void ECDSADNSCryptoKeyEngine::create(unsigned int bits) { AutoSeeded_RNG rng; EC_Domain_Params params; if(bits==256) { params = getECParams(13); } else if(bits == 384){ params = getECParams(14); } else { throw runtime_error("Unknown key length of "+lexical_cast(bits)+" bits requested from ECDSA class"); } d_key = shared_ptr(new ECDSA_PrivateKey(rng, params)); } int ECDSADNSCryptoKeyEngine::getBits() const { if(d_algorithm == 13) return 256; else if(d_algorithm == 14) return 384; return -1; } DNSCryptoKeyEngine::storvector_t ECDSADNSCryptoKeyEngine::convertToISCVector() const { /* Algorithm: 13 (ECDSAP256SHA256) PrivateKey: GU6SnQ/Ou+xC5RumuIUIuJZteXT2z0O/ok1s38Et6mQ= */ storvector_t storvect; string algorithm; if(getBits()==256) algorithm = "13 (ECDSAP256SHA256)"; else if(getBits()==384) algorithm ="14 (ECDSAP384SHA384)"; else algorithm =" ? (?)"; storvect.push_back(make_pair("Algorithm", algorithm)); const BigInt&x = d_key->private_value(); SecureVector buffer=BigInt::encode(x); storvect.push_back(make_pair("PrivateKey", string((char*)&*buffer.begin(), (char*)&*buffer.end()))); return storvect; } void ECDSADNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap) { /*Private-key-format: v1.2 Algorithm: 13 (ECDSAP256SHA256) PrivateKey: GU6SnQ/Ou+xC5RumuIUIuJZteXT2z0O/ok1s38Et6mQ= */ drc.d_algorithm = atoi(stormap["algorithm"].c_str()); if(drc.d_algorithm != d_algorithm) throw runtime_error("Tried to feed an algorithm "+lexical_cast(drc.d_algorithm)+" to a "+lexical_cast(d_algorithm)+" key!"); string privateKey=stormap["privatekey"]; BigInt bigint((byte*)privateKey.c_str(), privateKey.length()); EC_Domain_Params params=getECParams(d_algorithm); AutoSeeded_RNG rng; d_key=shared_ptr(new ECDSA_PrivateKey(rng, params, bigint)); } std::string ECDSADNSCryptoKeyEngine::getPubKeyHash() const { const BigInt&x = d_key->private_value(); // um, this is not the 'pubkeyhash', ahu SecureVector buffer=BigInt::encode(x); return string((const char*)buffer.begin(), (const char*)buffer.end()); } std::string ECDSADNSCryptoKeyEngine::getPublicKeyString() const { const BigInt&x =d_key->public_point().get_affine_x(); const BigInt&y =d_key->public_point().get_affine_y(); size_t part_size = std::max(x.bytes(), y.bytes()); MemoryVector bits(2*part_size); x.binary_encode(&bits[part_size - x.bytes()]); y.binary_encode(&bits[2*part_size - y.bytes()]); return string((const char*)bits.begin(), (const char*)bits.end()); } void ECDSADNSCryptoKeyEngine::fromPublicKeyString(const std::string&input) { BigInt x, y; x.binary_decode((const byte*)input.c_str(), input.length()/2); y.binary_decode((const byte*)input.c_str() + input.length()/2, input.length()/2); EC_Domain_Params params=getECParams(d_algorithm); PointGFp point(params.get_curve(), x,y); d_pubkey = shared_ptr(new ECDSA_PublicKey(params, point)); d_key.reset(); } std::string ECDSADNSCryptoKeyEngine::sign(const std::string& msg) const { string hash = this->hash(msg); ECDSA_Signature_Operation ops(*d_key); AutoSeeded_RNG rng; SecureVector signature=ops.sign((byte*)hash.c_str(), hash.length(), rng); return string((const char*)signature.begin(), (const char*) signature.end()); } std::string ECDSADNSCryptoKeyEngine::hash(const std::string& orig) const { SecureVector result; if(getBits() == 256) { // SHA256 SHA_256 hasher; result= hasher.process(orig); } else { // SHA384 SHA_384 hasher; result = hasher.process(orig); } return string((const char*)result.begin(), (const char*) result.end()); } bool ECDSADNSCryptoKeyEngine::verify(const std::string& msg, const std::string& signature) const { string hash = this->hash(msg); ECDSA_PublicKey* key; if(d_key) key = d_key.get(); else key = d_pubkey.get(); ECDSA_Verification_Operation ops(*key); return ops.verify ((byte*)hash.c_str(), hash.length(), (byte*)signature.c_str(), signature.length()); } namespace { struct LoaderStruct { LoaderStruct() { // 'botansigners' inits Botan for us DNSCryptoKeyEngine::report(12, &GOSTDNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(13, &ECDSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(14, &ECDSADNSCryptoKeyEngine::maker); } } loaderBotan19; } pdns-3.3/pdns/ssqlite3.cc0000644000014601777760000000715112136555572016624 0ustar00jenkinsnogroup00000000000000 // // SQLite backend for PowerDNS // Copyright (C) 2003, Michel Stol // #include #include #include "ssqlite3.hh" #include #include #include "pdns/logger.hh" #include "misc.hh" #ifdef WIN32 # include # define access _access # define F_OK 0 #else // WIN32 # include #endif // Unix // Constructor. SSQLite3::SSQLite3( const std::string & database, bool creat ) { // Open the database connection. if(!creat) if ( access( database.c_str(), F_OK ) == -1 ) throw sPerrorException( "SQLite database '"+database+"' does not exist yet" ); if ( sqlite3_open( database.c_str(), &m_pDB)!=SQLITE_OK ) throw sPerrorException( "Could not connect to the SQLite database '" + database + "'" ); m_pStmt = 0; m_dolog = 0; sqlite3_busy_handler(m_pDB, busyHandler, 0); } void SSQLite3::setLog(bool state) { m_dolog=state; } // Destructor. SSQLite3::~SSQLite3() { int ret; for(int n = 0; n < 2 ; ++n) { if((ret =sqlite3_close( m_pDB )) != SQLITE_OK) { if(n || !m_pStmt || ret != SQLITE_BUSY) { // if we have SQLITE_BUSY, and a working m_Pstmt, try finalize cerr<<"Unable to close down sqlite connection: "<= 3003009 if ( sqlite3_prepare_v2( m_pDB, query.c_str(), -1, &m_pStmt, &pTail ) != SQLITE_OK ) #else if ( sqlite3_prepare( m_pDB, query.c_str(), -1, &m_pStmt, &pTail ) != SQLITE_OK ) #endif throw sPerrorException( string("Unable to compile SQLite statement : ")+ sqlite3_errmsg( m_pDB ) ); return 0; } int SSQLite3::busyHandler(void*, int) { usleep(1000); return 1; } // Returns a row from the result set. bool SSQLite3::getRow( row_t & row ) { int numCols; int rc; const char *pData; row.clear(); rc = sqlite3_step( m_pStmt ); if ( rc == SQLITE_ROW ) { numCols = sqlite3_column_count( m_pStmt ); // Another row received, process it. for ( int i = 0; i < numCols; i++ ) { pData = (const char*) sqlite3_column_text( m_pStmt, i ); row.push_back( pData ? pData : "" ); // NULL value to "". } return true; } if ( rc == SQLITE_DONE ) { // We're done, clean up. sqlite3_finalize( m_pStmt ); m_pStmt = NULL; return false; } if(rc == SQLITE_CANTOPEN) { string error ="CANTOPEN error in sqlite3, often caused by unwritable sqlite3 db *directory*: "+string(sqlite3_errmsg(m_pDB)); sqlite3_finalize(m_pStmt); m_pStmt = 0; throw sPerrorException(error); } // Something went wrong, complain. throw sPerrorException( "Error while retrieving SQLite query results: "+string(sqlite3_errmsg(m_pDB) )); // Prevent some compilers from complaining. return false; } // Escape a SQL query. std::string SSQLite3::escape( const std::string & name) { std::string a; for( std::string::const_iterator i = name.begin(); i != name.end(); ++i ) { if( *i == '\'' || *i == '\\' ) a += '\\'; a += *i; } return a; } pdns-3.3/pdns/epollmplexer.cc0000644000014601777760000000774212136555572017573 0ustar00jenkinsnogroup00000000000000#include "mplexer.hh" #include "sstuff.hh" #include #include #include "misc.hh" #include #include "syncres.hh" #ifdef __linux__ #include #endif #include "namespaces.hh" #include "namespaces.hh" class EpollFDMultiplexer : public FDMultiplexer { public: EpollFDMultiplexer(); virtual ~EpollFDMultiplexer() { close(d_epollfd); } virtual int run(struct timeval* tv); virtual void addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter); virtual void removeFD(callbackmap_t& cbmap, int fd); string getName() { return "epoll"; } private: int d_epollfd; boost::shared_array d_eevents; static int s_maxevents; // not a hard maximum }; static FDMultiplexer* makeEpoll() { return new EpollFDMultiplexer(); } static struct EpollRegisterOurselves { EpollRegisterOurselves() { FDMultiplexer::getMultiplexerMap().insert(make_pair(0, &makeEpoll)); // priority 0! } } doItEpoll; int EpollFDMultiplexer::s_maxevents=1024; EpollFDMultiplexer::EpollFDMultiplexer() : d_eevents(new epoll_event[s_maxevents]) { d_epollfd=epoll_create(s_maxevents); // not hard max if(d_epollfd < 0) throw FDMultiplexerException("Setting up epoll: "+stringerror()); int fd=socket(AF_INET, SOCK_DGRAM, 0); // for self-test if(fd < 0) return; try { addReadFD(fd, 0); removeReadFD(fd); close(fd); return; } catch(FDMultiplexerException &fe) { close(fd); close(d_epollfd); throw FDMultiplexerException("epoll multiplexer failed self-test: "+string(fe.what())); } } void EpollFDMultiplexer::addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter) { accountingAddFD(cbmap, fd, toDo, parameter); struct epoll_event eevent; eevent.events = (&cbmap == &d_readCallbacks) ? EPOLLIN : EPOLLOUT; eevent.data.u64=0; // placate valgrind (I love it so much) eevent.data.fd=fd; if(epoll_ctl(d_epollfd, EPOLL_CTL_ADD, fd, &eevent) < 0) { cbmap.erase(fd); throw FDMultiplexerException("Adding fd to epoll set: "+stringerror()); } } void EpollFDMultiplexer::removeFD(callbackmap_t& cbmap, int fd) { if(!cbmap.erase(fd)) throw FDMultiplexerException("Tried to remove unlisted fd "+lexical_cast(fd)+ " from multiplexer"); struct epoll_event dummy; dummy.events = 0; dummy.data.u64 = 0; if(epoll_ctl(d_epollfd, EPOLL_CTL_DEL, fd, &dummy) < 0) throw FDMultiplexerException("Removing fd from epoll set: "+stringerror()); } int EpollFDMultiplexer::run(struct timeval* now) { if(d_inrun) { throw FDMultiplexerException("FDMultiplexer::run() is not reentrant!\n"); } int ret=epoll_wait(d_epollfd, d_eevents.get(), s_maxevents, 500); gettimeofday(now,0); // MANDATORY if(ret < 0 && errno!=EINTR) throw FDMultiplexerException("epoll returned error: "+stringerror()); if(ret < 1) // thanks AB! return 0; d_inrun=true; for(int n=0; n < ret; ++n) { d_iter=d_readCallbacks.find(d_eevents[n].data.fd); if(d_iter != d_readCallbacks.end()) { d_iter->second.d_callback(d_iter->first, d_iter->second.d_parameter); continue; // so we don't refind ourselves as writable! } d_iter=d_writeCallbacks.find(d_eevents[n].data.fd); if(d_iter != d_writeCallbacks.end()) { d_iter->second.d_callback(d_iter->first, d_iter->second.d_parameter); } } d_inrun=false; return 0; } #if 0 void acceptData(int fd, funcparam_t& parameter) { cout<<"Have data on fd "<(parameter); string packet; IPEndpoint rem; sock->recvFrom(packet, rem); cout<<"Received "< #include #include #if !defined SOLARIS8 && !defined WIN32 #elif defined WIN32 #include "utility.hh" #endif #ifndef WIN32 #include #else // ? struct sockaddr_un {}; #endif /** this class is used both to send and answer channel commands to the PowerDNS Recursor */ class RecursorControlChannel { public: RecursorControlChannel(); ~RecursorControlChannel(); int listen(const std::string& filename); void connect(const std::string& path, const std::string& filename); uint64_t getStat(const std::string& name); void send(const std::string& msg, const std::string* remote=0); std::string recv(std::string* remote=0, unsigned int timeout=5); int d_fd; private: struct sockaddr_un d_local; }; class RecursorControlParser { public: RecursorControlParser(); static void nop(void){} typedef void func_t(void); std::string getAnswer(const std::string& question, func_t** func); }; std::map getAllStatsMap(); #endif pdns-3.3/pdns/sillyrecords.cc0000644000014601777760000001666612165231435017575 0ustar00jenkinsnogroup00000000000000#include "utility.hh" #include #include #include #include #include #include #include "dnsrecords.hh" static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, 1000000,10000000,100000000,1000000000}; /* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer.*/ static uint8_t precsize_aton(const char **strptr) { unsigned int mval = 0, cmval = 0; uint8_t retval = 0; const char *cp; int exponent; int mantissa; cp = *strptr; while (isdigit(*cp)) mval = mval * 10 + (*cp++ - '0'); if (*cp == '.') { /* centimeters */ cp++; if (isdigit(*cp)) { cmval = (*cp++ - '0') * 10; if (isdigit(*cp)) { cmval += (*cp++ - '0'); } } } cmval = (mval * 100) + cmval; for (exponent = 0; exponent < 9; exponent++) if (cmval < poweroften[exponent+1]) break; mantissa = cmval / poweroften[exponent]; if (mantissa > 9) mantissa = 9; retval = (mantissa << 4) | exponent; *strptr = cp; return (retval); } /* converts ascii lat/lon to unsigned encoded 32-bit number. * moves pointer. */ static uint32_t latlon2ul(const char **latlonstrptr, int *which) { const char *cp; uint32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (*cp && !(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (*cp && !isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (*cp && !isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval); } void LOCRecordContent::report(void) { regist(1, ns_t_loc, &make, &make, "LOC"); } DNSRecordContent* LOCRecordContent::make(const string& content) { return new LOCRecordContent(content); } void LOCRecordContent::toPacket(DNSPacketWriter& pw) { pw.xfr8BitInt(d_version); pw.xfr8BitInt(d_size); pw.xfr8BitInt(d_horizpre); pw.xfr8BitInt(d_vertpre); pw.xfr32BitInt(d_latitude); pw.xfr32BitInt(d_longitude); pw.xfr32BitInt(d_altitude); } LOCRecordContent::DNSRecordContent* LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) { LOCRecordContent* ret=new LOCRecordContent(); pr.xfr8BitInt(ret->d_version); pr.xfr8BitInt(ret->d_size); pr.xfr8BitInt(ret->d_horizpre); pr.xfr8BitInt(ret->d_vertpre); pr.xfr32BitInt(ret->d_latitude); pr.xfr32BitInt(ret->d_longitude); pr.xfr32BitInt(ret->d_altitude); return ret; } LOCRecordContent::LOCRecordContent(const string& content, const string& zone) : DNSRecordContent(ns_t_loc) { // 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m // convert this to d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude d_version = 0; const char *cp, *maxcp; uint32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; d_horizpre = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ d_vertpre = 0x13; /* default = 1e3 cm = 10.00m */ d_size = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = content.c_str(); maxcp = cp + strlen(content.c_str()); lltemp1 = latlon2ul(&cp, &which1); lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { case 3: /* 1 + 2, the only valid combination */ if ((which1 == 1) && (which2 == 2)) { /* normal case */ d_latitude = lltemp1; d_longitude = lltemp2; } else if ((which1 == 2) && (which2 == 1)) {/*reversed*/ d_latitude = lltemp1; d_longitude = lltemp2; } else { /* some kind of brokenness */ return; } break; default: /* we didn't get one of each */ throw MOADNSException("Error decoding LOC content"); } /* altitude */ if (*cp == '-') { altsign = -1; cp++; } if (*cp == '+') cp++; while (isdigit(*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal meters */ cp++; if (isdigit(*cp)) { altfrac = (*cp++ - '0') * 10; if (isdigit(*cp)) { altfrac += (*cp++ - '0'); } } } d_altitude = (10000000 + (altsign * (altmeters * 100 + altfrac))); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; d_size = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp))/*if trailing garbage or m*/ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; d_horizpre = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp))/*if trailing garbage or m*/ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; d_vertpre = precsize_aton(&cp); defaults: ; } string LOCRecordContent::getZoneRepresentation() const { // convert d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude to: // 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m double latitude= ((int32_t)d_latitude - (1<<31))/3600000.0; double longitude=((int32_t)d_longitude - (1<<31))/3600000.0; double altitude= ((int32_t)d_altitude )/100.0 - 100000; double size=0.01*((d_size>>4)&0xf); int count=d_size & 0xf; while(count--) size*=10; double horizpre=0.01*((d_horizpre>>4) & 0xf); count=d_horizpre&0xf; while(count--) horizpre*=10; double vertpre=0.01*((d_vertpre>>4)&0xf); count=d_vertpre&0xf; while(count--) vertpre*=10; double remlat=60.0*(latitude-(int)latitude); double remlong=60.0*(longitude-(int)longitude); char ret[80]; snprintf(ret,sizeof(ret)-1,"%d %d %2.03f %c %d %d %2.03f %c %.2fm %.2fm %.2fm %.2fm", abs((int)latitude), abs((int) ((latitude-(int)latitude)*60)), fabs((double)((remlat-(int)remlat)*60.0)), latitude>0 ? 'N' : 'S', abs((int)longitude), abs((int) ((longitude-(int)longitude)*60)), fabs((double)((remlong-(int)remlong)*60.0)), longitude>0 ? 'E' : 'W', altitude, size, horizpre, vertpre); return ret; } pdns-3.3/pdns/dynlistener.hh0000644000014601777760000000501612155361054017414 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_DYNLISTENER #define PDNS_DYNLISTENER #include #include #include #include #include #include #include #include "iputils.hh" #include #ifndef WIN32 #include #include #include #include #include #endif // WIN32 #include "namespaces.hh" class DynListener : public boost::noncopyable { public: explicit DynListener(const string &pname=""); explicit DynListener(const ComboAddress& addr); ~DynListener(); void go(); void theListener(); static void *theListenerHelper(void *p); typedef string g_funk_t(const vector &parts, Utility::pid_t ppid); // guido! typedef struct { g_funk_t *func; string args; string usage; } g_funkwithusage_t; typedef map g_funkdb_t; static void registerFunc(const string &name, g_funk_t *gf, const string &usage="", const string &args=""); static void registerRestFunc(g_funk_t *gf); static g_funk_t* getFunc(const string& fname) { return s_funcdb[fname].func; } private: void sendLine(const string &line); string getHelp(); string getLine(); void listenOnUnixDomain(const std::string& fname); void listenOnTCP(const ComboAddress&); void createSocketAndBind(int family, struct sockaddr*local, size_t len); #ifndef WIN32 struct sockaddr_un d_remote; #else HANDLE m_pipeHandle; #endif // WIN32 Utility::socklen_t d_addrlen; NetmaskGroup d_tcprange; int d_s; int d_client; pthread_t d_tid; bool d_nonlocal; bool d_tcp; pid_t d_ppid; string d_socketname; ComboAddress d_socketaddress; static g_funkdb_t s_funcdb; static g_funk_t* s_restfunc; bool testLive(const string& fname); }; #endif /* PDNS_DYNLISTENER */ pdns-3.3/pdns/ednssubnet.hh0000644000014601777760000000207012136555572017234 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2011 Netherlabs Computer Consulting BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_EDNSSUBNET_HH #define PDNS_EDNSSUBNET_HH #include "namespaces.hh" #include "iputils.hh" struct EDNSSubnetOpts { Netmask source; Netmask scope; }; bool getEDNSSubnetOptsFromString(const string& options, EDNSSubnetOpts* eso); string makeEDNSSubnetOptsString(const EDNSSubnetOpts& eso); #endif pdns-3.3/pdns/bind-dnssec.schema.sqlite3.sql0000644000014601777760000000126512136555572022302 0ustar00jenkinsnogroup00000000000000create table domainmetadata ( id INTEGER PRIMARY KEY, domain VARCHAR(255) COLLATE NOCASE, kind VARCHAR(16) COLLATE NOCASE, content TEXT ); create index domainmetanameindex on domainmetadata(domain); create table cryptokeys ( id INTEGER PRIMARY KEY, domain VARCHAR(255) COLLATE NOCASE, flags INT NOT NULL, active BOOL, content TEXT ); create index domainnameindex on cryptokeys(domain); create table tsigkeys ( id INTEGER PRIMARY KEY, name VARCHAR(255) COLLATE NOCASE, algorithm VARCHAR(50) COLLATE NOCASE, secret VARCHAR(255) ); create unique index namealgoindex on tsigkeys(name, algorithm); pdns-3.3/pdns/pdns.conf-dist0000644000014601777760000002601512156563632017320 0ustar00jenkinsnogroup00000000000000# Autogenerated configuration file template ################################# # add-superfluous-nsec3-for-old-bind Add superfluous NSEC3 record to positive wildcard response # # add-superfluous-nsec3-for-old-bind=yes ################################# # allow-axfr-ips Allow zonetransfers only to these subnets # # allow-axfr-ips=0.0.0.0/0,::/0 ################################# # allow-recursion List of subnets that are allowed to recurse # # allow-recursion=0.0.0.0/0 ################################# # any-to-tcp Answer ANY queries with tc=1, shunting to TCP # # any-to-tcp=no ################################# # cache-ttl Seconds to store packets in the PacketCache # # cache-ttl=20 ################################# # chroot If set, chroot to this directory for more security # # chroot= ################################# # config-dir Location of configuration directory (pdns.conf) # # config-dir=/usr/local/etc ################################# # config-name Name of this virtual configuration - will rename the binary image # # config-name= ################################# # control-console Debugging switch - don't use # # control-console=no ################################# # daemon Operate as a daemon # # daemon=no ################################# # default-ksk-algorithms Default KSK algorithms # # default-ksk-algorithms=rsasha256 ################################# # default-ksk-size Default KSK size (0 means default) # # default-ksk-size=0 ################################# # default-soa-mail mail address to insert in the SOA record if none set in the backend # # default-soa-mail= ################################# # default-soa-name name to insert in the SOA record if none set in the backend # # default-soa-name=a.misconfigured.powerdns.server ################################# # default-ttl Seconds a result is valid if not set otherwise # # default-ttl=3600 ################################# # default-zsk-algorithms Default ZSK algorithms # # default-zsk-algorithms=rsasha256 ################################# # default-zsk-size Default KSK size (0 means default) # # default-zsk-size=0 ################################# # disable-axfr Disable zonetransfers but do allow TCP queries # # disable-axfr=no ################################# # disable-tcp Do not listen to TCP queries # # disable-tcp=no ################################# # distributor-threads Default number of Distributor (backend) threads to start # # distributor-threads=3 ################################# # do-ipv6-additional-processing Do AAAA additional processing # # do-ipv6-additional-processing=yes ################################# # edns-subnet-option-number EDNS option number to use # # edns-subnet-option-number=20730 ################################# # edns-subnet-processing If we should act on EDNS Subnet options # # edns-subnet-processing=no ################################# # entropy-source If set, read entropy from this file # # entropy-source=/dev/urandom ################################# # experimental-direct-dnskey EXPERIMENTAL: fetch DNSKEY RRs from backend during DNSKEY synthesis # # experimental-direct-dnskey=no ################################# # experimental-json-interface If the webserver should serve JSON data # # experimental-json-interface=no ################################# # experimental-logfile Filename of the log file for JSON parser # # experimental-logfile=/var/log/pdns.log ################################# # fancy-records Process URL and MBOXFW records # # fancy-records=no ################################# # guardian Run within a guardian process # # guardian=no ################################# # include-dir Include *.conf files from this directory # # include-dir= ################################# # launch Which backends to launch and order to query them in # # launch= ################################# # load-modules Load this module - supply absolute or relative path # # load-modules= ################################# # local-address Local IP addresses to which we bind # # local-address=0.0.0.0 ################################# # local-ipv6 Local IP address to which we bind # # local-ipv6= ################################# # local-port The port on which we listen # # local-port=53 ################################# # log-dns-details If PDNS should log DNS non-erroneous details # # log-dns-details= ################################# # log-dns-queries If PDNS should log all incoming DNS queries # # log-dns-queries=no ################################# # log-failed-updates If PDNS should log failed update requests # # log-failed-updates= ################################# # logging-facility Log under a specific facility # # logging-facility= ################################# # loglevel Amount of logging. Higher is more. Do not set below 3 # # loglevel=4 ################################# # lua-prequery-script Lua script with prequery handler # # lua-prequery-script= ################################# # master Act as a master # # master=no ################################# # max-cache-entries Maximum number of cache entries # # max-cache-entries=1000000 ################################# # max-ent-entries Maximum number of empty non-terminals in a zone # # max-ent-entries=100000 ################################# # max-queue-length Maximum queuelength before considering situation lost # # max-queue-length=5000 ################################# # max-tcp-connections Maximum number of TCP connections # # max-tcp-connections=10 ################################# # module-dir Default directory for modules # # module-dir=/usr/local/lib ################################# # negquery-cache-ttl Seconds to store negative query results in the QueryCache # # negquery-cache-ttl=60 ################################# # no-shuffle Set this to prevent random shuffling of answers - for regression testing # # no-shuffle=off ################################# # out-of-zone-additional-processing Do out of zone additional processing # # out-of-zone-additional-processing=yes ################################# # overload-queue-length Maximum queuelength moving to packetcache only # # overload-queue-length=0 ################################# # pipebackend-abi-version Version of the pipe backend ABI # # pipebackend-abi-version=1 ################################# # prevent-self-notification Don't send notifications to what we think is ourself # # prevent-self-notification=yes ################################# # query-cache-ttl Seconds to store query results in the QueryCache # # query-cache-ttl=20 ################################# # query-local-address Source IP address for sending queries # # query-local-address=0.0.0.0 ################################# # query-local-address6 Source IPv6 address for sending queries # # query-local-address6=:: ################################# # query-logging Hint backends that queries should be logged # # query-logging=no ################################# # queue-limit Maximum number of milliseconds to queue a query # # queue-limit=1500 ################################# # receiver-threads Default number of receiver threads to start # # receiver-threads=1 ################################# # recursive-cache-ttl Seconds to store packets for recursive queries in the PacketCache # # recursive-cache-ttl=10 ################################# # recursor If recursion is desired, IP address of a recursing nameserver # # recursor=no ################################# # retrieval-threads Number of AXFR-retrieval threads for slave operation # # retrieval-threads=2 ################################# # send-root-referral Send out old-fashioned root-referral instead of ServFail in case of no authority # # send-root-referral=no ################################# # server-id Returned when queried for 'server.id' TXT or NSID, defaults to hostname # # server-id= ################################# # setgid If set, change group id to this gid for more security # # setgid= ################################# # setuid If set, change user id to this uid for more security # # setuid= ################################# # signing-threads Default number of signer threads to start # # signing-threads=3 ################################# # slave Act as a slave # # slave=no ################################# # slave-cycle-interval Reschedule failed SOA serial checks once every .. seconds # # slave-cycle-interval=60 ################################# # slave-renotify If we should send out notifications for slaved updates # # slave-renotify=no ################################# # smtpredirector Our smtpredir MX host # # smtpredirector=a.misconfigured.powerdns.smtp.server ################################# # soa-expire-default Default SOA expire # # soa-expire-default=604800 ################################# # soa-minimum-ttl Default SOA minimum ttl # # soa-minimum-ttl=3600 ################################# # soa-refresh-default Default SOA refresh # # soa-refresh-default=10800 ################################# # soa-retry-default Default SOA retry # # soa-retry-default=3600 ################################# # soa-serial-offset Make sure that no SOA serial is less than this number # # soa-serial-offset=0 ################################# # socket-dir Where the controlsocket will live # # socket-dir=/var/run ################################# # tcp-control-address If set, PowerDNS can be controlled over TCP on this address # # tcp-control-address= ################################# # tcp-control-port If set, PowerDNS can be controlled over TCP on this address # # tcp-control-port=53000 ################################# # tcp-control-range If set, remote control of PowerDNS is possible over these networks only # # tcp-control-range=127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10 ################################# # tcp-control-secret If set, PowerDNS can be controlled over TCP after passing this secret # # tcp-control-secret= ################################# # traceback-handler Enable the traceback handler (Linux only) # # traceback-handler=yes ################################# # trusted-notification-proxy IP address of incoming notification proxy # # trusted-notification-proxy= ################################# # urlredirector Where we send hosts to that need to be url redirected # # urlredirector=127.0.0.1 ################################# # version-string PowerDNS version in packets - full, anonymous, powerdns or custom # # version-string=full ################################# # webserver Start a webserver for monitoring # # webserver=no ################################# # webserver-address IP Address of webserver to listen on # # webserver-address=127.0.0.1 ################################# # webserver-password Password required for accessing the webserver # # webserver-password= ################################# # webserver-port Port of webserver to listen on # # webserver-port=8081 ################################# # webserver-print-arguments If the webserver should print arguments # # webserver-print-arguments=no ################################# # wildcard-url Process URL and MBOXFW records # # wildcard-url=no pdns-3.3/pdns/lock.hh0000644000014601777760000000645512136555572016025 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LOCK_HH #define LOCK_HH #include #include #include "misc.hh" #include "ahuexception.hh" extern bool g_singleThreaded; class Lock { pthread_mutex_t *d_lock; public: Lock(pthread_mutex_t *lock) : d_lock(lock) { if(g_singleThreaded) return; if((errno=pthread_mutex_lock(d_lock))) throw AhuException("error acquiring lock: "+stringerror()); } ~Lock() { if(g_singleThreaded) return; pthread_mutex_unlock(d_lock); } }; class WriteLock { pthread_rwlock_t *d_lock; public: WriteLock(pthread_rwlock_t *lock) : d_lock(lock) { if(g_singleThreaded) return; if((errno=pthread_rwlock_wrlock(d_lock))) { throw AhuException("error acquiring rwlock wrlock: "+stringerror()); } } ~WriteLock() { if(g_singleThreaded) return; pthread_rwlock_unlock(d_lock); } }; class TryWriteLock { pthread_rwlock_t *d_lock; bool d_havelock; public: TryWriteLock(pthread_rwlock_t *lock) : d_lock(lock) { if(g_singleThreaded) { d_havelock=true; return; } d_havelock=false; if((errno=pthread_rwlock_trywrlock(d_lock)) && errno!=EBUSY) throw AhuException("error acquiring rwlock tryrwlock: "+stringerror()); d_havelock=(errno==0); } ~TryWriteLock() { if(g_singleThreaded) return; if(d_havelock) pthread_rwlock_unlock(d_lock); } bool gotIt() { if(g_singleThreaded) return true; return d_havelock; } }; class TryReadLock { pthread_rwlock_t *d_lock; bool d_havelock; public: TryReadLock(pthread_rwlock_t *lock) : d_lock(lock) { if(g_singleThreaded) { d_havelock=true; return; } if((errno=pthread_rwlock_tryrdlock(d_lock)) && errno!=EBUSY) throw AhuException("error acquiring rwlock tryrdlock: "+stringerror()); d_havelock=(errno==0); } ~TryReadLock() { if(g_singleThreaded) return; if(d_havelock) pthread_rwlock_unlock(d_lock); } bool gotIt() { if(g_singleThreaded) return true; return d_havelock; } }; class ReadLock { pthread_rwlock_t *d_lock; public: ReadLock(pthread_rwlock_t *lock) : d_lock(lock) { if(g_singleThreaded) return; if((errno=pthread_rwlock_rdlock(d_lock))) throw AhuException("error acquiring rwlock tryrwlock: "+stringerror()); } ~ReadLock() { if(g_singleThreaded) return; pthread_rwlock_unlock(d_lock); } void upgrade() { if(g_singleThreaded) return; pthread_rwlock_unlock(d_lock); pthread_rwlock_wrlock(d_lock); } }; #endif pdns-3.3/pdns/rcpgenerator.hh0000644000014601777760000000501712145442346017553 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2009 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_RCPGENERATOR_HH #define PDNS_RCPGENERATOR_HH #include #include #include #if !defined SOLARIS8 && !defined WIN32 #elif defined WIN32 # include "utility.hh" #endif #include "namespaces.hh" class RecordTextException : public runtime_error { public: RecordTextException(const string& str) : runtime_error(str) {} }; class RecordTextReader { public: RecordTextReader(const string& str, const string& zone=""); void xfr64BitInt(uint64_t& val); void xfr48BitInt(uint64_t& val); void xfr32BitInt(uint32_t& val); void xfr16BitInt(uint16_t& val); void xfr8BitInt(uint8_t& val); void xfrType(uint16_t& val); void xfrIP(uint32_t& val); void xfrIP6(std::string& val); void xfrTime(uint32_t& val); void xfrLabel(string& val, bool compress=false); void xfrText(string& val, bool multi=false); void xfrHexBlob(string& val, bool keepReading=false); void xfrBase32HexBlob(string& val); void xfrBlob(string& val, int len=-1); bool eof(); private: string d_string; string d_zone; string::size_type d_pos; string::size_type d_end; void skipSpaces(); }; class RecordTextWriter { public: RecordTextWriter(string& str); void xfr48BitInt(const uint64_t& val); void xfr32BitInt(const uint32_t& val); void xfr16BitInt(const uint16_t& val); void xfr8BitInt(const uint8_t& val); void xfrIP(const uint32_t& val); void xfrIP6(const std::string& val); void xfrTime(const uint32_t& val); void xfrBase32HexBlob(const string& val); void xfrType(const uint16_t& val); void xfrLabel(const string& val, bool compress=false); void xfrText(const string& val, bool multi=false); void xfrBlob(const string& val, int len=-1); void xfrHexBlob(const string& val, bool keepReading=false); private: string& d_string; }; #endif pdns-3.3/pdns/speedtest.cc0000644000014601777760000004726312136555572017065 0ustar00jenkinsnogroup00000000000000#include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include #include "config.h" #ifndef RECURSOR #include "statbag.hh" StatBag S; #endif volatile bool g_ret; // make sure the optimizer does not get too smart uint64_t g_totalRuns; volatile bool g_stop; void alarmHandler(int) { g_stop=true; } template void doRun(const C& cmd, int mseconds=100) { struct itimerval it; it.it_value.tv_sec=mseconds/1000; it.it_value.tv_usec = 1000* (mseconds%1000); it.it_interval.tv_sec=0; it.it_interval.tv_usec=0; signal(SIGVTALRM, alarmHandler); setitimer(ITIMER_VIRTUAL, &it, 0); unsigned int runs=0; g_stop=false; DTime dt; dt.set(); while(runs++, !g_stop) { cmd(); } double delta=dt.udiff()/1000000.0; boost::format fmt("'%s' %.02f seconds: %.1f runs/s, %.02f usec/run"); cerr<< (fmt % cmd.getName() % delta % (runs/delta) % (delta* 1000000.0/runs)) << endl; g_totalRuns += runs; } struct ARecordTest { explicit ARecordTest(int records) : d_records(records) {} string getName() const { return (boost::format("%d a records") % d_records).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::A); for(int records = 0; records < d_records; records++) { pw.startRecord("outpost.ds9a.nl", QType::A); ARecordContent arc("1.2.3.4"); arc.toPacket(pw); } pw.commit(); } int d_records; }; struct MakeStringFromCharStarTest { MakeStringFromCharStarTest() : d_size(0){} string getName() const { return (boost::format("make a std::string")).str(); } void operator()() const { string name("outpost.ds9a.nl"); d_size += name.length(); } mutable int d_size; }; struct GetTimeTest { string getName() const { return "gettimeofday-test"; } void operator()() const { struct timeval tv; gettimeofday(&tv, 0); } }; pthread_mutex_t s_testlock=PTHREAD_MUTEX_INITIALIZER; struct GetLockUncontendedTest { string getName() const { return "getlock-uncontended-test"; } void operator()() const { pthread_mutex_lock(&s_testlock); pthread_mutex_unlock(&s_testlock); } }; struct StaticMemberTest { string getName() const { return "static-member-test"; } void operator()() const { static string* s_ptr; if(!s_ptr) s_ptr = new string(); } }; struct MakeARecordTest { string getName() const { return (boost::format("make a-record")).str(); } void operator()() const { static string src("1.2.3.4"); ARecordContent arc(src); //ARecordContent arc(0x01020304); } }; struct MakeARecordTestMM { string getName() const { return (boost::format("make a-record (mm)")).str(); } void operator()() const { DNSRecordContent*drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); delete drc; } }; struct A2RecordTest { explicit A2RecordTest(int records) : d_records(records) {} string getName() const { return (boost::format("%d a records") % d_records).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::A); ARecordContent arc("1.2.3.4"); string name("outpost.ds9a.nl"); for(int records = 0; records < d_records; records++) { pw.startRecord(name, QType::A); arc.toPacket(pw); } pw.commit(); } int d_records; }; struct TXTRecordTest { explicit TXTRecordTest(int records) : d_records(records) {} string getName() const { return (boost::format("%d TXT records") % d_records).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::TXT); for(int records = 0; records < d_records; records++) { pw.startRecord("outpost.ds9a.nl", QType::TXT); TXTRecordContent arc("\"een leuk verhaaltje in een TXT\""); arc.toPacket(pw); } pw.commit(); } int d_records; }; struct GenericRecordTest { explicit GenericRecordTest(int records, uint16_t type, const std::string& content) : d_records(records), d_type(type), d_content(content) {} string getName() const { return (boost::format("%d %s records") % d_records % DNSRecordContent::NumberToType(d_type)).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", d_type); for(int records = 0; records < d_records; records++) { pw.startRecord("outpost.ds9a.nl", d_type); DNSRecordContent*drc = DNSRecordContent::mastermake(d_type, 1, d_content); drc->toPacket(pw); delete drc; } pw.commit(); } int d_records; uint16_t d_type; string d_content; }; struct AAAARecordTest { explicit AAAARecordTest(int records) : d_records(records) {} string getName() const { return (boost::format("%d aaaa records (mm)") % d_records).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::AAAA); for(int records = 0; records < d_records; records++) { pw.startRecord("outpost.ds9a.nl", QType::AAAA); DNSRecordContent*drc = DNSRecordContent::mastermake(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441"); drc->toPacket(pw); delete drc; } pw.commit(); } int d_records; }; struct SOARecordTest { explicit SOARecordTest(int records) : d_records(records) {} string getName() const { return (boost::format("%d soa records (mm)") % d_records).str(); } void operator()() const { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::SOA); for(int records = 0; records < d_records; records++) { pw.startRecord("outpost.ds9a.nl", QType::SOA); DNSRecordContent*drc = DNSRecordContent::mastermake(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400"); drc->toPacket(pw); delete drc; } pw.commit(); } int d_records; }; vector makeEmptyQuery() { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::SOA); return packet; } vector makeRootReferral() { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::SOA); // nobody reads what we output, but it appears to be the magic that shuts some nameservers up static const char*ips[]={"198.41.0.4", "192.228.79.201", "192.33.4.12", "199.7.91.13", "192.203.230.10", "192.5.5.241", "192.112.36.4", "128.63.2.53", "192.36.148.17","192.58.128.30", "193.0.14.129", "198.32.64.12", "202.12.27.33"}; static char templ[40]; strncpy(templ,"a.root-servers.net", sizeof(templ) - 1); for(char c='a';c<='m';++c) { *templ=c; pw.startRecord(".", QType::NS, 3600, 1, DNSPacketWriter::AUTHORITY); DNSRecordContent* drc = DNSRecordContent::mastermake(QType::NS, 1, templ); drc->toPacket(pw); delete drc; } for(char c='a';c<='m';++c) { *templ=c; pw.startRecord(".", QType::A, 3600, 1, DNSPacketWriter::ADDITIONAL); DNSRecordContent* drc = DNSRecordContent::mastermake(QType::A, 1, ips[c-'a']); drc->toPacket(pw); delete drc; } pw.commit(); return packet; } vector makeTypicalReferral() { vector packet; DNSPacketWriter pw(packet, "outpost.ds9a.nl", QType::A); pw.startRecord("ds9a.nl", QType::NS, 3600, 1, DNSPacketWriter::AUTHORITY); DNSRecordContent* drc = DNSRecordContent::mastermake(QType::NS, 1, "ns1.ds9a.nl"); drc->toPacket(pw); delete drc; pw.startRecord("ds9a.nl", QType::NS, 3600, 1, DNSPacketWriter::AUTHORITY); drc = DNSRecordContent::mastermake(QType::NS, 1, "ns2.ds9a.nl"); drc->toPacket(pw); delete drc; pw.startRecord("ns1.ds9a.nl", QType::A, 3600, 1, DNSPacketWriter::ADDITIONAL); drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); drc->toPacket(pw); delete drc; pw.startRecord("ns2.ds9a.nl", QType::A, 3600, 1, DNSPacketWriter::ADDITIONAL); drc = DNSRecordContent::mastermake(QType::A, 1, "4.3.2.1"); drc->toPacket(pw); delete drc; pw.commit(); return packet; } struct RootRefTest { string getName() const { return "write rootreferral"; } void operator()() const { vector packet=makeRootReferral(); } }; struct StackMallocTest { string getName() const { return "stack allocation"; } void operator()() const { char *buffer= new char[200000]; delete buffer; } }; struct EmptyQueryTest { string getName() const { return "write empty query"; } void operator()() const { vector packet=makeEmptyQuery(); } }; struct TypicalRefTest { string getName() const { return "write typical referral"; } void operator()() const { vector packet=makeTypicalReferral(); } }; struct TCacheComp { bool operator()(const pair& a, const pair& b) const { int cmp=strcasecmp(a.first.c_str(), b.first.c_str()); if(cmp < 0) return true; if(cmp > 0) return false; return a.second < b.second; } }; struct NegCacheEntry { string d_name; QType d_qtype; string d_qname; uint32_t d_ttd; }; struct timeval d_now; static bool magicAddrMatch(const QType& query, const QType& answer) { if(query.getCode() != QType::ADDR) return false; return answer.getCode() == QType::A || answer.getCode() == QType::AAAA; } bool moreSpecificThan(const string& a, const string &b) { static string dot("."); int counta=(a!=dot), countb=(b!=dot); for(string::size_type n=0;ncountb; } struct ParsePacketTest { explicit ParsePacketTest(const vector& packet, const std::string& name) : d_packet(packet), d_name(name) {} string getName() const { return "parse '"+d_name+"'"; } void operator()() const { MOADNSParser mdp((const char*)&*d_packet.begin(), d_packet.size()); typedef map, set, TCacheComp > tcache_t; tcache_t tcache; struct { vector d_result; bool d_aabit; int d_rcode; } lwr; DNSResourceRecord rr; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { DNSResourceRecord rr; rr.qtype=i->first.d_type; rr.qname=i->first.d_label; rr.ttl=i->first.d_ttl; rr.content=i->first.d_content->getZoneRepresentation(); // this should be the serialised form rr.d_place=(DNSResourceRecord::Place) i->first.d_place; lwr.d_result.push_back(rr); } // reap all answers from this packet that are acceptable for(vector::iterator i=lwr.d_result.begin();i != lwr.d_result.end();++i) { if(i->qtype.getCode() == QType::OPT) { // <qname<<"' from '"<qname<<"|"<qtype.getName()<<"|"<content<<"' from '"<qtype.getCode()==QType::ANY) { // LOG<<"NO! - we don't accept 'ANY' data"<qname, auth)) { if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && i->d_place==DNSResourceRecord::ANSWER && 0) { // LOG<<"NO! Is from delegation-only zone"<ttl=min(s_maxcachettl, i->ttl); DNSResourceRecord rr=*i; rr.d_place=DNSResourceRecord::ANSWER; // rr.ttl += d_now.tv_sec; if(rr.qtype.getCode() == QType::NS) // people fiddle with the case rr.content=toLower(rr.content); // this must stay! (the cache can't be case-insensitive on the RHS of records) tcache[make_pair(i->qname,i->qtype)].insert(rr); } } else ; // LOG<<"NO!"<second.size() > 1) { // need to group the ttl to be the minimum of the RRSET (RFC 2181, 5.2) uint32_t lowestTTL=std::numeric_limits::max(); for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) lowestTTL=min(lowestTTL, j->ttl); for(tcache_t::value_type::second_type::iterator j=i->second.begin(); j != i->second.end(); ++j) ((tcache_t::value_type::second_type::value_type*)&(*j))->ttl=lowestTTL; } // RC.replace(d_now.tv_sec, i->first.first, i->first.second, i->second, lwr.d_aabit); } set nsset; // LOG< ret; QType qtype(QType::A); string auth("."); for(vector::const_iterator i=lwr.d_result.begin();i!=lwr.d_result.end();++i) { if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NXDomain) { // LOG<qname; ne.d_ttd=d_now.tv_sec + min(i->ttl, 3600U); // controversial ne.d_name=qname; ne.d_qtype=QType(0); // this encodes 'whole record' { // Lock l(&s_negcachelock); // replacing_insert(s_negcache, ne); } negindic=true; } else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { ret.push_back(*i); newtarget=i->content; } // for ANY answers we *must* have an authoritive answer else if(i->d_place==DNSResourceRecord::ANSWER && pdns_iequals(i->qname, qname) && ( i->qtype==qtype || (lwr.d_aabit && (qtype==QType(QType::ANY) || magicAddrMatch(qtype, i->qtype) ) ) ) ) { // LOG<content<<"|"<qtype.getName()<<"'"<d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { if(moreSpecificThan(i->qname,auth)) { newauth=i->qname; // LOG<qname<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<content); } else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NoError) { // LOG<qtype.getName()+"'") <qname; ne.d_ttd=d_now.tv_sec + i->ttl; ne.d_name=qname; ne.d_qtype=qtype; if(qtype.getCode()) { // prevents us from blacking out a whole domain // Lock l(&s_negcachelock); // replacing_insert(s_negcache, ne); } negindic=true; } } } const vector& d_packet; std::string d_name; }; struct ParsePacketBareTest { explicit ParsePacketBareTest(const vector& packet, const std::string& name) : d_packet(packet), d_name(name) {} string getName() const { return "parse '"+d_name+"' bare"; } void operator()() const { MOADNSParser mdp((const char*)&*d_packet.begin(), d_packet.size()); } const vector& d_packet; std::string d_name; }; struct SimpleCompressTest { explicit SimpleCompressTest(const std::string& name) : d_name(name) {} string getName() const { return "compress '"+d_name+"'"; } void operator()() const { simpleCompress(d_name); } std::string d_name; }; struct VectorExpandTest { string getName() const { return "vector expand"; } void operator()() const { vector d_record; d_record.resize(12); string out="\x03www\x04ds9a\x02nl"; string::size_type len = d_record.size(); d_record.resize(len + out.length()); memcpy(&d_record[len], out.c_str(), out.length()); } }; struct IEqualsTest { string getName() const { return "iequals test"; } void operator()() const { static string a("www.ds9a.nl"), b("www.lwn.net"); g_ret = boost::iequals(a, b); } }; struct MyIEqualsTest { string getName() const { return "pdns_iequals test"; } void operator()() const { static string a("www.ds9a.nl"), b("www.lwn.net"); g_ret = pdns_iequals(a, b); } }; struct StrcasecmpTest { string getName() const { return "strcasecmp test"; } void operator()() const { static string a("www.ds9a.nl"), b("www.lwn.net"); g_ret = strcasecmp(a.c_str(), b.c_str()); } }; struct NOPTest { string getName() const { return "null test"; } void operator()() const { } }; int main(int argc, char** argv) try { reportAllTypes(); doRun(NOPTest()); doRun(IEqualsTest()); doRun(MyIEqualsTest()); doRun(StrcasecmpTest()); doRun(StackMallocTest()); vector packet = makeRootReferral(); doRun(ParsePacketBareTest(packet, "root-referral")); doRun(ParsePacketTest(packet, "root-referral")); doRun(RootRefTest()); doRun(EmptyQueryTest()); doRun(TypicalRefTest()); packet = makeEmptyQuery(); doRun(ParsePacketTest(packet, "empty-query")); packet = makeTypicalReferral(); cerr<<"typical referral size: "< #include "namespaces.hh" //! Generic Exception thrown class AhuException { public: AhuException(){reason="Unspecified";}; AhuException(string r){reason=r;}; string reason; //! Print this to tell the user what went wrong }; class TimeoutException : public AhuException {}; #endif pdns-3.3/pdns/lua-auth.hh0000644000014601777760000000072312136555572016605 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_LUA_AUTH_HH #define PDNS_LUA_AUTH_HH #include "dns.hh" #include "iputils.hh" #include "dnspacket.hh" #include "lua-pdns.hh" class AuthLua : public PowerDNSLua { public: explicit AuthLua(const std::string& fname); // ~AuthLua(); bool axfrfilter(const ComboAddress& remote, const string& zone, const DNSResourceRecord& in, vector& out); DNSPacket* prequery(DNSPacket *p); private: void registerLuaDNSPacket(void); }; #endif pdns-3.3/pdns/config.guess0000755000014601777760000011310612136555572017064 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-03-20' # This file 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. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c ; for c in cc gcc c89 c99 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; if test $? = 0 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; 2-1307) UNAME_MACHINE="alphaev68" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:3*) echo i386-pc-interix3 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` rm -f $dummy.c test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` rm -f $dummy.c test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: pdns-3.3/pdns/dynhandler.hh0000644000014601777760000000424612136555572017221 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_DYNHANDLER_HH #define PDNS_DYNHANDLER_HH #include #include #include #include #ifndef WIN32 # include "config.h" # include #else # include "pdnsservice.hh" #endif // WIN32 #include "namespaces.hh" bool DLQuitPlease(); string DLQuitHandler(const vector&parts, Utility::pid_t ppid); string DLRQuitHandler(const vector&parts, Utility::pid_t ppid); string DLPingHandler(const vector&parts, Utility::pid_t ppid); string DLShowHandler(const vector&parts, Utility::pid_t ppid); string DLUptimeHandler(const vector&parts, Utility::pid_t ppid); string DLSettingsHandler(const vector&parts, Utility::pid_t ppid); void setStatus(const string &str); string DLCCHandler(const vector&parts, Utility::pid_t ppid); string DLStatusHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyHostHandler(const vector&parts, Utility::pid_t ppid); string DLReloadHandler(const vector&parts, Utility::pid_t ppid); string DLRediscoverHandler(const vector&parts, Utility::pid_t ppid); string DLVersionHandler(const vector&parts, Utility::pid_t ppid); string DLPurgeHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyRetrieveHandler(const vector&parts, Utility::pid_t ppid); #endif /* PDNS_DYNHANDLER_HH */ pdns-3.3/pdns/ext/0000755000014601777760000000000012165464055015337 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/rapidjson/0000755000014601777760000000000012165464055017330 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/rapidjson/license.txt0000644000014601777760000000205512165464055021515 0ustar00jenkinsnogroup00000000000000Copyright (C) 2011 Milo Yip Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.pdns-3.3/pdns/ext/rapidjson/include/0000755000014601777760000000000012165464055020753 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/rapidjson/include/rapidjson/0000755000014601777760000000000012165464055022744 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/rapidjson/include/rapidjson/rapidjson.h0000644000014601777760000004125712165464055025117 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_RAPIDJSON_H_ #define RAPIDJSON_RAPIDJSON_H_ // Copyright (c) 2011-2012 Milo Yip (miloyip@gmail.com) // Version 0.11 #include // malloc(), realloc(), free() #include // memcpy() /////////////////////////////////////////////////////////////////////////////// // RAPIDJSON_NO_INT64DEFINE // Here defines int64_t and uint64_t types in global namespace. // If user have their own definition, can define RAPIDJSON_NO_INT64DEFINE to disable this. #ifndef RAPIDJSON_NO_INT64DEFINE #ifdef _MSC_VER typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else #include #endif #endif // RAPIDJSON_NO_INT64TYPEDEF /////////////////////////////////////////////////////////////////////////////// // RAPIDJSON_ENDIAN #define RAPIDJSON_LITTLEENDIAN 0 //!< Little endian machine #define RAPIDJSON_BIGENDIAN 1 //!< Big endian machine //! Endianness of the machine. /*! GCC provided macro for detecting endianness of the target machine. But other compilers may not have this. User can define RAPIDJSON_ENDIAN to either RAPIDJSON_LITTLEENDIAN or RAPIDJSON_BIGENDIAN. */ #ifndef RAPIDJSON_ENDIAN #ifdef __BYTE_ORDER__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN #else #define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN #endif // __BYTE_ORDER__ #else #define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN // Assumes little endian otherwise. #endif #endif // RAPIDJSON_ENDIAN /////////////////////////////////////////////////////////////////////////////// // RAPIDJSON_SSE2/RAPIDJSON_SSE42/RAPIDJSON_SIMD // Enable SSE2 optimization. //#define RAPIDJSON_SSE2 // Enable SSE4.2 optimization. //#define RAPIDJSON_SSE42 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) #define RAPIDJSON_SIMD #endif /////////////////////////////////////////////////////////////////////////////// // RAPIDJSON_NO_SIZETYPEDEFINE #ifndef RAPIDJSON_NO_SIZETYPEDEFINE namespace rapidjson { //! Use 32-bit array/string indices even for 64-bit platform, instead of using size_t. /*! User may override the SizeType by defining RAPIDJSON_NO_SIZETYPEDEFINE. */ typedef unsigned SizeType; } // namespace rapidjson #endif /////////////////////////////////////////////////////////////////////////////// // RAPIDJSON_ASSERT //! Assertion. /*! By default, rapidjson uses C assert() for assertion. User can override it by defining RAPIDJSON_ASSERT(x) macro. */ #ifndef RAPIDJSON_ASSERT #include #define RAPIDJSON_ASSERT(x) assert(x) #endif // RAPIDJSON_ASSERT /////////////////////////////////////////////////////////////////////////////// // Helpers #define RAPIDJSON_MULTILINEMACRO_BEGIN do { #define RAPIDJSON_MULTILINEMACRO_END \ } while((void)0, 0) namespace rapidjson { /////////////////////////////////////////////////////////////////////////////// // Allocator /*! \class rapidjson::Allocator \brief Concept for allocating, resizing and freeing memory block. Note that Malloc() and Realloc() are non-static but Free() is static. So if an allocator need to support Free(), it needs to put its pointer in the header of memory block. \code concept Allocator { static const bool kNeedFree; //!< Whether this allocator needs to call Free(). // Allocate a memory block. // \param size of the memory block in bytes. // \returns pointer to the memory block. void* Malloc(size_t size); // Resize a memory block. // \param originalPtr The pointer to current memory block. Null pointer is permitted. // \param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.) // \param newSize the new size in bytes. void* Realloc(void* originalPtr, size_t originalSize, size_t newSize); // Free a memory block. // \param pointer to the memory block. Null pointer is permitted. static void Free(void *ptr); }; \endcode */ /////////////////////////////////////////////////////////////////////////////// // CrtAllocator //! C-runtime library allocator. /*! This class is just wrapper for standard C library memory routines. \implements Allocator */ class CrtAllocator { public: static const bool kNeedFree = true; void* Malloc(size_t size) { return malloc(size); } void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { (void)originalSize; return realloc(originalPtr, newSize); } static void Free(void *ptr) { free(ptr); } }; /////////////////////////////////////////////////////////////////////////////// // MemoryPoolAllocator //! Default memory allocator used by the parser and DOM. /*! This allocator allocate memory blocks from pre-allocated memory chunks. It does not free memory blocks. And Realloc() only allocate new memory. The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default. User may also supply a buffer as the first chunk. If the user-buffer is full then additional chunks are allocated by BaseAllocator. The user-buffer is not deallocated by this allocator. \tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator. \implements Allocator */ template class MemoryPoolAllocator { public: static const bool kNeedFree = false; //!< Tell users that no need to call Free() with this allocator. (concept Allocator) //! Constructor with chunkSize. /*! \param chunkSize The size of memory chunk. The default is kDefaultChunkSize. \param baseAllocator The allocator for allocating memory chunks. */ MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0) { if (!baseAllocator_) ownBaseAllocator_ = baseAllocator_ = new BaseAllocator(); AddChunk(chunk_capacity_); } //! Constructor with user-supplied buffer. /*! The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size. The user buffer will not be deallocated when this allocator is destructed. \param buffer User supplied buffer. \param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader). \param chunkSize The size of memory chunk. The default is kDefaultChunkSize. \param baseAllocator The allocator for allocating memory chunks. */ MemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0) { RAPIDJSON_ASSERT(buffer != 0); RAPIDJSON_ASSERT(size > sizeof(ChunkHeader)); chunkHead_ = (ChunkHeader*)buffer; chunkHead_->capacity = size - sizeof(ChunkHeader); chunkHead_->size = 0; chunkHead_->next = 0; } //! Destructor. /*! This deallocates all memory chunks, excluding the user-supplied buffer. */ ~MemoryPoolAllocator() { Clear(); delete ownBaseAllocator_; } //! Deallocates all memory chunks, excluding the user-supplied buffer. void Clear() { while(chunkHead_ != 0 && chunkHead_ != (ChunkHeader *)userBuffer_) { ChunkHeader* next = chunkHead_->next; baseAllocator_->Free(chunkHead_); chunkHead_ = next; } } //! Computes the total capacity of allocated memory chunks. /*! \return total capacity in bytes. */ size_t Capacity() { size_t capacity = 0; for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) capacity += c->capacity; return capacity; } //! Computes the memory blocks allocated. /*! \return total used bytes. */ size_t Size() { size_t size = 0; for (ChunkHeader* c = chunkHead_; c != 0; c = c->next) size += c->size; return size; } //! Allocates a memory block. (concept Allocator) void* Malloc(size_t size) { size = (size + 3) & ~3; // Force aligning size to 4 if (chunkHead_->size + size > chunkHead_->capacity) AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size); char *buffer = (char *)(chunkHead_ + 1) + chunkHead_->size; RAPIDJSON_ASSERT(((uintptr_t)buffer & 3) == 0); // returned buffer is aligned to 4 chunkHead_->size += size; return buffer; } //! Resizes a memory block (concept Allocator) void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { if (originalPtr == 0) return Malloc(newSize); // Do not shrink if new size is smaller than original if (originalSize >= newSize) return originalPtr; // Simply expand it if it is the last allocation and there is sufficient space if (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) { size_t increment = newSize - originalSize; increment = (increment + 3) & ~3; // Force aligning size to 4 if (chunkHead_->size + increment <= chunkHead_->capacity) { chunkHead_->size += increment; RAPIDJSON_ASSERT(((uintptr_t)originalPtr & 3) == 0); // returned buffer is aligned to 4 return originalPtr; } } // Realloc process: allocate and copy memory, do not free original buffer. void* newBuffer = Malloc(newSize); RAPIDJSON_ASSERT(newBuffer != 0); // Do not handle out-of-memory explicitly. return memcpy(newBuffer, originalPtr, originalSize); } //! Frees a memory block (concept Allocator) static void Free(void *) {} // Do nothing private: //! Creates a new chunk. /*! \param capacity Capacity of the chunk in bytes. */ void AddChunk(size_t capacity) { ChunkHeader* chunk = (ChunkHeader*)baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity); chunk->capacity = capacity; chunk->size = 0; chunk->next = chunkHead_; chunkHead_ = chunk; } static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity. //! Chunk header for perpending to each chunk. /*! Chunks are stored as a singly linked list. */ struct ChunkHeader { size_t capacity; //!< Capacity of the chunk in bytes (excluding the header itself). size_t size; //!< Current size of allocated memory in bytes. ChunkHeader *next; //!< Next chunk in the linked list. }; ChunkHeader *chunkHead_; //!< Head of the chunk linked-list. Only the head chunk serves allocation. size_t chunk_capacity_; //!< The minimum capacity of chunk when they are allocated. char *userBuffer_; //!< User supplied buffer. BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks. BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object. }; /////////////////////////////////////////////////////////////////////////////// // Encoding /*! \class rapidjson::Encoding \brief Concept for encoding of Unicode characters. \code concept Encoding { typename Ch; //! Type of character. //! \brief Encode a Unicode codepoint to a buffer. //! \param buffer pointer to destination buffer to store the result. It should have sufficient size of encoding one character. //! \param codepoint An unicode codepoint, ranging from 0x0 to 0x10FFFF inclusively. //! \returns the pointer to the next character after the encoded data. static Ch* Encode(Ch *buffer, unsigned codepoint); }; \endcode */ /////////////////////////////////////////////////////////////////////////////// // UTF8 //! UTF-8 encoding. /*! http://en.wikipedia.org/wiki/UTF-8 \tparam CharType Type for storing 8-bit UTF-8 data. Default is char. \implements Encoding */ template struct UTF8 { typedef CharType Ch; static Ch* Encode(Ch *buffer, unsigned codepoint) { if (codepoint <= 0x7F) *buffer++ = codepoint & 0xFF; else if (codepoint <= 0x7FF) { *buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF); *buffer++ = 0x80 | ((codepoint & 0x3F)); } else if (codepoint <= 0xFFFF) { *buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF); *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F); *buffer++ = 0x80 | (codepoint & 0x3F); } else { RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); *buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF); *buffer++ = 0x80 | ((codepoint >> 12) & 0x3F); *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F); *buffer++ = 0x80 | (codepoint & 0x3F); } return buffer; } }; /////////////////////////////////////////////////////////////////////////////// // UTF16 //! UTF-16 encoding. /*! http://en.wikipedia.org/wiki/UTF-16 \tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead. \implements Encoding */ template struct UTF16 { typedef CharType Ch; static Ch* Encode(Ch* buffer, unsigned codepoint) { if (codepoint <= 0xFFFF) { RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair *buffer++ = static_cast(codepoint); } else { RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); unsigned v = codepoint - 0x10000; *buffer++ = static_cast((v >> 10) + 0xD800); *buffer++ = (v & 0x3FF) + 0xDC00; } return buffer; } }; /////////////////////////////////////////////////////////////////////////////// // UTF32 //! UTF-32 encoding. /*! http://en.wikipedia.org/wiki/UTF-32 \tparam Ch Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead. \implements Encoding */ template struct UTF32 { typedef CharType Ch; static Ch *Encode(Ch* buffer, unsigned codepoint) { RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); *buffer++ = codepoint; return buffer; } }; /////////////////////////////////////////////////////////////////////////////// // Stream /*! \class rapidjson::Stream \brief Concept for reading and writing characters. For read-only stream, no need to implement PutBegin(), Put() and PutEnd(). For write-only stream, only need to implement Put(). \code concept Stream { typename Ch; //!< Character type of the stream. //! Read the current character from stream without moving the read cursor. Ch Peek() const; //! Read the current character from stream and moving the read cursor to next character. Ch Take(); //! Get the current read cursor. //! \return Number of characters read from start. size_t Tell(); //! Begin writing operation at the current read pointer. //! \return The begin writer pointer. Ch* PutBegin(); //! Write a character. void Put(Ch c); //! End the writing operation. //! \param begin The begin write pointer returned by PutBegin(). //! \return Number of characters written. size_t PutEnd(Ch* begin); } \endcode */ //! Put N copies of a character to a stream. template inline void PutN(Stream& stream, Ch c, size_t n) { for (size_t i = 0; i < n; i++) stream.Put(c); } /////////////////////////////////////////////////////////////////////////////// // StringStream //! Read-only string stream. /*! \implements Stream */ template struct GenericStringStream { typedef typename Encoding::Ch Ch; GenericStringStream(const Ch *src) : src_(src), head_(src) {} Ch Peek() const { return *src_; } Ch Take() { return *src_++; } size_t Tell() const { return src_ - head_; } Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } void Put(Ch) { RAPIDJSON_ASSERT(false); } size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } const Ch* src_; //!< Current read position. const Ch* head_; //!< Original head of the string. }; typedef GenericStringStream > StringStream; /////////////////////////////////////////////////////////////////////////////// // InsituStringStream //! A read-write string stream. /*! This string stream is particularly designed for in-situ parsing. \implements Stream */ template struct GenericInsituStringStream { typedef typename Encoding::Ch Ch; GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {} // Read Ch Peek() { return *src_; } Ch Take() { return *src_++; } size_t Tell() { return src_ - head_; } // Write Ch* PutBegin() { return dst_ = src_; } void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; } size_t PutEnd(Ch* begin) { return dst_ - begin; } Ch* src_; Ch* dst_; Ch* head_; }; typedef GenericInsituStringStream > InsituStringStream; /////////////////////////////////////////////////////////////////////////////// // Type //! Type of JSON value enum Type { kNullType = 0, //!< null kFalseType = 1, //!< false kTrueType = 2, //!< true kObjectType = 3, //!< object kArrayType = 4, //!< array kStringType = 5, //!< string kNumberType = 6, //!< number }; } // namespace rapidjson #endif // RAPIDJSON_RAPIDJSON_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/stringbuffer.h0000644000014601777760000000253712165464055025624 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_STRINGBUFFER_H_ #define RAPIDJSON_STRINGBUFFER_H_ #include "rapidjson.h" #include "internal/stack.h" namespace rapidjson { //! Represents an in-memory output stream. /*! \tparam Encoding Encoding of the stream. \tparam Allocator type for allocating memory buffer. \implements Stream */ template struct GenericStringBuffer { typedef typename Encoding::Ch Ch; GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} void Put(Ch c) { *stack_.template Push() = c; } void Clear() { stack_.Clear(); } const char* GetString() const { // Push and pop a null terminator. This is safe. *stack_.template Push() = '\0'; stack_.template Pop(1); return stack_.template Bottom(); } size_t Size() const { return stack_.GetSize(); } static const size_t kDefaultCapacity = 256; mutable internal::Stack stack_; }; typedef GenericStringBuffer > StringBuffer; //! Implement specialized version of PutN() with memset() for better performance. template<> inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { memset(stream.stack_.Push(n), c, n * sizeof(c)); } } // namespace rapidjson #endif // RAPIDJSON_STRINGBUFFER_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/filestream.h0000644000014601777760000000171112165464055025250 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_FILESTREAM_H_ #define RAPIDJSON_FILESTREAM_H_ #include namespace rapidjson { //! Wrapper of C file stream for input or output. /*! This simple wrapper does not check the validity of the stream. \implements Stream */ class FileStream { public: typedef char Ch; //!< Character type. Only support char. FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); } char Peek() const { return current_; } char Take() { char c = current_; Read(); return c; } size_t Tell() const { return count_; } void Put(char c) { fputc(c, fp_); } // Not implemented char* PutBegin() { return 0; } size_t PutEnd(char*) { return 0; } private: void Read() { RAPIDJSON_ASSERT(fp_ != 0); int c = fgetc(fp_); if (c != EOF) { current_ = (char)c; count_++; } else current_ = '\0'; } FILE* fp_; char current_; size_t count_; }; } // namespace rapidjson #endif // RAPIDJSON_FILESTREAM_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/prettywriter.h0000644000014601777760000001230112165464055025676 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_PRETTYWRITER_H_ #define RAPIDJSON_PRETTYWRITER_H_ #include "writer.h" namespace rapidjson { //! Writer with indentation and spacing. /*! \tparam Stream Type of ouptut stream. \tparam Encoding Encoding of both source strings and output. \tparam Allocator Type of allocator for allocating memory of stack. */ template, typename Allocator = MemoryPoolAllocator<> > class PrettyWriter : public Writer { public: typedef Writer Base; typedef typename Base::Ch Ch; //! Constructor /*! \param stream Output stream. \param allocator User supplied allocator. If it is null, it will create a private one. \param levelDepth Initial capacity of */ PrettyWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : Base(stream, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {} //! Set custom indentation. /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r'). \param indentCharCount Number of indent characters for each indentation level. \note The default indentation is 4 spaces. */ PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) { RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r'); indentChar_ = indentChar; indentCharCount_ = indentCharCount; return *this; } //@name Implementation of Handler. //@{ PrettyWriter& Null() { PrettyPrefix(kNullType); Base::WriteNull(); return *this; } PrettyWriter& Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); Base::WriteBool(b); return *this; } PrettyWriter& Int(int i) { PrettyPrefix(kNumberType); Base::WriteInt(i); return *this; } PrettyWriter& Uint(unsigned u) { PrettyPrefix(kNumberType); Base::WriteUint(u); return *this; } PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; } PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; } PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; } PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) { (void)copy; PrettyPrefix(kStringType); Base::WriteString(str, length); return *this; } PrettyWriter& StartObject() { PrettyPrefix(kObjectType); new (Base::level_stack_.template Push()) typename Base::Level(false); Base::WriteStartObject(); return *this; } PrettyWriter& EndObject(SizeType memberCount = 0) { (void)memberCount; RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); RAPIDJSON_ASSERT(!Base::level_stack_.template Top()->inArray); bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; if (!empty) { Base::stream_.Put('\n'); WriteIndent(); } Base::WriteEndObject(); return *this; } PrettyWriter& StartArray() { PrettyPrefix(kArrayType); new (Base::level_stack_.template Push()) typename Base::Level(true); Base::WriteStartArray(); return *this; } PrettyWriter& EndArray(SizeType memberCount = 0) { (void)memberCount; RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray); bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; if (!empty) { Base::stream_.Put('\n'); WriteIndent(); } Base::WriteEndArray(); return *this; } //@} //! Simpler but slower overload. PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); } protected: void PrettyPrefix(Type type) { (void)type; if (Base::level_stack_.GetSize() != 0) { // this value is not at root typename Base::Level* level = Base::level_stack_.template Top(); if (level->inArray) { if (level->valueCount > 0) { Base::stream_.Put(','); // add comma if it is not the first element in array Base::stream_.Put('\n'); } else Base::stream_.Put('\n'); WriteIndent(); } else { // in object if (level->valueCount > 0) { if (level->valueCount % 2 == 0) { Base::stream_.Put(','); Base::stream_.Put('\n'); } else { Base::stream_.Put(':'); Base::stream_.Put(' '); } } else Base::stream_.Put('\n'); if (level->valueCount % 2 == 0) WriteIndent(); } if (!level->inArray && level->valueCount % 2 == 0) RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name level->valueCount++; } else RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); } void WriteIndent() { size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_; PutN(Base::stream_, indentChar_, count); } Ch indentChar_; unsigned indentCharCount_; }; } // namespace rapidjson #endif // RAPIDJSON_RAPIDJSON_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/writer.h0000644000014601777760000001553512165464055024442 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_WRITER_H_ #define RAPIDJSON_WRITER_H_ #include "rapidjson.h" #include "internal/stack.h" #include "internal/strfunc.h" #include // snprintf() or _sprintf_s() #include // placement new #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4127) // conditional expression is constant #endif namespace rapidjson { //! JSON writer /*! Writer implements the concept Handler. It generates JSON text by events to an output stream. User may programmatically calls the functions of a writer to generate JSON text. On the other side, a writer can also be passed to objects that generates events, for example Reader::Parse() and Document::Accept(). \tparam Stream Type of ouptut stream. \tparam Encoding Encoding of both source strings and output. \implements Handler */ template, typename Allocator = MemoryPoolAllocator<> > class Writer { public: typedef typename Encoding::Ch Ch; Writer(Stream& stream, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level)) {} //@name Implementation of Handler //@{ Writer& Null() { Prefix(kNullType); WriteNull(); return *this; } Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; } Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); return *this; } Writer& Uint(unsigned u) { Prefix(kNumberType); WriteUint(u); return *this; } Writer& Int64(int64_t i64) { Prefix(kNumberType); WriteInt64(i64); return *this; } Writer& Uint64(uint64_t u64) { Prefix(kNumberType); WriteUint64(u64); return *this; } Writer& Double(double d) { Prefix(kNumberType); WriteDouble(d); return *this; } Writer& String(const Ch* str, SizeType length, bool copy = false) { (void)copy; Prefix(kStringType); WriteString(str, length); return *this; } Writer& StartObject() { Prefix(kObjectType); new (level_stack_.template Push()) Level(false); WriteStartObject(); return *this; } Writer& EndObject(SizeType memberCount = 0) { (void)memberCount; RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); RAPIDJSON_ASSERT(!level_stack_.template Top()->inArray); level_stack_.template Pop(1); WriteEndObject(); return *this; } Writer& StartArray() { Prefix(kArrayType); new (level_stack_.template Push()) Level(true); WriteStartArray(); return *this; } Writer& EndArray(SizeType elementCount = 0) { (void)elementCount; RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); RAPIDJSON_ASSERT(level_stack_.template Top()->inArray); level_stack_.template Pop(1); WriteEndArray(); return *this; } //@} //! Simpler but slower overload. Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); } protected: //! Information for each nested level struct Level { Level(bool inArray_) : inArray(inArray_), valueCount(0) {} bool inArray; //!< true if in array, otherwise in object size_t valueCount; //!< number of values in this level }; static const size_t kDefaultLevelDepth = 32; void WriteNull() { stream_.Put('n'); stream_.Put('u'); stream_.Put('l'); stream_.Put('l'); } void WriteBool(bool b) { if (b) { stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e'); } else { stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e'); } } void WriteInt(int i) { if (i < 0) { stream_.Put('-'); i = -i; } WriteUint((unsigned)i); } void WriteUint(unsigned u) { char buffer[10]; char *p = buffer; do { *p++ = (u % 10) + '0'; u /= 10; } while (u > 0); do { --p; stream_.Put(*p); } while (p != buffer); } void WriteInt64(int64_t i64) { if (i64 < 0) { stream_.Put('-'); i64 = -i64; } WriteUint64((uint64_t)i64); } void WriteUint64(uint64_t u64) { char buffer[20]; char *p = buffer; do { *p++ = char(u64 % 10) + '0'; u64 /= 10; } while (u64 > 0); do { --p; stream_.Put(*p); } while (p != buffer); } //! \todo Optimization with custom double-to-string converter. void WriteDouble(double d) { char buffer[100]; #if _MSC_VER int ret = sprintf_s(buffer, sizeof(buffer), "%g", d); #else int ret = snprintf(buffer, sizeof(buffer), "%g", d); #endif RAPIDJSON_ASSERT(ret >= 1); for (int i = 0; i < ret; i++) stream_.Put(buffer[i]); } void WriteString(const Ch* str, SizeType length) { static const char hexDigits[] = "0123456789ABCDEF"; static const char escape[256] = { #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //0 1 2 3 4 5 6 7 8 9 A B C D E F 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 Z16, Z16, // 30~4F 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50 Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF #undef Z16 }; stream_.Put('\"'); for (const Ch* p = str; p != str + length; ++p) { if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) { stream_.Put('\\'); stream_.Put(escape[(unsigned char)*p]); if (escape[(unsigned char)*p] == 'u') { stream_.Put('0'); stream_.Put('0'); stream_.Put(hexDigits[(*p) >> 4]); stream_.Put(hexDigits[(*p) & 0xF]); } } else stream_.Put(*p); } stream_.Put('\"'); } void WriteStartObject() { stream_.Put('{'); } void WriteEndObject() { stream_.Put('}'); } void WriteStartArray() { stream_.Put('['); } void WriteEndArray() { stream_.Put(']'); } void Prefix(Type type) { (void)type; if (level_stack_.GetSize() != 0) { // this value is not at root Level* level = level_stack_.template Top(); if (level->valueCount > 0) { if (level->inArray) stream_.Put(','); // add comma if it is not the first element in array else // in object stream_.Put((level->valueCount % 2 == 0) ? ',' : ':'); } if (!level->inArray && level->valueCount % 2 == 0) RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name level->valueCount++; } else RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); } Stream& stream_; internal::Stack level_stack_; private: // Prohibit assignment for VC C4512 warning Writer& operator=(const Writer& w); }; } // namespace rapidjson #ifdef _MSC_VER #pragma warning(pop) #endif #endif // RAPIDJSON_RAPIDJSON_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/internal/0000755000014601777760000000000012165464055024560 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/rapidjson/include/rapidjson/internal/stack.h0000644000014601777760000000446412165464055026046 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_INTERNAL_STACK_H_ #define RAPIDJSON_INTERNAL_STACK_H_ namespace rapidjson { namespace internal { /////////////////////////////////////////////////////////////////////////////// // Stack //! A type-unsafe stack for storing different types of data. /*! \tparam Allocator Allocator for allocating stack memory. */ template class Stack { public: Stack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) { RAPIDJSON_ASSERT(stack_capacity_ > 0); if (!allocator_) own_allocator_ = allocator_ = new Allocator(); stack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_); stack_end_ = stack_ + stack_capacity_; } ~Stack() { Allocator::Free(stack_); delete own_allocator_; // Only delete if it is owned by the stack } void Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; } template T* Push(size_t count = 1) { // Expand the stack if needed if (stack_top_ + sizeof(T) * count >= stack_end_) { size_t new_capacity = stack_capacity_ * 2; size_t size = GetSize(); size_t new_size = GetSize() + sizeof(T) * count; if (new_capacity < new_size) new_capacity = new_size; stack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity); stack_capacity_ = new_capacity; stack_top_ = stack_ + size; stack_end_ = stack_ + stack_capacity_; } T* ret = (T*)stack_top_; stack_top_ += sizeof(T) * count; return ret; } template T* Pop(size_t count) { RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T)); stack_top_ -= count * sizeof(T); return (T*)stack_top_; } template T* Top() { RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); return (T*)(stack_top_ - sizeof(T)); } template T* Bottom() { return (T*)stack_; } Allocator& GetAllocator() { return *allocator_; } size_t GetSize() const { return stack_top_ - stack_; } size_t GetCapacity() const { return stack_capacity_; } private: Allocator* allocator_; Allocator* own_allocator_; char *stack_; char *stack_top_; char *stack_end_; size_t stack_capacity_; }; } // namespace internal } // namespace rapidjson #endif // RAPIDJSON_STACK_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/internal/strfunc.h0000644000014601777760000000125012165464055026413 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ #define RAPIDJSON_INTERNAL_STRFUNC_H_ namespace rapidjson { namespace internal { //! Custom strlen() which works on different character types. /*! \tparam Ch Character type (e.g. char, wchar_t, short) \param s Null-terminated input string. \return Number of characters in the string. \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. */ template inline SizeType StrLen(const Ch* s) { const Ch* p = s; while (*p != '\0') ++p; return SizeType(p - s); } } // namespace internal } // namespace rapidjson #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/internal/pow10.h0000644000014601777760000001161512165464055025703 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_POW10_ #define RAPIDJSON_POW10_ namespace rapidjson { namespace internal { //! Computes integer powers of 10 in double (10.0^n). /*! This function uses lookup table for fast and accurate results. \param n positive/negative exponent. Must <= 308. \return 10.0^n */ inline double Pow10(int n) { static const double e[] = { // 1e-308...1e308: 617 * 8 bytes = 4936 bytes 1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300, 1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280, 1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260, 1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240, 1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220, 1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200, 1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180, 1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160, 1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140, 1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120, 1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e+0, 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 }; RAPIDJSON_ASSERT(n <= 308); return n < -308 ? 0.0 : e[n + 308]; } } // namespace internal } // namespace rapidjson #endif // RAPIDJSON_POW10_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/document.h0000644000014601777760000007145712165464055024751 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_DOCUMENT_H_ #define RAPIDJSON_DOCUMENT_H_ #include "reader.h" #include "internal/strfunc.h" #include // placement new #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4127) // conditional expression is constant #endif namespace rapidjson { /////////////////////////////////////////////////////////////////////////////// // GenericValue //! Represents a JSON value. Use Value for UTF8 encoding and default allocator. /*! A JSON value can be one of 7 types. This class is a variant type supporting these types. Use the Value if UTF8 and default allocator \tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document) \tparam Allocator Allocator type for allocating memory of object, array and string. */ #pragma pack (push, 4) template > class GenericValue { public: //! Name-value pair in an object. struct Member { GenericValue name; //!< name of member (must be a string) GenericValue value; //!< value of member. }; typedef Encoding EncodingType; //!< Encoding type from template parameter. typedef Allocator AllocatorType; //!< Allocator type from template parameter. typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. typedef Member* MemberIterator; //!< Member iterator for iterating in object. typedef const Member* ConstMemberIterator; //!< Constant member iterator for iterating in object. typedef GenericValue* ValueIterator; //!< Value iterator for iterating in array. typedef const GenericValue* ConstValueIterator; //!< Constant value iterator for iterating in array. //!@name Constructors and destructor. //@{ //! Default constructor creates a null value. GenericValue() : flags_(kNullFlag) {} //! Copy constructor is not permitted. private: GenericValue(const GenericValue& rhs); public: //! Constructor with JSON value type. /*! This creates a Value of specified type with default content. \param type Type of the value. \note Default content for number is zero. */ GenericValue(Type type) { static const unsigned defaultFlags[7] = { kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kConstStringFlag, kNumberFlag | kIntFlag | kUintFlag | kInt64Flag | kUint64Flag | kDoubleFlag }; RAPIDJSON_ASSERT(type <= kNumberType); flags_ = defaultFlags[type]; memset(&data_, 0, sizeof(data_)); } //! Constructor for boolean value. GenericValue(bool b) : flags_(b ? kTrueFlag : kFalseFlag) {} //! Constructor for int value. GenericValue(int i) : flags_(kNumberIntFlag) { data_.n.i64 = i; if (i >= 0) flags_ |= kUintFlag | kUint64Flag; } //! Constructor for unsigned value. GenericValue(unsigned u) : flags_(kNumberUintFlag) { data_.n.u64 = u; if (!(u & 0x80000000)) flags_ |= kIntFlag | kInt64Flag; } //! Constructor for int64_t value. GenericValue(int64_t i64) : flags_(kNumberInt64Flag) { data_.n.i64 = i64; if (i64 >= 0) { flags_ |= kNumberUint64Flag; if (!(i64 & 0xFFFFFFFF00000000LL)) flags_ |= kUintFlag; if (!(i64 & 0xFFFFFFFF80000000LL)) flags_ |= kIntFlag; } else if (i64 >= -2147483648LL) flags_ |= kIntFlag; } //! Constructor for uint64_t value. GenericValue(uint64_t u64) : flags_(kNumberUint64Flag) { data_.n.u64 = u64; if (!(u64 & 0x8000000000000000ULL)) flags_ |= kInt64Flag; if (!(u64 & 0xFFFFFFFF00000000ULL)) flags_ |= kUintFlag; if (!(u64 & 0xFFFFFFFF80000000ULL)) flags_ |= kIntFlag; } //! Constructor for double value. GenericValue(double d) : flags_(kNumberDoubleFlag) { data_.n.d = d; } //! Constructor for constant string (i.e. do not make a copy of string) GenericValue(const Ch* s, SizeType length) { RAPIDJSON_ASSERT(s != NULL); flags_ = kConstStringFlag; data_.s.str = s; data_.s.length = length; } //! Constructor for constant string (i.e. do not make a copy of string) GenericValue(const Ch* s) { SetStringRaw(s, internal::StrLen(s)); } //! Constructor for copy-string (i.e. do make a copy of string) GenericValue(const Ch* s, SizeType length, Allocator& allocator) { SetStringRaw(s, length, allocator); } //! Constructor for copy-string (i.e. do make a copy of string) GenericValue(const Ch*s, Allocator& allocator) { SetStringRaw(s, internal::StrLen(s), allocator); } //! Destructor. /*! Need to destruct elements of array, members of object, or copy-string. */ ~GenericValue() { if (Allocator::kNeedFree) { // Shortcut by Allocator's trait switch(flags_) { case kArrayFlag: for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v) v->~GenericValue(); Allocator::Free(data_.a.elements); break; case kObjectFlag: for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) { m->name.~GenericValue(); m->value.~GenericValue(); } Allocator::Free(data_.o.members); break; case kCopyStringFlag: Allocator::Free(const_cast(data_.s.str)); break; } } } //@} //!@name Assignment operators //@{ //! Assignment with move semantics. /*! \param rhs Source of the assignment. It will become a null value after assignment. */ GenericValue& operator=(GenericValue& rhs) { RAPIDJSON_ASSERT(this != &rhs); this->~GenericValue(); memcpy(this, &rhs, sizeof(GenericValue)); rhs.flags_ = kNullFlag; return *this; } //! Assignment with primitive types. /*! \tparam T Either Type, int, unsigned, int64_t, uint64_t, const Ch* \param value The value to be assigned. */ template GenericValue& operator=(T value) { this->~GenericValue(); new (this) GenericValue(value); return *this; } //@} //!@name Type //@{ Type GetType() const { return static_cast(flags_ & kTypeMask); } bool IsNull() const { return flags_ == kNullFlag; } bool IsFalse() const { return flags_ == kFalseFlag; } bool IsTrue() const { return flags_ == kTrueFlag; } bool IsBool() const { return (flags_ & kBoolFlag) != 0; } bool IsObject() const { return flags_ == kObjectFlag; } bool IsArray() const { return flags_ == kArrayFlag; } bool IsNumber() const { return (flags_ & kNumberFlag) != 0; } bool IsInt() const { return (flags_ & kIntFlag) != 0; } bool IsUint() const { return (flags_ & kUintFlag) != 0; } bool IsInt64() const { return (flags_ & kInt64Flag) != 0; } bool IsUint64() const { return (flags_ & kUint64Flag) != 0; } bool IsDouble() const { return (flags_ & kDoubleFlag) != 0; } bool IsString() const { return (flags_ & kStringFlag) != 0; } //@} //!@name Null //@{ GenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; } //@} //!@name Bool //@{ bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return flags_ == kTrueFlag; } GenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; } //@} //!@name Object //@{ //! Set this value as an empty object. GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; } //! Get the value associated with the object's name. GenericValue& operator[](const Ch* name) { if (Member* member = FindMember(name)) return member->value; else { static GenericValue NullValue; return NullValue; } } const GenericValue& operator[](const Ch* name) const { return const_cast(*this)[name]; } //! Member iterators. ConstMemberIterator MemberBegin() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.members; } ConstMemberIterator MemberEnd() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.members + data_.o.size; } MemberIterator MemberBegin() { RAPIDJSON_ASSERT(IsObject()); return data_.o.members; } MemberIterator MemberEnd() { RAPIDJSON_ASSERT(IsObject()); return data_.o.members + data_.o.size; } //! Check whether a member exists in the object. bool HasMember(const Ch* name) const { return FindMember(name) != 0; } //! Add a member (name-value pair) to the object. /*! \param name A string value as name of member. \param value Value of any type. \param allocator Allocator for reallocating memory. \return The value itself for fluent API. \note The ownership of name and value will be transfered to this object if success. */ GenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) { RAPIDJSON_ASSERT(IsObject()); RAPIDJSON_ASSERT(name.IsString()); Object& o = data_.o; if (o.size >= o.capacity) { if (o.capacity == 0) { o.capacity = kDefaultObjectCapacity; o.members = (Member*)allocator.Malloc(o.capacity * sizeof(Member)); } else { SizeType oldCapacity = o.capacity; o.capacity *= 2; o.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member)); } } o.members[o.size].name.RawAssign(name); o.members[o.size].value.RawAssign(value); o.size++; return *this; } GenericValue& AddMember(const Ch* name, Allocator& nameAllocator, GenericValue& value, Allocator& allocator) { GenericValue n(name, internal::StrLen(name), nameAllocator); return AddMember(n, value, allocator); } GenericValue& AddMember(const Ch* name, GenericValue& value, Allocator& allocator) { GenericValue n(name, internal::StrLen(name)); return AddMember(n, value, allocator); } template GenericValue& AddMember(const Ch* name, T value, Allocator& allocator) { GenericValue n(name, internal::StrLen(name)); GenericValue v(value); return AddMember(n, v, allocator); } //! Remove a member in object by its name. /*! \param name Name of member to be removed. \return Whether the member existed. \note Removing member is implemented by moving the last member. So the ordering of members is changed. */ bool RemoveMember(const Ch* name) { RAPIDJSON_ASSERT(IsObject()); if (Member* m = FindMember(name)) { RAPIDJSON_ASSERT(data_.o.size > 0); RAPIDJSON_ASSERT(data_.o.members != 0); Member* last = data_.o.members + (data_.o.size - 1); if (data_.o.size > 1 && m != last) { // Move the last one to this place m->name = last->name; m->value = last->value; } else { // Only one left, just destroy m->name.~GenericValue(); m->value.~GenericValue(); } --data_.o.size; return true; } return false; } //@} //!@name Array //@{ //! Set this value as an empty array. GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; } //! Get the number of elements in array. SizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; } //! Get the capacity of array. SizeType Capacity() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.capacity; } //! Check whether the array is empty. bool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size == 0; } //! Remove all elements in the array. /*! This function do not deallocate memory in the array, i.e. the capacity is unchanged. */ void Clear() { RAPIDJSON_ASSERT(IsArray()); for (SizeType i = 0; i < data_.a.size; ++i) data_.a.elements[i].~GenericValue(); data_.a.size = 0; } //! Get an element from array by index. /*! \param index Zero-based index of element. \note \code Value a(kArrayType); a.PushBack(123); int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type. int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work. int z = a[0u].GetInt(); // This works too. \endcode */ GenericValue& operator[](SizeType index) { RAPIDJSON_ASSERT(IsArray()); RAPIDJSON_ASSERT(index < data_.a.size); return data_.a.elements[index]; } const GenericValue& operator[](SizeType index) const { return const_cast(*this)[index]; } //! Element iterator ValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return data_.a.elements; } ValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return data_.a.elements + data_.a.size; } ConstValueIterator Begin() const { return const_cast(*this).Begin(); } ConstValueIterator End() const { return const_cast(*this).End(); } //! Request the array to have enough capacity to store elements. /*! \param newCapacity The capacity that the array at least need to have. \param allocator The allocator for allocating memory. It must be the same one use previously. \return The value itself for fluent API. */ GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) { RAPIDJSON_ASSERT(IsArray()); if (newCapacity > data_.a.capacity) { data_.a.elements = (GenericValue*)allocator.Realloc(data_.a.elements, data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue)); data_.a.capacity = newCapacity; } return *this; } //! Append a value at the end of the array. /*! \param value The value to be appended. \param allocator The allocator for allocating memory. It must be the same one use previously. \return The value itself for fluent API. \note The ownership of the value will be transfered to this object if success. \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. */ GenericValue& PushBack(GenericValue& value, Allocator& allocator) { RAPIDJSON_ASSERT(IsArray()); if (data_.a.size >= data_.a.capacity) Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator); data_.a.elements[data_.a.size++].RawAssign(value); return *this; } template GenericValue& PushBack(T value, Allocator& allocator) { GenericValue v(value); return PushBack(v, allocator); } //! Remove the last element in the array. GenericValue& PopBack() { RAPIDJSON_ASSERT(IsArray()); RAPIDJSON_ASSERT(!Empty()); data_.a.elements[--data_.a.size].~GenericValue(); return *this; } //@} //!@name Number //@{ int GetInt() const { RAPIDJSON_ASSERT(flags_ & kIntFlag); return data_.n.i.i; } unsigned GetUint() const { RAPIDJSON_ASSERT(flags_ & kUintFlag); return data_.n.u.u; } int64_t GetInt64() const { RAPIDJSON_ASSERT(flags_ & kInt64Flag); return data_.n.i64; } uint64_t GetUint64() const { RAPIDJSON_ASSERT(flags_ & kUint64Flag); return data_.n.u64; } double GetDouble() const { RAPIDJSON_ASSERT(IsNumber()); if ((flags_ & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion. if ((flags_ & kIntFlag) != 0) return data_.n.i.i; // int -> double if ((flags_ & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double if ((flags_ & kInt64Flag) != 0) return (double)data_.n.i64; // int64_t -> double (may lose precision) RAPIDJSON_ASSERT((flags_ & kUint64Flag) != 0); return (double)data_.n.u64; // uint64_t -> double (may lose precision) } GenericValue& SetInt(int i) { this->~GenericValue(); new (this) GenericValue(i); return *this; } GenericValue& SetUint(unsigned u) { this->~GenericValue(); new (this) GenericValue(u); return *this; } GenericValue& SetInt64(int64_t i64) { this->~GenericValue(); new (this) GenericValue(i64); return *this; } GenericValue& SetUint64(uint64_t u64) { this->~GenericValue(); new (this) GenericValue(u64); return *this; } GenericValue& SetDouble(double d) { this->~GenericValue(); new (this) GenericValue(d); return *this; } //@} //!@name String //@{ const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return data_.s.str; } //! Get the length of string. /*! Since rapidjson permits "\u0000" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength(). */ SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return data_.s.length; } //! Set this value as a string without copying source string. /*! This version has better performance with supplied length, and also support string containing null character. \param s source string pointer. \param length The length of source string, excluding the trailing null terminator. \return The value itself for fluent API. */ GenericValue& SetString(const Ch* s, SizeType length) { this->~GenericValue(); SetStringRaw(s, length); return *this; } //! Set this value as a string without copying source string. /*! \param s source string pointer. \return The value itself for fluent API. */ GenericValue& SetString(const Ch* s) { return SetString(s, internal::StrLen(s)); } //! Set this value as a string by copying from source string. /*! This version has better performance with supplied length, and also support string containing null character. \param s source string. \param length The length of source string, excluding the trailing null terminator. \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). \return The value itself for fluent API. */ GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(s, length, allocator); return *this; } //! Set this value as a string by copying from source string. /*! \param s source string. \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). \return The value itself for fluent API. */ GenericValue& SetString(const Ch* s, Allocator& allocator) { SetString(s, internal::StrLen(s), allocator); return *this; } //@} //! Generate events of this value to a Handler. /*! This function adopts the GoF visitor pattern. Typical usage is to output this JSON value as JSON text via Writer, which is a Handler. It can also be used to deep clone this value via GenericDocument, which is also a Handler. \tparam Handler type of handler. \param handler An object implementing concept Handler. */ template const GenericValue& Accept(Handler& handler) const { switch(GetType()) { case kNullType: handler.Null(); break; case kFalseType: handler.Bool(false); break; case kTrueType: handler.Bool(true); break; case kObjectType: handler.StartObject(); for (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) { handler.String(m->name.data_.s.str, m->name.data_.s.length, false); m->value.Accept(handler); } handler.EndObject(data_.o.size); break; case kArrayType: handler.StartArray(); for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v) v->Accept(handler); handler.EndArray(data_.a.size); break; case kStringType: handler.String(data_.s.str, data_.s.length, false); break; case kNumberType: if (IsInt()) handler.Int(data_.n.i.i); else if (IsUint()) handler.Uint(data_.n.u.u); else if (IsInt64()) handler.Int64(data_.n.i64); else if (IsUint64()) handler.Uint64(data_.n.u64); else handler.Double(data_.n.d); break; } return *this; } private: template friend class GenericDocument; enum { kBoolFlag = 0x100, kNumberFlag = 0x200, kIntFlag = 0x400, kUintFlag = 0x800, kInt64Flag = 0x1000, kUint64Flag = 0x2000, kDoubleFlag = 0x4000, kStringFlag = 0x100000, kCopyFlag = 0x200000, // Initial flags of different types. kNullFlag = kNullType, kTrueFlag = kTrueType | kBoolFlag, kFalseFlag = kFalseType | kBoolFlag, kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag, kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag, kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag, kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag, kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag, kConstStringFlag = kStringType | kStringFlag, kCopyStringFlag = kStringType | kStringFlag | kCopyFlag, kObjectFlag = kObjectType, kArrayFlag = kArrayType, kTypeMask = 0xFF // bitwise-and with mask of 0xFF can be optimized by compiler }; static const SizeType kDefaultArrayCapacity = 16; static const SizeType kDefaultObjectCapacity = 16; struct String { const Ch* str; SizeType length; unsigned hashcode; //!< reserved }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode // By using proper binary layout, retrieval of different integer types do not need conversions. union Number { #if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN struct I { int i; char padding[4]; }i; struct U { unsigned u; char padding2[4]; }u; #else struct I { char padding[4]; int i; }i; struct U { char padding2[4]; unsigned u; }u; #endif int64_t i64; uint64_t u64; double d; }; // 8 bytes struct Object { Member* members; SizeType size; SizeType capacity; }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode struct Array { GenericValue* elements; SizeType size; SizeType capacity; }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode union Data { String s; Number n; Object o; Array a; }; // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode //! Find member by name. Member* FindMember(const Ch* name) { RAPIDJSON_ASSERT(name); RAPIDJSON_ASSERT(IsObject()); SizeType length = internal::StrLen(name); Object& o = data_.o; for (Member* member = o.members; member != data_.o.members + data_.o.size; ++member) if (length == member->name.data_.s.length && memcmp(member->name.data_.s.str, name, length * sizeof(Ch)) == 0) return member; return 0; } const Member* FindMember(const Ch* name) const { return const_cast(*this).FindMember(name); } // Initialize this value as array with initial data, without calling destructor. void SetArrayRaw(GenericValue* values, SizeType count, Allocator& alloctaor) { flags_ = kArrayFlag; data_.a.elements = (GenericValue*)alloctaor.Malloc(count * sizeof(GenericValue)); memcpy(data_.a.elements, values, count * sizeof(GenericValue)); data_.a.size = data_.a.capacity = count; } //! Initialize this value as object with initial data, without calling destructor. void SetObjectRaw(Member* members, SizeType count, Allocator& alloctaor) { flags_ = kObjectFlag; data_.o.members = (Member*)alloctaor.Malloc(count * sizeof(Member)); memcpy(data_.o.members, members, count * sizeof(Member)); data_.o.size = data_.o.capacity = count; } //! Initialize this value as constant string, without calling destructor. void SetStringRaw(const Ch* s, SizeType length) { RAPIDJSON_ASSERT(s != NULL); flags_ = kConstStringFlag; data_.s.str = s; data_.s.length = length; } //! Initialize this value as copy string with initial data, without calling destructor. void SetStringRaw(const Ch* s, SizeType length, Allocator& allocator) { RAPIDJSON_ASSERT(s != NULL); flags_ = kCopyStringFlag; data_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch)); data_.s.length = length; memcpy(const_cast(data_.s.str), s, length * sizeof(Ch)); const_cast(data_.s.str)[length] = '\0'; } //! Assignment without calling destructor void RawAssign(GenericValue& rhs) { memcpy(this, &rhs, sizeof(GenericValue)); rhs.flags_ = kNullFlag; } Data data_; unsigned flags_; }; #pragma pack (pop) //! Value with UTF8 encoding. typedef GenericValue > Value; /////////////////////////////////////////////////////////////////////////////// // GenericDocument //! A document for parsing JSON text as DOM. /*! \implements Handler \tparam Encoding encoding for both parsing and string storage. \tparam Alloactor allocator for allocating memory for the DOM, and the stack during parsing. */ template > class GenericDocument : public GenericValue { public: typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. typedef GenericValue ValueType; //!< Value type of the document. typedef Allocator AllocatorType; //!< Allocator type from template parameter. //! Constructor /*! \param allocator Optional allocator for allocating stack memory. \param stackCapacity Initial capacity of stack in bytes. */ GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseError_(0), errorOffset_(0) {} //! Parse JSON text from an input stream. /*! \tparam parseFlags Combination of ParseFlag. \param stream Input stream to be parsed. \return The document itself for fluent API. */ template GenericDocument& ParseStream(Stream& stream) { ValueType::SetNull(); // Remove existing root if exist GenericReader reader; if (reader.template Parse(stream, *this)) { RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object this->RawAssign(*stack_.template Pop(1)); // Add this-> to prevent issue 13. parseError_ = 0; errorOffset_ = 0; } else { parseError_ = reader.GetParseError(); errorOffset_ = reader.GetErrorOffset(); ClearStack(); } return *this; } //! Parse JSON text from a mutable string. /*! \tparam parseFlags Combination of ParseFlag. \param str Mutable zero-terminated string to be parsed. \return The document itself for fluent API. */ template GenericDocument& ParseInsitu(Ch* str) { GenericInsituStringStream s(str); return ParseStream(s); } //! Parse JSON text from a read-only string. /*! \tparam parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). \param str Read-only zero-terminated string to be parsed. */ template GenericDocument& Parse(const Ch* str) { RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag)); GenericStringStream s(str); return ParseStream(s); } //! Whether a parse error was occured in the last parsing. bool HasParseError() const { return parseError_ != 0; } //! Get the message of parsing error. const char* GetParseError() const { return parseError_; } //! Get the offset in character of the parsing error. size_t GetErrorOffset() const { return errorOffset_; } //! Get the allocator of this document. Allocator& GetAllocator() { return stack_.GetAllocator(); } //! Get the capacity of stack in bytes. size_t GetStackCapacity() const { return stack_.GetCapacity(); } private: // Prohibit assignment GenericDocument& operator=(const GenericDocument&); friend class GenericReader; // for Reader to call the following private handler functions // Implementation of Handler void Null() { new (stack_.template Push()) ValueType(); } void Bool(bool b) { new (stack_.template Push()) ValueType(b); } void Int(int i) { new (stack_.template Push()) ValueType(i); } void Uint(unsigned i) { new (stack_.template Push()) ValueType(i); } void Int64(int64_t i) { new (stack_.template Push()) ValueType(i); } void Uint64(uint64_t i) { new (stack_.template Push()) ValueType(i); } void Double(double d) { new (stack_.template Push()) ValueType(d); } void String(const Ch* str, SizeType length, bool copy) { if (copy) new (stack_.template Push()) ValueType(str, length, GetAllocator()); else new (stack_.template Push()) ValueType(str, length); } void StartObject() { new (stack_.template Push()) ValueType(kObjectType); } void EndObject(SizeType memberCount) { typename ValueType::Member* members = stack_.template Pop(memberCount); stack_.template Top()->SetObjectRaw(members, (SizeType)memberCount, GetAllocator()); } void StartArray() { new (stack_.template Push()) ValueType(kArrayType); } void EndArray(SizeType elementCount) { ValueType* elements = stack_.template Pop(elementCount); stack_.template Top()->SetArrayRaw(elements, elementCount, GetAllocator()); } void ClearStack() { if (Allocator::kNeedFree) while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects) (stack_.template Pop(1))->~ValueType(); else stack_.Clear(); } static const size_t kDefaultStackCapacity = 1024; internal::Stack stack_; const char* parseError_; size_t errorOffset_; }; typedef GenericDocument > Document; } // namespace rapidjson #ifdef _MSC_VER #pragma warning(pop) #endif #endif // RAPIDJSON_DOCUMENT_H_ pdns-3.3/pdns/ext/rapidjson/include/rapidjson/reader.h0000644000014601777760000005013712165464055024365 0ustar00jenkinsnogroup00000000000000#ifndef RAPIDJSON_READER_H_ #define RAPIDJSON_READER_H_ // Copyright (c) 2011 Milo Yip (miloyip@gmail.com) // Version 0.1 #include "rapidjson.h" #include "internal/pow10.h" #include "internal/stack.h" #include #ifdef RAPIDJSON_SSE42 #include #elif defined(RAPIDJSON_SSE2) #include #endif #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4127) // conditional expression is constant #endif #ifndef RAPIDJSON_PARSE_ERROR #define RAPIDJSON_PARSE_ERROR(msg, offset) \ RAPIDJSON_MULTILINEMACRO_BEGIN \ parseError_ = msg; \ errorOffset_ = offset; \ longjmp(jmpbuf_, 1); \ RAPIDJSON_MULTILINEMACRO_END #endif namespace rapidjson { /////////////////////////////////////////////////////////////////////////////// // ParseFlag //! Combination of parseFlags enum ParseFlag { kParseDefaultFlags = 0, //!< Default parse flags. Non-destructive parsing. Text strings are decoded into allocated buffer. kParseInsituFlag = 1 //!< In-situ(destructive) parsing. }; /////////////////////////////////////////////////////////////////////////////// // Handler /*! \class rapidjson::Handler \brief Concept for receiving events from GenericReader upon parsing. \code concept Handler { typename Ch; void Null(); void Bool(bool b); void Int(int i); void Uint(unsigned i); void Int64(int64_t i); void Uint64(uint64_t i); void Double(double d); void String(const Ch* str, SizeType length, bool copy); void StartObject(); void EndObject(SizeType memberCount); void StartArray(); void EndArray(SizeType elementCount); }; \endcode */ /////////////////////////////////////////////////////////////////////////////// // BaseReaderHandler //! Default implementation of Handler. /*! This can be used as base class of any reader handler. \implements Handler */ template > struct BaseReaderHandler { typedef typename Encoding::Ch Ch; void Default() {} void Null() { Default(); } void Bool(bool) { Default(); } void Int(int) { Default(); } void Uint(unsigned) { Default(); } void Int64(int64_t) { Default(); } void Uint64(uint64_t) { Default(); } void Double(double) { Default(); } void String(const Ch*, SizeType, bool) { Default(); } void StartObject() { Default(); } void EndObject(SizeType) { Default(); } void StartArray() { Default(); } void EndArray(SizeType) { Default(); } }; /////////////////////////////////////////////////////////////////////////////// // SkipWhitespace //! Skip the JSON white spaces in a stream. /*! \param stream A input stream for skipping white spaces. \note This function has SSE2/SSE4.2 specialization. */ template void SkipWhitespace(Stream& stream) { Stream s = stream; // Use a local copy for optimization while (s.Peek() == ' ' || s.Peek() == '\n' || s.Peek() == '\r' || s.Peek() == '\t') s.Take(); stream = s; } #ifdef RAPIDJSON_SSE42 //! Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once. inline const char *SkipWhitespace_SIMD(const char* p) { static const char whitespace[16] = " \n\r\t"; __m128i w = _mm_loadu_si128((const __m128i *)&whitespace[0]); for (;;) { __m128i s = _mm_loadu_si128((const __m128i *)p); unsigned r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY)); if (r == 0) // all 16 characters are whitespace p += 16; else { // some of characters may be non-whitespace #ifdef _MSC_VER // Find the index of first non-whitespace unsigned long offset; if (_BitScanForward(&offset, r)) return p + offset; #else if (r != 0) return p + __builtin_ffs(r) - 1; #endif } } } #elif defined(RAPIDJSON_SSE2) //! Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once. inline const char *SkipWhitespace_SIMD(const char* p) { static const char whitespaces[4][17] = { " ", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"}; __m128i w0 = _mm_loadu_si128((const __m128i *)&whitespaces[0][0]); __m128i w1 = _mm_loadu_si128((const __m128i *)&whitespaces[1][0]); __m128i w2 = _mm_loadu_si128((const __m128i *)&whitespaces[2][0]); __m128i w3 = _mm_loadu_si128((const __m128i *)&whitespaces[3][0]); for (;;) { __m128i s = _mm_loadu_si128((const __m128i *)p); __m128i x = _mm_cmpeq_epi8(s, w0); x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1)); x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2)); x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3)); unsigned short r = ~_mm_movemask_epi8(x); if (r == 0) // all 16 characters are whitespace p += 16; else { // some of characters may be non-whitespace #ifdef _MSC_VER // Find the index of first non-whitespace unsigned long offset; if (_BitScanForward(&offset, r)) return p + offset; #else if (r != 0) return p + __builtin_ffs(r) - 1; #endif } } } #endif // RAPIDJSON_SSE2 #ifdef RAPIDJSON_SIMD //! Template function specialization for InsituStringStream template<> inline void SkipWhitespace(InsituStringStream& stream) { stream.src_ = const_cast(SkipWhitespace_SIMD(stream.src_)); } //! Template function specialization for StringStream template<> inline void SkipWhitespace(StringStream& stream) { stream.src_ = SkipWhitespace_SIMD(stream.src_); } #endif // RAPIDJSON_SIMD /////////////////////////////////////////////////////////////////////////////// // GenericReader //! SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. /*! GenericReader parses JSON text from a stream, and send events synchronously to an object implementing Handler concept. It needs to allocate a stack for storing a single decoded string during non-destructive parsing. For in-situ parsing, the decoded string is directly written to the source text string, no temporary buffer is required. A GenericReader object can be reused for parsing multiple JSON text. \tparam Encoding Encoding of both the stream and the parse output. \tparam Allocator Allocator type for stack. */ template > class GenericReader { public: typedef typename Encoding::Ch Ch; //! Constructor. /*! \param allocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing) \param stackCapacity stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing) */ GenericReader(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseError_(0), errorOffset_(0) {} //! Parse JSON text. /*! \tparam parseFlags Combination of ParseFlag. \tparam Stream Type of input stream. \tparam Handler Type of handler which must implement Handler concept. \param stream Input stream to be parsed. \param handler The handler to receive events. \return Whether the parsing is successful. */ template bool Parse(Stream& stream, Handler& handler) { parseError_ = 0; errorOffset_ = 0; #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable #endif if (setjmp(jmpbuf_)) { #ifdef _MSC_VER #pragma warning(pop) #endif stack_.Clear(); return false; } SkipWhitespace(stream); if (stream.Peek() == '\0') RAPIDJSON_PARSE_ERROR("Text only contains white space(s)", stream.Tell()); else { switch (stream.Peek()) { case '{': ParseObject(stream, handler); break; case '[': ParseArray(stream, handler); break; default: RAPIDJSON_PARSE_ERROR("Expect either an object or array at root", stream.Tell()); } SkipWhitespace(stream); if (stream.Peek() != '\0') RAPIDJSON_PARSE_ERROR("Nothing should follow the root object or array.", stream.Tell()); } return true; } bool HasParseError() const { return parseError_ != 0; } const char* GetParseError() const { return parseError_; } size_t GetErrorOffset() const { return errorOffset_; } private: // Parse object: { string : value, ... } template void ParseObject(Stream& stream, Handler& handler) { RAPIDJSON_ASSERT(stream.Peek() == '{'); stream.Take(); // Skip '{' handler.StartObject(); SkipWhitespace(stream); if (stream.Peek() == '}') { stream.Take(); handler.EndObject(0); // empty object return; } for (SizeType memberCount = 0;;) { if (stream.Peek() != '"') { RAPIDJSON_PARSE_ERROR("Name of an object member must be a string", stream.Tell()); break; } ParseString(stream, handler); SkipWhitespace(stream); if (stream.Take() != ':') { RAPIDJSON_PARSE_ERROR("There must be a colon after the name of object member", stream.Tell()); break; } SkipWhitespace(stream); ParseValue(stream, handler); SkipWhitespace(stream); ++memberCount; switch(stream.Take()) { case ',': SkipWhitespace(stream); break; case '}': handler.EndObject(memberCount); return; default: RAPIDJSON_PARSE_ERROR("Must be a comma or '}' after an object member", stream.Tell()); } } } // Parse array: [ value, ... ] template void ParseArray(Stream& stream, Handler& handler) { RAPIDJSON_ASSERT(stream.Peek() == '['); stream.Take(); // Skip '[' handler.StartArray(); SkipWhitespace(stream); if (stream.Peek() == ']') { stream.Take(); handler.EndArray(0); // empty array return; } for (SizeType elementCount = 0;;) { ParseValue(stream, handler); ++elementCount; SkipWhitespace(stream); switch (stream.Take()) { case ',': SkipWhitespace(stream); break; case ']': handler.EndArray(elementCount); return; default: RAPIDJSON_PARSE_ERROR("Must be a comma or ']' after an array element.", stream.Tell()); } } } template void ParseNull(Stream& stream, Handler& handler) { RAPIDJSON_ASSERT(stream.Peek() == 'n'); stream.Take(); if (stream.Take() == 'u' && stream.Take() == 'l' && stream.Take() == 'l') handler.Null(); else RAPIDJSON_PARSE_ERROR("Invalid value", stream.Tell() - 1); } template void ParseTrue(Stream& stream, Handler& handler) { RAPIDJSON_ASSERT(stream.Peek() == 't'); stream.Take(); if (stream.Take() == 'r' && stream.Take() == 'u' && stream.Take() == 'e') handler.Bool(true); else RAPIDJSON_PARSE_ERROR("Invalid value", stream.Tell()); } template void ParseFalse(Stream& stream, Handler& handler) { RAPIDJSON_ASSERT(stream.Peek() == 'f'); stream.Take(); if (stream.Take() == 'a' && stream.Take() == 'l' && stream.Take() == 's' && stream.Take() == 'e') handler.Bool(false); else RAPIDJSON_PARSE_ERROR("Invalid value", stream.Tell() - 1); } // Helper function to parse four hexidecimal digits in \uXXXX in ParseString(). template unsigned ParseHex4(Stream& stream) { Stream s = stream; // Use a local copy for optimization unsigned codepoint = 0; for (int i = 0; i < 4; i++) { Ch c = s.Take(); codepoint <<= 4; codepoint += c; if (c >= '0' && c <= '9') codepoint -= '0'; else if (c >= 'A' && c <= 'F') codepoint -= 'A' - 10; else if (c >= 'a' && c <= 'f') codepoint -= 'a' - 10; else RAPIDJSON_PARSE_ERROR("Incorrect hex digit after \\u escape", s.Tell() - 1); } stream = s; // Restore stream return codepoint; } // Parse string, handling the prefix and suffix double quotes and escaping. template void ParseString(Stream& stream, Handler& handler) { #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 static const Ch escape[256] = { Z16, Z16, 0, 0,'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'/', Z16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, 0, 0,'\b', 0, 0, 0,'\f', 0, 0, 0, 0, 0, 0, 0,'\n', 0, 0, 0,'\r', 0,'\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 }; #undef Z16 Stream s = stream; // Use a local copy for optimization RAPIDJSON_ASSERT(s.Peek() == '\"'); s.Take(); // Skip '\"' Ch *head; SizeType len; if (parseFlags & kParseInsituFlag) head = s.PutBegin(); else len = 0; #define RAPIDJSON_PUT(x) \ do { \ if (parseFlags & kParseInsituFlag) \ s.Put(x); \ else { \ *stack_.template Push() = x; \ ++len; \ } \ } while(false) for (;;) { Ch c = s.Take(); if (c == '\\') { // Escape Ch e = s.Take(); if ((sizeof(Ch) == 1 || e < 256) && escape[(unsigned char)e]) RAPIDJSON_PUT(escape[(unsigned char)e]); else if (e == 'u') { // Unicode unsigned codepoint = ParseHex4(s); if (codepoint >= 0xD800 && codepoint <= 0xDBFF) { // Handle UTF-16 surrogate pair if (s.Take() != '\\' || s.Take() != 'u') { RAPIDJSON_PARSE_ERROR("Missing the second \\u in surrogate pair", s.Tell() - 2); return; } unsigned codepoint2 = ParseHex4(s); if (codepoint2 < 0xDC00 || codepoint2 > 0xDFFF) { RAPIDJSON_PARSE_ERROR("The second \\u in surrogate pair is invalid", s.Tell() - 2); return; } codepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000; } Ch buffer[4]; SizeType count = SizeType(Encoding::Encode(buffer, codepoint) - &buffer[0]); if (parseFlags & kParseInsituFlag) for (SizeType i = 0; i < count; i++) s.Put(buffer[i]); else { memcpy(stack_.template Push(count), buffer, count * sizeof(Ch)); len += count; } } else { RAPIDJSON_PARSE_ERROR("Unknown escape character", stream.Tell() - 1); return; } } else if (c == '"') { // Closing double quote if (parseFlags & kParseInsituFlag) { size_t length = s.PutEnd(head); RAPIDJSON_ASSERT(length <= 0xFFFFFFFF); RAPIDJSON_PUT('\0'); // null-terminate the string handler.String(head, SizeType(length), false); } else { RAPIDJSON_PUT('\0'); handler.String(stack_.template Pop(len), len - 1, true); } stream = s; // restore stream return; } else if (c == '\0') { RAPIDJSON_PARSE_ERROR("lacks ending quotation before the end of string", stream.Tell() - 1); return; } else if ((unsigned)c < 0x20) { // RFC 4627: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF RAPIDJSON_PARSE_ERROR("Incorrect unescaped character in string", stream.Tell() - 1); return; } else RAPIDJSON_PUT(c); // Normal character, just copy } #undef RAPIDJSON_PUT } template void ParseNumber(Stream& stream, Handler& handler) { Stream s = stream; // Local copy for optimization // Parse minus bool minus = false; if (s.Peek() == '-') { minus = true; s.Take(); } // Parse int: zero / ( digit1-9 *DIGIT ) unsigned i; bool try64bit = false; if (s.Peek() == '0') { i = 0; s.Take(); } else if (s.Peek() >= '1' && s.Peek() <= '9') { i = s.Take() - '0'; if (minus) while (s.Peek() >= '0' && s.Peek() <= '9') { if (i >= 214748364) { // 2^31 = 2147483648 if (i != 214748364 || s.Peek() > '8') { try64bit = true; break; } } i = i * 10 + (s.Take() - '0'); } else while (s.Peek() >= '0' && s.Peek() <= '9') { if (i >= 429496729) { // 2^32 - 1 = 4294967295 if (i != 429496729 || s.Peek() > '5') { try64bit = true; break; } } i = i * 10 + (s.Take() - '0'); } } else { RAPIDJSON_PARSE_ERROR("Expect a value here.", stream.Tell()); return; } // Parse 64bit int uint64_t i64 = 0; bool useDouble = false; if (try64bit) { i64 = i; if (minus) while (s.Peek() >= '0' && s.Peek() <= '9') { if (i64 >= 922337203685477580uLL) // 2^63 = 9223372036854775808 if (i64 != 922337203685477580uLL || s.Peek() > '8') { useDouble = true; break; } i64 = i64 * 10 + (s.Take() - '0'); } else while (s.Peek() >= '0' && s.Peek() <= '9') { if (i64 >= 1844674407370955161uLL) // 2^64 - 1 = 18446744073709551615 if (i64 != 1844674407370955161uLL || s.Peek() > '5') { useDouble = true; break; } i64 = i64 * 10 + (s.Take() - '0'); } } // Force double for big integer double d = 0.0; if (useDouble) { d = (double)i64; while (s.Peek() >= '0' && s.Peek() <= '9') { if (d >= 1E307) { RAPIDJSON_PARSE_ERROR("Number too big to store in double", stream.Tell()); return; } d = d * 10 + (s.Take() - '0'); } } // Parse frac = decimal-point 1*DIGIT int expFrac = 0; if (s.Peek() == '.') { if (!useDouble) { d = try64bit ? (double)i64 : (double)i; useDouble = true; } s.Take(); if (s.Peek() >= '0' && s.Peek() <= '9') { d = d * 10 + (s.Take() - '0'); --expFrac; } else { RAPIDJSON_PARSE_ERROR("At least one digit in fraction part", stream.Tell()); return; } while (s.Peek() >= '0' && s.Peek() <= '9') { if (expFrac > -16) { d = d * 10 + (s.Peek() - '0'); --expFrac; } s.Take(); } } // Parse exp = e [ minus / plus ] 1*DIGIT int exp = 0; if (s.Peek() == 'e' || s.Peek() == 'E') { if (!useDouble) { d = try64bit ? (double)i64 : (double)i; useDouble = true; } s.Take(); bool expMinus = false; if (s.Peek() == '+') s.Take(); else if (s.Peek() == '-') { s.Take(); expMinus = true; } if (s.Peek() >= '0' && s.Peek() <= '9') { exp = s.Take() - '0'; while (s.Peek() >= '0' && s.Peek() <= '9') { exp = exp * 10 + (s.Take() - '0'); if (exp > 308) { RAPIDJSON_PARSE_ERROR("Number too big to store in double", stream.Tell()); return; } } } else { RAPIDJSON_PARSE_ERROR("At least one digit in exponent", s.Tell()); return; } if (expMinus) exp = -exp; } // Finish parsing, call event according to the type of number. if (useDouble) { d *= internal::Pow10(exp + expFrac); handler.Double(minus ? -d : d); } else { if (try64bit) { if (minus) handler.Int64(-(int64_t)i64); else handler.Uint64(i64); } else { if (minus) handler.Int(-(int)i); else handler.Uint(i); } } stream = s; // restore stream } // Parse any JSON value template void ParseValue(Stream& stream, Handler& handler) { switch (stream.Peek()) { case 'n': ParseNull (stream, handler); break; case 't': ParseTrue (stream, handler); break; case 'f': ParseFalse (stream, handler); break; case '"': ParseString(stream, handler); break; case '{': ParseObject(stream, handler); break; case '[': ParseArray (stream, handler); break; default : ParseNumber(stream, handler); } } static const size_t kDefaultStackCapacity = 256; //!< Default stack capacity in bytes for storing a single decoded string. internal::Stack stack_; //!< A stack for storing decoded string temporarily during non-destructive parsing. jmp_buf jmpbuf_; //!< setjmp buffer for fast exit from nested parsing function calls. const char* parseError_; size_t errorOffset_; }; // class GenericReader //! Reader with UTF8 encoding and default allocator. typedef GenericReader > Reader; } // namespace rapidjson #ifdef _MSC_VER #pragma warning(pop) #endif #endif // RAPIDJSON_READER_H_ pdns-3.3/pdns/ext/polarssl-1.1.2/0000755000014601777760000000000012165464055017633 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/polarssl-1.1.2/ChangeLog0000644000014601777760000005546312165464055021422 0ustar00jenkinsnogroup00000000000000PolarSSL ChangeLog = Version 1.1.2 released on 2012-04-26 Bugfix * Fixed handling error in mpi_cmp_mpi() on longer B values (found by Hui Dong) Security * Fixed potential memory corruption on miscrafted client messages (found by Frama-C team at CEA LIST) * Fixed generation of DHM parameters to correct length (found by Ruslan Yushchenko) = Version 1.1.1 released on 2012-01-23 Bugfix * Check for failed malloc() in ssl_set_hostname() and x509_get_entries() (Closes ticket #47, found by Hugo Leisink) * Fixed issues with Intel compiler on 64-bit systems (Closes ticket #50) * Fixed multiple compiler warnings for VS6 and armcc * Fixed bug in CTR_CRBG selftest = Version 1.1.0 released on 2011-12-22 Features * Added ssl_session_reset() to allow better multi-connection pools of SSL contexts without needing to set all non-connection-specific data and pointers again. Adapted ssl_server to use this functionality. * Added ssl_set_max_version() to allow clients to offer a lower maximum supported version to a server to help buggy server implementations. (Closes ticket #36) * Added cipher_get_cipher_mode() and cipher_get_cipher_operation() introspection functions (Closes ticket #40) * Added CTR_DRBG based on AES-256-CTR (NIST SP 800-90) random generator * Added a generic entropy accumulator that provides support for adding custom entropy sources and added some generic and platform dependent entropy sources Changes * Documentation for AES and Camellia in modes CTR and CFB128 clarified. * Fixed rsa_encrypt and rsa_decrypt examples to use public key for encryption and private key for decryption. (Closes ticket #34) * Inceased maximum size of ASN1 length reads to 32-bits. * Added an EXPLICIT tag number parameter to x509_get_ext() * Added a separate CRL entry extension parsing function * Separated the ASN.1 parsing code from the X.509 specific parsing code. So now there is a module that is controlled with POLARSSL_ASN1_PARSE_C. * Changed the defined key-length of DES ciphers in cipher.h to include the parity bits, to prevent mistakes in copying data. (Closes ticket #33) * Loads of minimal changes to better support WINCE as a build target (Credits go to Marco Lizza) * Added POLARSSL_MPI_WINDOW_SIZE definition to allow easier time to memory trade-off * Introduced POLARSSL_MPI_MAX_SIZE and POLARSSL_MPI_MAX_BITS for MPI size management (Closes ticket #44) * Changed the used random function pointer to more flexible format. Renamed havege_rand() to havege_random() to prevent mistakes. Lots of changes as a consequence in library code and programs * Moved all examples programs to use the new entropy and CTR_DRBG * Added permissive certificate parsing to x509parse_crt() and x509parse_crtfile(). With permissive parsing the parsing does not stop on encountering a parse-error. Beware that the meaning of return values has changed! * All error codes are now negative. Even on mermory failures and IO errors. Bugfix * Fixed faulty HMAC-MD2 implementation. Found by dibac. (Closes ticket #37) * Fixed a bug where the CRL parser expected an EXPLICIT ASN.1 tag before version numbers * Allowed X509 key usage parsing to accept 4 byte values instead of the standard 1 byte version sometimes used by Microsoft. (Closes ticket #38) * Fixed incorrect behaviour in case of RSASSA-PSS with a salt length smaller than the hash length. (Closes ticket #41) * If certificate serial is longer than 32 octets, serial number is now appended with '....' after first 28 octets * Improved build support for s390x and sparc64 in bignum.h * Fixed MS Visual C++ name clash with int64 in sha4.h * Corrected removal of leading "00:" in printing serial numbers in certificates and CRLs = Version 1.0.0 released on 2011-07-27 Features * Expanded cipher layer with support for CFB128 and CTR mode * Added rsa_encrypt and rsa_decrypt simple example programs. Changes * The generic cipher and message digest layer now have normal error codes instead of integers Bugfix * Undid faulty bug fix in ssl_write() when flushing old data (Ticket #18) = Version 0.99-pre5 released on 2011-05-26 Features * Added additional Cipher Block Modes to symmetric ciphers (AES CTR, Camellia CTR, XTEA CBC) including the option to enable and disable individual modes when needed * Functions requiring File System functions can now be disabled by undefining POLARSSL_FS_IO * A error_strerror function() has been added to translate between error codes and their description. * Added mpi_get_bit() and mpi_set_bit() individual bit setter/getter functions. * Added ssl_mail_client and ssl_fork_server as example programs. Changes * Major argument / variable rewrite. Introduced use of size_t instead of int for buffer lengths and loop variables for better unsigned / signed use. Renamed internal bigint types t_int and t_dbl to t_uint and t_udbl in the process * mpi_init() and mpi_free() now only accept a single MPI argument and do not accept variable argument lists anymore. * The error codes have been remapped and combining error codes is now done with a PLUS instead of an OR as error codes used are negative. * Changed behaviour of net_read(), ssl_fetch_input() and ssl_recv(). net_recv() now returns 0 on EOF instead of POLARSSL_ERR_NET_CONN_RESET. ssl_fetch_input() returns POLARSSL_ERR_SSL_CONN_EOF on an EOF from its f_recv() function. ssl_read() returns 0 if a POLARSSL_ERR_SSL_CONN_EOF is received after the handshake. * Network functions now return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE instead of the ambiguous POLARSSL_ERR_NET_TRY_AGAIN = Version 0.99-pre4 released on 2011-04-01 Features * Added support for PKCS#1 v2.1 encoding and thus support for the RSAES-OAEP and RSASSA-PSS operations. * Reading of Public Key files incorporated into default x509 functionality as well. * Added mpi_fill_random() for centralized filling of big numbers with random data (Fixed ticket #10) Changes * Debug print of MPI now removes leading zero octets and displays actual bit size of the value. * x509parse_key() (and as a consequence x509parse_keyfile()) does not zeroize memory in advance anymore. Use rsa_init() before parsing a key or keyfile! Bugfix * Debug output of MPI's now the same independent of underlying platform (32-bit / 64-bit) (Fixes ticket #19, found by Mads Kiilerich and Mihai Militaru) * Fixed bug in ssl_write() when flushing old data (Fixed ticket #18, found by Nikolay Epifanov) * Fixed proper handling of RSASSA-PSS verification with variable length salt lengths = Version 0.99-pre3 released on 2011-02-28 This release replaces version 0.99-pre2 which had possible copyright issues. Features * Parsing PEM private keys encrypted with DES and AES are now supported as well (Fixes ticket #5) * Added crl_app program to allow easy reading and printing of X509 CRLs from file Changes * Parsing of PEM files moved to separate module (Fixes ticket #13). Also possible to remove PEM support for systems only using DER encoding Bugfixes * Corrected parsing of UTCTime dates before 1990 and after 1950 * Support more exotic OID's when parsing certificates (found by Mads Kiilerich) * Support more exotic name representations when parsing certificates (found by Mads Kiilerich) * Replaced the expired test certificates * Do not bail out if no client certificate specified. Try to negotiate anonymous connection (Fixes ticket #12, found by Boris Krasnovskiy) Security fixes * Fixed a possible Man-in-the-Middle attack on the Diffie Hellman key exchange (thanks to Larry Highsmith, Subreption LLC) = Version 0.99-pre1 released on 2011-01-30 Features Note: Most of these features have been donated by Fox-IT * Added Doxygen source code documentation parts * Added reading of DHM context from memory and file * Improved X509 certificate parsing to include extended certificate fields, including Key Usage * Improved certificate verification and verification against the available CRLs * Detection for DES weak keys and parity bits added * Improvements to support integration in other applications: + Added generic message digest and cipher wrapper + Improved information about current capabilities, status, objects and configuration + Added verification callback on certificate chain verification to allow external blacklisting + Additional example programs to show usage * Added support for PKCS#11 through the use of the libpkcs11-helper library Changes * x509parse_time_expired() checks time in addition to the existing date check * The ciphers member of ssl_context and the cipher member of ssl_session have been renamed to ciphersuites and ciphersuite respectively. This clarifies the difference with the generic cipher layer and is better naming altogether = Version 0.14.0 released on 2010-08-16 Features * Added support for SSL_EDH_RSA_AES_128_SHA and SSL_EDH_RSA_CAMELLIA_128_SHA ciphersuites * Added compile-time and run-time version information * Expanded ssl_client2 arguments for more flexibility * Added support for TLS v1.1 Changes * Made Makefile cleaner * Removed dependency on rand() in rsa_pkcs1_encrypt(). Now using random fuction provided to function and changed the prototype of rsa_pkcs1_encrypt(), rsa_init() and rsa_gen_key(). * Some SSL defines were renamed in order to avoid future confusion Bug fixes * Fixed CMake out of source build for tests (found by kkert) * rsa_check_private() now supports PKCS1v2 keys as well * Fixed deadlock in rsa_pkcs1_encrypt() on failing random generator = Version 0.13.1 released on 2010-03-24 Bug fixes * Fixed Makefile in library that was mistakenly merged * Added missing const string fixes = Version 0.13.0 released on 2010-03-21 Features * Added option parsing for host and port selection to ssl_client2 * Added support for GeneralizedTime in X509 parsing * Added cert_app program to allow easy reading and printing of X509 certificates from file or SSL connection. Changes * Added const correctness for main code base * X509 signature algorithm determination is now in a function to allow easy future expansion * Changed symmetric cipher functions to identical interface (returning int result values) * Changed ARC4 to use seperate input/output buffer * Added reset function for HMAC context as speed-up for specific use-cases Bug fixes * Fixed bug resulting in failure to send the last certificate in the chain in ssl_write_certificate() and ssl_write_certificate_request() (found by fatbob) * Added small fixes for compiler warnings on a Mac (found by Frank de Brabander) * Fixed algorithmic bug in mpi_is_prime() (found by Smbat Tonoyan) = Version 0.12.1 released on 2009-10-04 Changes * Coverage test definitions now support 'depends_on' tagging system. * Tests requiring specific hashing algorithms now honor the defines. Bug fixes * Changed typo in #ifdef in x509parse.c (found by Eduardo) = Version 0.12.0 released on 2009-07-28 Features * Added CMake makefiles as alternative to regular Makefiles. * Added preliminary Code Coverage tests for AES, ARC4, Base64, MPI, SHA-family, MD-family, HMAC-SHA-family, Camellia, DES, 3-DES, RSA PKCS#1, XTEA, Diffie-Hellman and X509parse. Changes * Error codes are not (necessarily) negative. Keep this is mind when checking for errors. * RSA_RAW renamed to SIG_RSA_RAW for consistency. * Fixed typo in name of POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE. * Changed interface for AES and Camellia setkey functions to indicate invalid key lengths. Bug fixes * Fixed include location of endian.h on FreeBSD (found by Gabriel) * Fixed include location of endian.h and name clash on Apples (found by Martin van Hensbergen) * Fixed HMAC-MD2 by modifying md2_starts(), so that the required HMAC ipad and opad variables are not cleared. (found by code coverage tests) * Prevented use of long long in bignum if POLARSSL_HAVE_LONGLONG not defined (found by Giles Bathgate). * Fixed incorrect handling of negative strings in mpi_read_string() (found by code coverage tests). * Fixed segfault on handling empty rsa_context in rsa_check_pubkey() and rsa_check_privkey() (found by code coverage tests). * Fixed incorrect handling of one single negative input value in mpi_add_abs() (found by code coverage tests). * Fixed incorrect handling of negative first input value in mpi_sub_abs() (found by code coverage tests). * Fixed incorrect handling of negative first input value in mpi_mod_mpi() and mpi_mod_int(). Resulting change also affects mpi_write_string() (found by code coverage tests). * Corrected is_prime() results for 0, 1 and 2 (found by code coverage tests). * Fixed Camellia and XTEA for 64-bit Windows systems. = Version 0.11.1 released on 2009-05-17 * Fixed missing functionality for SHA-224, SHA-256, SHA384, SHA-512 in rsa_pkcs1_sign() = Version 0.11.0 released on 2009-05-03 * Fixed a bug in mpi_gcd() so that it also works when both input numbers are even and added testcases to check (found by Pierre Habouzit). * Added support for SHA-224, SHA-256, SHA-384 and SHA-512 one way hash functions with the PKCS#1 v1.5 signing and verification. * Fixed minor bug regarding mpi_gcd located within the POLARSSL_GENPRIME block. * Fixed minor memory leak in x509parse_crt() and added better handling of 'full' certificate chains (found by Mathias Olsson). * Centralized file opening and reading for x509 files into load_file() * Made definition of net_htons() endian-clean for big endian systems (Found by Gernot). * Undefining POLARSSL_HAVE_ASM now also handles prevents asm in padlock and timing code. * Fixed an off-by-one buffer allocation in ssl_set_hostname() responsible for crashes and unwanted behaviour. * Added support for Certificate Revocation List (CRL) parsing. * Added support for CRL revocation to x509parse_verify() and SSL/TLS code. * Fixed compatibility of XTEA and Camellia on a 64-bit system (found by Felix von Leitner). = Version 0.10.0 released on 2009-01-12 * Migrated XySSL to PolarSSL * Added XTEA symmetric cipher * Added Camellia symmetric cipher * Added support for ciphersuites: SSL_RSA_CAMELLIA_128_SHA, SSL_RSA_CAMELLIA_256_SHA and SSL_EDH_RSA_CAMELLIA_256_SHA * Fixed dangerous bug that can cause a heap overflow in rsa_pkcs1_decrypt (found by Christophe Devine) ================================================================ XySSL ChangeLog = Version 0.9 released on 2008-03-16 * Added support for ciphersuite: SSL_RSA_AES_128_SHA * Enabled support for large files by default in aescrypt2.c * Preliminary openssl wrapper contributed by David Barrett * Fixed a bug in ssl_write() that caused the same payload to be sent twice in non-blocking mode when send returns EAGAIN * Fixed ssl_parse_client_hello(): session id and challenge must not be swapped in the SSLv2 ClientHello (found by Greg Robson) * Added user-defined callback debug function (Krystian Kolodziej) * Before freeing a certificate, properly zero out all cert. data * Fixed the "mode" parameter so that encryption/decryption are not swapped on PadLock; also fixed compilation on older versions of gcc (bug reported by David Barrett) * Correctly handle the case in padlock_xcryptcbc() when input or ouput data is non-aligned by falling back to the software implementation, as VIA Nehemiah cannot handle non-aligned buffers * Fixed a memory leak in x509parse_crt() which was reported by Greg Robson-Garth; some x509write.c fixes by Pascal Vizeli, thanks to Matthew Page who reported several bugs * Fixed x509_get_ext() to accept some rare certificates which have an INTEGER instead of a BOOLEAN for BasicConstraints::cA. * Added support on the client side for the TLS "hostname" extension (patch contributed by David Patino) * Make x509parse_verify() return BADCERT_CN_MISMATCH when an empty string is passed as the CN (bug reported by spoofy) * Added an option to enable/disable the BN assembly code * Updated rsa_check_privkey() to verify that (D*E) = 1 % (P-1)*(Q-1) * Disabled obsolete hash functions by default (MD2, MD4); updated selftest and benchmark to not test ciphers that have been disabled * Updated x509parse_cert_info() to correctly display byte 0 of the serial number, setup correct server port in the ssl client example * Fixed a critical denial-of-service with X.509 cert. verification: peer may cause xyssl to loop indefinitely by sending a certificate for which the RSA signature check fails (bug reported by Benoit) * Added test vectors for: AES-CBC, AES-CFB, DES-CBC and 3DES-CBC, HMAC-MD5, HMAC-SHA1, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 * Fixed HMAC-SHA-384 and HMAC-SHA-512 (thanks to Josh Sinykin) * Modified ssl_parse_client_key_exchange() to protect against Daniel Bleichenbacher attack on PKCS#1 v1.5 padding, as well as the Klima-Pokorny-Rosa extension of Bleichenbacher's attack * Updated rsa_gen_key() so that ctx->N is always nbits in size * Fixed assembly PPC compilation errors on Mac OS X, thanks to David Barrett and Dusan Semen = Version 0.8 released on 2007-10-20 * Modified the HMAC functions to handle keys larger than 64 bytes, thanks to Stephane Desneux and gary ng * Fixed ssl_read_record() to properly update the handshake message digests, which fixes IE6/IE7 client authentication * Cleaned up the XYSSL* #defines, suggested by Azriel Fasten * Fixed net_recv(), thanks to Lorenz Schori and Egon Kocjan * Added user-defined callbacks for handling I/O and sessions * Added lots of debugging output in the SSL/TLS functions * Added preliminary X.509 cert. writing by Pascal Vizeli * Added preliminary support for the VIA PadLock routines * Added AES-CFB mode of operation, contributed by chmike * Added an SSL/TLS stress testing program (ssl_test.c) * Updated the RSA PKCS#1 code to allow choosing between RSA_PUBLIC and RSA_PRIVATE, as suggested by David Barrett * Updated ssl_read() to skip 0-length records from OpenSSL * Fixed the make install target to comply with *BSD make * Fixed a bug in mpi_read_binary() on 64-bit platforms * mpi_is_prime() speedups, thanks to Kevin McLaughlin * Fixed a long standing memory leak in mpi_is_prime() * Replaced realloc with malloc in mpi_grow(), and set the sign of zero as positive in mpi_init() (reported by Jonathan M. McCune) = Version 0.7 released on 2007-07-07 * Added support for the MicroBlaze soft-core processor * Fixed a bug in ssl_tls.c which sometimes prevented SSL connections from being established with non-blocking I/O * Fixed a couple bugs in the VS6 and UNIX Makefiles * Fixed the "PIC register ebx clobbered in asm" bug * Added HMAC starts/update/finish support functions * Added the SHA-224, SHA-384 and SHA-512 hash functions * Fixed the net_set_*block routines, thanks to Andreas * Added a few demonstration programs: md5sum, sha1sum, dh_client, dh_server, rsa_genkey, rsa_sign, rsa_verify * Added new bignum import and export helper functions * Rewrote README.txt in program/ssl/ca to better explain how to create a test PKI = Version 0.6 released on 2007-04-01 * Ciphers used in SSL/TLS can now be disabled at compile time, to reduce the memory footprint on embedded systems * Added multiply assembly code for the TriCore and modified havege_struct for this processor, thanks to David Patiño * Added multiply assembly code for 64-bit PowerPCs, thanks to Peking University and the OSU Open Source Lab * Added experimental support of Quantum Cryptography * Added support for autoconf, contributed by Arnaud Cornet * Fixed "long long" compilation issues on IA-64 and PPC64 * Fixed a bug introduced in xyssl-0.5/timing.c: hardclock was not being correctly defined on ARM and MIPS = Version 0.5 released on 2007-03-01 * Added multiply assembly code for SPARC and Alpha * Added (beta) support for non-blocking I/O operations * Implemented session resuming and client authentication * Fixed some portability issues on WinCE, MINIX 3, Plan9 (thanks to Benjamin Newman), HP-UX, FreeBSD and Solaris * Improved the performance of the EDH key exchange * Fixed a bug that caused valid packets with a payload size of 16384 bytes to be rejected = Version 0.4 released on 2007-02-01 * Added support for Ephemeral Diffie-Hellman key exchange * Added multiply asm code for SSE2, ARM, PPC, MIPS and M68K * Various improvement to the modular exponentiation code * Rewrote the headers to generate the API docs with doxygen * Fixed a bug in ssl_encrypt_buf (incorrect padding was generated) and in ssl_parse_client_hello (max. client version was not properly set), thanks to Didier Rebeix * Fixed another bug in ssl_parse_client_hello: clients with cipherlists larger than 96 bytes were incorrectly rejected * Fixed a couple memory leak in x509_read.c = Version 0.3 released on 2007-01-01 * Added server-side SSLv3 and TLSv1.0 support * Multiple fixes to enhance the compatibility with g++, thanks to Xosé Antón Otero Ferreira * Fixed a bug in the CBC code, thanks to dowst; also, the bignum code is no longer dependant on long long * Updated rsa_pkcs1_sign to handle arbitrary large inputs * Updated timing.c for improved compatibility with i386 and 486 processors, thanks to Arnaud Cornet = Version 0.2 released on 2006-12-01 * Updated timing.c to support ARM and MIPS arch * Updated the MPI code to support 8086 on MSVC 1.5 * Added the copyright notice at the top of havege.h * Fixed a bug in sha2_hmac, thanks to newsoft/Wenfang Zhang * Fixed a bug reported by Adrian Rüegsegger in x509_read_key * Fixed a bug reported by Torsten Lauter in ssl_read_record * Fixed a bug in rsa_check_privkey that would wrongly cause valid RSA keys to be dismissed (thanks to oldwolf) * Fixed a bug in mpi_is_prime that caused some primes to fail the Miller-Rabin primality test I'd also like to thank Younès Hafri for the CRUX linux port, Khalil Petit who added XySSL into pkgsrc and Arnaud Cornet who maintains the Debian package :-) = Version 0.1 released on 2006-11-01 pdns-3.3/pdns/ext/polarssl-1.1.2/LICENSE0000644000014601777760000004310312165464055020641 0ustar00jenkinsnogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General Public License instead of this License. pdns-3.3/pdns/ext/polarssl-1.1.2/README0000644000014601777760000000301212165464055020507 0ustar00jenkinsnogroup00000000000000README for PolarSSL -- COMPILING There are currently three active build systems within the PolarSSL releases: - Make - CMake - Microsoft Visual Studio The main system used for development is CMake. That system is always the most up-to-date. The others should reflect all changes present in the CMake build system, but some features are not ported there by default. --- Make In order to build the source using Make, just enter at the command line: make In order to run the tests, enter: make check --- CMake In order to build the source using CMake, just enter at the command line: cmake . make There are 3 different active build modes specified within the CMake buildsystem: - Release This generates the default code without any unnecessary information in the binary files. - Debug This generates debug information and disables optimization of the code. - Coverage This generates code coverage information in addition to debug information. Switching build modes in CMake is simple. For debug mode, enter at the command line: cmake -D CMAKE_BUILD_TYPE:String="Debug" . In order to run the tests, enter: make test --- Microsoft Visual Studio The build files for Microsoft Visual Studio are generated for Visual Studio 6.0 all future Visual Studio's should be able to open and use this older version of the build files. The workspace 'polarssl.dsw' contains all the basic projects needed to build the library and all the programs. The files in tests are not generated and compiled, as these need a perl environment as well. pdns-3.3/pdns/ext/polarssl-1.1.2/include/0000755000014601777760000000000012165464055021256 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/0000755000014601777760000000000012165464055023115 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/debug.h0000644000014601777760000000577512165464055024372 0ustar00jenkinsnogroup00000000000000/** * \file debug.h * * \brief Debug functions * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_DEBUG_H #define POLARSSL_DEBUG_H #include "config.h" #include "ssl.h" #if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C) #define SSL_DEBUG_MSG( level, args ) \ debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args ); #define SSL_DEBUG_RET( level, text, ret ) \ debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ); #define SSL_DEBUG_BUF( level, text, buf, len ) \ debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ); #define SSL_DEBUG_MPI( level, text, X ) \ debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ); #define SSL_DEBUG_CRT( level, text, crt ) \ debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ); #else #define SSL_DEBUG_MSG( level, args ) do { } while( 0 ) #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) #endif #ifdef __cplusplus extern "C" { #endif char *debug_fmt( const char *format, ... ); void debug_print_msg( const ssl_context *ssl, int level, const char *file, int line, const char *text ); void debug_print_ret( const ssl_context *ssl, int level, const char *file, int line, const char *text, int ret ); void debug_print_buf( const ssl_context *ssl, int level, const char *file, int line, const char *text, unsigned char *buf, size_t len ); void debug_print_mpi( const ssl_context *ssl, int level, const char *file, int line, const char *text, const mpi *X ); void debug_print_crt( const ssl_context *ssl, int level, const char *file, int line, const char *text, const x509_cert *crt ); #ifdef __cplusplus } #endif #endif /* debug.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/md_wrap.h0000644000014601777760000000331512165464055024721 0ustar00jenkinsnogroup00000000000000/** * \file md_wrap.h * * \brief Message digest wrappers. * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_MD_WRAP_H #define POLARSSL_MD_WRAP_H #include "config.h" #include "md.h" #ifdef __cplusplus extern "C" { #endif #if defined(POLARSSL_MD2_C) extern const md_info_t md2_info; #endif #if defined(POLARSSL_MD4_C) extern const md_info_t md4_info; #endif #if defined(POLARSSL_MD5_C) extern const md_info_t md5_info; #endif #if defined(POLARSSL_SHA1_C) extern const md_info_t sha1_info; #endif #if defined(POLARSSL_SHA2_C) extern const md_info_t sha224_info; extern const md_info_t sha256_info; #endif #if defined(POLARSSL_SHA4_C) extern const md_info_t sha384_info; extern const md_info_t sha512_info; #endif #ifdef __cplusplus } #endif #endif /* POLARSSL_MD_WRAP_H */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/rsa.h0000644000014601777760000003217312165464055024061 0ustar00jenkinsnogroup00000000000000/** * \file rsa.h * * \brief The RSA public-key cryptosystem * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_RSA_H #define POLARSSL_RSA_H #include "bignum.h" /* * RSA Error codes */ #define POLARSSL_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */ #define POLARSSL_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */ #define POLARSSL_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */ #define POLARSSL_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the libraries validity check. */ #define POLARSSL_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */ #define POLARSSL_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */ #define POLARSSL_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */ #define POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */ #define POLARSSL_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */ /* * PKCS#1 constants */ #define SIG_RSA_RAW 0 #define SIG_RSA_MD2 2 #define SIG_RSA_MD4 3 #define SIG_RSA_MD5 4 #define SIG_RSA_SHA1 5 #define SIG_RSA_SHA224 14 #define SIG_RSA_SHA256 11 #define SIG_RSA_SHA384 12 #define SIG_RSA_SHA512 13 #define RSA_PUBLIC 0 #define RSA_PRIVATE 1 #define RSA_PKCS_V15 0 #define RSA_PKCS_V21 1 #define RSA_SIGN 1 #define RSA_CRYPT 2 #define ASN1_STR_CONSTRUCTED_SEQUENCE "\x30" #define ASN1_STR_NULL "\x05" #define ASN1_STR_OID "\x06" #define ASN1_STR_OCTET_STRING "\x04" #define OID_DIGEST_ALG_MDX "\x2A\x86\x48\x86\xF7\x0D\x02\x00" #define OID_HASH_ALG_SHA1 "\x2b\x0e\x03\x02\x1a" #define OID_HASH_ALG_SHA2X "\x60\x86\x48\x01\x65\x03\x04\x02\x00" #define OID_ISO_MEMBER_BODIES "\x2a" #define OID_ISO_IDENTIFIED_ORG "\x2b" /* * ISO Member bodies OID parts */ #define OID_COUNTRY_US "\x86\x48" #define OID_RSA_DATA_SECURITY "\x86\xf7\x0d" /* * ISO Identified organization OID parts */ #define OID_OIW_SECSIG_SHA1 "\x0e\x03\x02\x1a" /* * DigestInfo ::= SEQUENCE { * digestAlgorithm DigestAlgorithmIdentifier, * digest Digest } * * DigestAlgorithmIdentifier ::= AlgorithmIdentifier * * Digest ::= OCTET STRING */ #define ASN1_HASH_MDX \ ( \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x20" \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x0C" \ ASN1_STR_OID "\x08" \ OID_DIGEST_ALG_MDX \ ASN1_STR_NULL "\x00" \ ASN1_STR_OCTET_STRING "\x10" \ ) #define ASN1_HASH_SHA1 \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x21" \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x09" \ ASN1_STR_OID "\x05" \ OID_HASH_ALG_SHA1 \ ASN1_STR_NULL "\x00" \ ASN1_STR_OCTET_STRING "\x14" #define ASN1_HASH_SHA2X \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x11" \ ASN1_STR_CONSTRUCTED_SEQUENCE "\x0d" \ ASN1_STR_OID "\x09" \ OID_HASH_ALG_SHA2X \ ASN1_STR_NULL "\x00" \ ASN1_STR_OCTET_STRING "\x00" /** * \brief RSA context structure */ typedef struct { int ver; /*!< always 0 */ size_t len; /*!< size(N) in chars */ mpi N; /*!< public modulus */ mpi E; /*!< public exponent */ mpi D; /*!< private exponent */ mpi P; /*!< 1st prime factor */ mpi Q; /*!< 2nd prime factor */ mpi DP; /*!< D % (P - 1) */ mpi DQ; /*!< D % (Q - 1) */ mpi QP; /*!< 1 / (Q % P) */ mpi RN; /*!< cached R^2 mod N */ mpi RP; /*!< cached R^2 mod P */ mpi RQ; /*!< cached R^2 mod Q */ int padding; /*!< RSA_PKCS_V15 for 1.5 padding and RSA_PKCS_v21 for OAEP/PSS */ int hash_id; /*!< Hash identifier of md_type_t as specified in the md.h header file for the EME-OAEP and EMSA-PSS encoding */ } rsa_context; #ifdef __cplusplus extern "C" { #endif /** * \brief Initialize an RSA context * * \param ctx RSA context to be initialized * \param padding RSA_PKCS_V15 or RSA_PKCS_V21 * \param hash_id RSA_PKCS_V21 hash identifier * * \note The hash_id parameter is actually ignored * when using RSA_PKCS_V15 padding. */ void rsa_init( rsa_context *ctx, int padding, int hash_id); /** * \brief Generate an RSA keypair * * \param ctx RSA context that will hold the key * \param f_rng RNG function * \param p_rng RNG parameter * \param nbits size of the public key in bits * \param exponent public exponent (e.g., 65537) * * \note rsa_init() must be called beforehand to setup * the RSA context. * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code */ int rsa_gen_key( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, unsigned int nbits, int exponent ); /** * \brief Check a public RSA key * * \param ctx RSA context to be checked * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code */ int rsa_check_pubkey( const rsa_context *ctx ); /** * \brief Check a private RSA key * * \param ctx RSA context to be checked * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code */ int rsa_check_privkey( const rsa_context *ctx ); /** * \brief Do an RSA public key operation * * \param ctx RSA context * \param input input buffer * \param output output buffer * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code * * \note This function does NOT take care of message * padding. Also, be sure to set input[0] = 0 or assure that * input is smaller than N. * * \note The input and output buffers must be large * enough (eg. 128 bytes if RSA-1024 is used). */ int rsa_public( rsa_context *ctx, const unsigned char *input, unsigned char *output ); /** * \brief Do an RSA private key operation * * \param ctx RSA context * \param input input buffer * \param output output buffer * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code * * \note The input and output buffers must be large * enough (eg. 128 bytes if RSA-1024 is used). */ int rsa_private( rsa_context *ctx, const unsigned char *input, unsigned char *output ); /** * \brief Add the message padding, then do an RSA operation * * \param ctx RSA context * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding) * \param p_rng RNG parameter * \param mode RSA_PUBLIC or RSA_PRIVATE * \param ilen contains the plaintext length * \param input buffer holding the data to be encrypted * \param output buffer that will hold the ciphertext * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code * * \note The output buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int rsa_pkcs1_encrypt( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output ); /** * \brief Do an RSA operation, then remove the message padding * * \param ctx RSA context * \param mode RSA_PUBLIC or RSA_PRIVATE * \param olen will contain the plaintext length * \param input buffer holding the encrypted data * \param output buffer that will hold the plaintext * \param output_max_len maximum length of the output buffer * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code * * \note The output buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise * an error is thrown. */ int rsa_pkcs1_decrypt( rsa_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); /** * \brief Do a private RSA to sign a message digest * * \param ctx RSA context * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding) * \param p_rng RNG parameter * \param mode RSA_PUBLIC or RSA_PRIVATE * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,384,512} * \param hashlen message digest length (for SIG_RSA_RAW only) * \param hash buffer holding the message digest * \param sig buffer that will hold the ciphertext * * \return 0 if the signing operation was successful, * or an POLARSSL_ERR_RSA_XXX error code * * \note The "sig" buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). * * \note In case of PKCS#1 v2.1 encoding keep in mind that * the hash_id in the RSA context is the one used for the * encoding. hash_id in the function call is the type of hash * that is encoded. According to RFC 3447 it is advised to * keep both hashes the same. */ int rsa_pkcs1_sign( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * \brief Do a public RSA and check the message digest * * \param ctx points to an RSA public key * \param mode RSA_PUBLIC or RSA_PRIVATE * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,384,512} * \param hashlen message digest length (for SIG_RSA_RAW only) * \param hash buffer holding the message digest * \param sig buffer holding the ciphertext * * \return 0 if the verify operation was successful, * or an POLARSSL_ERR_RSA_XXX error code * * \note The "sig" buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). * * \note In case of PKCS#1 v2.1 encoding keep in mind that * the hash_id in the RSA context is the one used for the * verification. hash_id in the function call is the type of hash * that is verified. According to RFC 3447 it is advised to * keep both hashes the same. */ int rsa_pkcs1_verify( rsa_context *ctx, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * \brief Free the components of an RSA key * * \param ctx RSA Context to free */ void rsa_free( rsa_context *ctx ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int rsa_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* rsa.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/padlock.h0000644000014601777760000000566412165464055024716 0ustar00jenkinsnogroup00000000000000/** * \file padlock.h * * \brief VIA PadLock ACE for HW encryption/decryption supported by some processors * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_PADLOCK_H #define POLARSSL_PADLOCK_H #include "aes.h" #define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) #ifndef POLARSSL_HAVE_X86 #define POLARSSL_HAVE_X86 #endif #define PADLOCK_RNG 0x000C #define PADLOCK_ACE 0x00C0 #define PADLOCK_PHE 0x0C00 #define PADLOCK_PMM 0x3000 #define PADLOCK_ALIGN16(x) (unsigned long *) (16 + ((long) x & ~15)) #ifdef __cplusplus extern "C" { #endif /** * \brief PadLock detection routine * * \param The feature to detect * * \return 1 if CPU has support for the feature, 0 otherwise */ int padlock_supports( int feature ); /** * \brief PadLock AES-ECB block en(de)cryption * * \param ctx AES context * \param mode AES_ENCRYPT or AES_DECRYPT * \param input 16-byte input block * \param output 16-byte output block * * \return 0 if success, 1 if operation failed */ int padlock_xcryptecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); /** * \brief PadLock AES-CBC buffer en(de)cryption * * \param ctx AES context * \param mode AES_ENCRYPT or AES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if success, 1 if operation failed */ int padlock_xcryptcbc( aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); #ifdef __cplusplus } #endif #endif /* HAVE_X86 */ #endif /* padlock.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/xtea.h0000644000014601777760000000561112165464055024232 0ustar00jenkinsnogroup00000000000000/** * \file xtea.h * * \brief XTEA block cipher (32-bit) * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_XTEA_H #define POLARSSL_XTEA_H #include #ifdef _MSC_VER #include typedef UINT32 uint32_t; #else #include #endif #define XTEA_ENCRYPT 1 #define XTEA_DECRYPT 0 #define POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */ /** * \brief XTEA context structure */ typedef struct { uint32_t k[4]; /*!< key */ } xtea_context; #ifdef __cplusplus extern "C" { #endif /** * \brief XTEA key schedule * * \param ctx XTEA context to be initialized * \param key the secret key */ void xtea_setup( xtea_context *ctx, unsigned char key[16] ); /** * \brief XTEA cipher function * * \param ctx XTEA context * \param mode XTEA_ENCRYPT or XTEA_DECRYPT * \param input 8-byte input block * \param output 8-byte output block * * \return 0 if successful */ int xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], unsigned char output[8] ); /** * \brief XTEA CBC cipher function * * \param ctx XTEA context * \param mode XTEA_ENCRYPT or XTEA_DECRYPT * \param length the length of input, multiple of 8 * \param iv initialization vector for CBC mode * \param input input block * \param output output block * * \return 0 if successful, * POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0 */ int xtea_crypt_cbc( xtea_context *ctx, int mode, size_t length, unsigned char iv[8], unsigned char *input, unsigned char *output); /* * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int xtea_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* xtea.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/dhm.h0000644000014601777760000001157712165464055024051 0ustar00jenkinsnogroup00000000000000/** * \file dhm.h * * \brief Diffie-Hellman-Merkle key exchange * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_DHM_H #define POLARSSL_DHM_H #include "bignum.h" /* * DHM Error codes */ #define POLARSSL_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters to function. */ #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */ #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */ #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */ #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */ #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */ /** * \brief DHM context structure */ typedef struct { size_t len; /*!< size(P) in chars */ mpi P; /*!< prime modulus */ mpi G; /*!< generator */ mpi X; /*!< secret value */ mpi GX; /*!< self = G^X mod P */ mpi GY; /*!< peer = G^Y mod P */ mpi K; /*!< key = GY^X mod P */ mpi RP; /*!< cached R^2 mod P */ } dhm_context; #ifdef __cplusplus extern "C" { #endif /** * \brief Parse the ServerKeyExchange parameters * * \param ctx DHM context * \param p &(start of input buffer) * \param end end of buffer * * \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code */ int dhm_read_params( dhm_context *ctx, unsigned char **p, const unsigned char *end ); /** * \brief Setup and write the ServerKeyExchange parameters * * \param ctx DHM context * \param x_size private value size in bytes * \param output destination buffer * \param olen number of chars written * \param f_rng RNG function * \param p_rng RNG parameter * * \note This function assumes that ctx->P and ctx->G * have already been properly set (for example * using mpi_read_string or mpi_read_binary). * * \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code */ int dhm_make_params( dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Import the peer's public value G^Y * * \param ctx DHM context * \param input input buffer * \param ilen size of buffer * * \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code */ int dhm_read_public( dhm_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief Create own private value X and export G^X * * \param ctx DHM context * \param x_size private value size in bytes * \param output destination buffer * \param olen must be equal to ctx->P.len * \param f_rng RNG function * \param p_rng RNG parameter * * \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code */ int dhm_make_public( dhm_context *ctx, int x_size, unsigned char *output, size_t olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Derive and export the shared secret (G^Y)^X mod P * * \param ctx DHM context * \param output destination buffer * \param olen number of chars written * * \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code */ int dhm_calc_secret( dhm_context *ctx, unsigned char *output, size_t *olen ); /* * \brief Free the components of a DHM key */ void dhm_free( dhm_context *ctx ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int dhm_self_test( int verbose ); #ifdef __cplusplus } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/bn_mul.h0000644000014601777760000007010312165464055024543 0ustar00jenkinsnogroup00000000000000/** * \file bn_mul.h * * \brief Multi-precision integer library * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * Multiply source vector [s] with b, add result * to destination vector [d] and set carry c. * * Currently supports: * * . IA-32 (386+) . AMD64 / EM64T * . IA-32 (SSE2) . Motorola 68000 * . PowerPC, 32-bit . MicroBlaze * . PowerPC, 64-bit . TriCore * . SPARC v8 . ARM v3+ * . Alpha . MIPS32 * . C, longlong . C, generic */ #ifndef POLARSSL_BN_MUL_H #define POLARSSL_BN_MUL_H #include "bignum.h" #if defined(POLARSSL_HAVE_ASM) #if defined(__GNUC__) #if defined(__i386__) #define MULADDC_INIT \ asm( " \ movl %%ebx, %0; \ movl %5, %%esi; \ movl %6, %%edi; \ movl %7, %%ecx; \ movl %8, %%ebx; \ " #define MULADDC_CORE \ " \ lodsl; \ mull %%ebx; \ addl %%ecx, %%eax; \ adcl $0, %%edx; \ addl (%%edi), %%eax; \ adcl $0, %%edx; \ movl %%edx, %%ecx; \ stosl; \ " #if defined(POLARSSL_HAVE_SSE2) #define MULADDC_HUIT \ " \ movd %%ecx, %%mm1; \ movd %%ebx, %%mm0; \ movd (%%edi), %%mm3; \ paddq %%mm3, %%mm1; \ movd (%%esi), %%mm2; \ pmuludq %%mm0, %%mm2; \ movd 4(%%esi), %%mm4; \ pmuludq %%mm0, %%mm4; \ movd 8(%%esi), %%mm6; \ pmuludq %%mm0, %%mm6; \ movd 12(%%esi), %%mm7; \ pmuludq %%mm0, %%mm7; \ paddq %%mm2, %%mm1; \ movd 4(%%edi), %%mm3; \ paddq %%mm4, %%mm3; \ movd 8(%%edi), %%mm5; \ paddq %%mm6, %%mm5; \ movd 12(%%edi), %%mm4; \ paddq %%mm4, %%mm7; \ movd %%mm1, (%%edi); \ movd 16(%%esi), %%mm2; \ pmuludq %%mm0, %%mm2; \ psrlq $32, %%mm1; \ movd 20(%%esi), %%mm4; \ pmuludq %%mm0, %%mm4; \ paddq %%mm3, %%mm1; \ movd 24(%%esi), %%mm6; \ pmuludq %%mm0, %%mm6; \ movd %%mm1, 4(%%edi); \ psrlq $32, %%mm1; \ movd 28(%%esi), %%mm3; \ pmuludq %%mm0, %%mm3; \ paddq %%mm5, %%mm1; \ movd 16(%%edi), %%mm5; \ paddq %%mm5, %%mm2; \ movd %%mm1, 8(%%edi); \ psrlq $32, %%mm1; \ paddq %%mm7, %%mm1; \ movd 20(%%edi), %%mm5; \ paddq %%mm5, %%mm4; \ movd %%mm1, 12(%%edi); \ psrlq $32, %%mm1; \ paddq %%mm2, %%mm1; \ movd 24(%%edi), %%mm5; \ paddq %%mm5, %%mm6; \ movd %%mm1, 16(%%edi); \ psrlq $32, %%mm1; \ paddq %%mm4, %%mm1; \ movd 28(%%edi), %%mm5; \ paddq %%mm5, %%mm3; \ movd %%mm1, 20(%%edi); \ psrlq $32, %%mm1; \ paddq %%mm6, %%mm1; \ movd %%mm1, 24(%%edi); \ psrlq $32, %%mm1; \ paddq %%mm3, %%mm1; \ movd %%mm1, 28(%%edi); \ addl $32, %%edi; \ addl $32, %%esi; \ psrlq $32, %%mm1; \ movd %%mm1, %%ecx; \ " #define MULADDC_STOP \ " \ emms; \ movl %4, %%ebx; \ movl %%ecx, %1; \ movl %%edi, %2; \ movl %%esi, %3; \ " \ : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ : "eax", "ecx", "edx", "esi", "edi" \ ); #else #define MULADDC_STOP \ " \ movl %4, %%ebx; \ movl %%ecx, %1; \ movl %%edi, %2; \ movl %%esi, %3; \ " \ : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ : "eax", "ecx", "edx", "esi", "edi" \ ); #endif /* SSE2 */ #endif /* i386 */ #if defined(__amd64__) || defined (__x86_64__) #define MULADDC_INIT \ asm( "movq %0, %%rsi " :: "m" (s)); \ asm( "movq %0, %%rdi " :: "m" (d)); \ asm( "movq %0, %%rcx " :: "m" (c)); \ asm( "movq %0, %%rbx " :: "m" (b)); \ asm( "xorq %r8, %r8 " ); #define MULADDC_CORE \ asm( "movq (%rsi),%rax " ); \ asm( "mulq %rbx " ); \ asm( "addq $8, %rsi " ); \ asm( "addq %rcx, %rax " ); \ asm( "movq %r8, %rcx " ); \ asm( "adcq $0, %rdx " ); \ asm( "nop " ); \ asm( "addq %rax, (%rdi) " ); \ asm( "adcq %rdx, %rcx " ); \ asm( "addq $8, %rdi " ); #define MULADDC_STOP \ asm( "movq %%rcx, %0 " : "=m" (c)); \ asm( "movq %%rdi, %0 " : "=m" (d)); \ asm( "movq %%rsi, %0 " : "=m" (s) :: \ "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" ); #endif /* AMD64 */ #if defined(__mc68020__) || defined(__mcpu32__) #define MULADDC_INIT \ asm( "movl %0, %%a2 " :: "m" (s)); \ asm( "movl %0, %%a3 " :: "m" (d)); \ asm( "movl %0, %%d3 " :: "m" (c)); \ asm( "movl %0, %%d2 " :: "m" (b)); \ asm( "moveq #0, %d0 " ); #define MULADDC_CORE \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d4:%d1 " ); \ asm( "addl %d3, %d1 " ); \ asm( "addxl %d0, %d4 " ); \ asm( "moveq #0, %d3 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "addxl %d4, %d3 " ); #define MULADDC_STOP \ asm( "movl %%d3, %0 " : "=m" (c)); \ asm( "movl %%a3, %0 " : "=m" (d)); \ asm( "movl %%a2, %0 " : "=m" (s) :: \ "d0", "d1", "d2", "d3", "d4", "a2", "a3" ); #define MULADDC_HUIT \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d4:%d1 " ); \ asm( "addxl %d3, %d1 " ); \ asm( "addxl %d0, %d4 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d3:%d1 " ); \ asm( "addxl %d4, %d1 " ); \ asm( "addxl %d0, %d3 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d4:%d1 " ); \ asm( "addxl %d3, %d1 " ); \ asm( "addxl %d0, %d4 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d3:%d1 " ); \ asm( "addxl %d4, %d1 " ); \ asm( "addxl %d0, %d3 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d4:%d1 " ); \ asm( "addxl %d3, %d1 " ); \ asm( "addxl %d0, %d4 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d3:%d1 " ); \ asm( "addxl %d4, %d1 " ); \ asm( "addxl %d0, %d3 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d4:%d1 " ); \ asm( "addxl %d3, %d1 " ); \ asm( "addxl %d0, %d4 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "movel %a2@+, %d1 " ); \ asm( "mulul %d2, %d3:%d1 " ); \ asm( "addxl %d4, %d1 " ); \ asm( "addxl %d0, %d3 " ); \ asm( "addl %d1, %a3@+ " ); \ asm( "addxl %d0, %d3 " ); #endif /* MC68000 */ #if defined(__powerpc__) || defined(__ppc__) #if defined(__powerpc64__) || defined(__ppc64__) #if defined(__MACH__) && defined(__APPLE__) #define MULADDC_INIT \ asm( "ld r3, %0 " :: "m" (s)); \ asm( "ld r4, %0 " :: "m" (d)); \ asm( "ld r5, %0 " :: "m" (c)); \ asm( "ld r6, %0 " :: "m" (b)); \ asm( "addi r3, r3, -8 " ); \ asm( "addi r4, r4, -8 " ); \ asm( "addic r5, r5, 0 " ); #define MULADDC_CORE \ asm( "ldu r7, 8(r3) " ); \ asm( "mulld r8, r7, r6 " ); \ asm( "mulhdu r9, r7, r6 " ); \ asm( "adde r8, r8, r5 " ); \ asm( "ld r7, 8(r4) " ); \ asm( "addze r5, r9 " ); \ asm( "addc r8, r8, r7 " ); \ asm( "stdu r8, 8(r4) " ); #define MULADDC_STOP \ asm( "addze r5, r5 " ); \ asm( "addi r4, r4, 8 " ); \ asm( "addi r3, r3, 8 " ); \ asm( "std r5, %0 " : "=m" (c)); \ asm( "std r4, %0 " : "=m" (d)); \ asm( "std r3, %0 " : "=m" (s) :: \ "r3", "r4", "r5", "r6", "r7", "r8", "r9" ); #else #define MULADDC_INIT \ asm( "ld %%r3, %0 " :: "m" (s)); \ asm( "ld %%r4, %0 " :: "m" (d)); \ asm( "ld %%r5, %0 " :: "m" (c)); \ asm( "ld %%r6, %0 " :: "m" (b)); \ asm( "addi %r3, %r3, -8 " ); \ asm( "addi %r4, %r4, -8 " ); \ asm( "addic %r5, %r5, 0 " ); #define MULADDC_CORE \ asm( "ldu %r7, 8(%r3) " ); \ asm( "mulld %r8, %r7, %r6 " ); \ asm( "mulhdu %r9, %r7, %r6 " ); \ asm( "adde %r8, %r8, %r5 " ); \ asm( "ld %r7, 8(%r4) " ); \ asm( "addze %r5, %r9 " ); \ asm( "addc %r8, %r8, %r7 " ); \ asm( "stdu %r8, 8(%r4) " ); #define MULADDC_STOP \ asm( "addze %r5, %r5 " ); \ asm( "addi %r4, %r4, 8 " ); \ asm( "addi %r3, %r3, 8 " ); \ asm( "std %%r5, %0 " : "=m" (c)); \ asm( "std %%r4, %0 " : "=m" (d)); \ asm( "std %%r3, %0 " : "=m" (s) :: \ "r3", "r4", "r5", "r6", "r7", "r8", "r9" ); #endif #else /* PPC32 */ #if defined(__MACH__) && defined(__APPLE__) #define MULADDC_INIT \ asm( "lwz r3, %0 " :: "m" (s)); \ asm( "lwz r4, %0 " :: "m" (d)); \ asm( "lwz r5, %0 " :: "m" (c)); \ asm( "lwz r6, %0 " :: "m" (b)); \ asm( "addi r3, r3, -4 " ); \ asm( "addi r4, r4, -4 " ); \ asm( "addic r5, r5, 0 " ); #define MULADDC_CORE \ asm( "lwzu r7, 4(r3) " ); \ asm( "mullw r8, r7, r6 " ); \ asm( "mulhwu r9, r7, r6 " ); \ asm( "adde r8, r8, r5 " ); \ asm( "lwz r7, 4(r4) " ); \ asm( "addze r5, r9 " ); \ asm( "addc r8, r8, r7 " ); \ asm( "stwu r8, 4(r4) " ); #define MULADDC_STOP \ asm( "addze r5, r5 " ); \ asm( "addi r4, r4, 4 " ); \ asm( "addi r3, r3, 4 " ); \ asm( "stw r5, %0 " : "=m" (c)); \ asm( "stw r4, %0 " : "=m" (d)); \ asm( "stw r3, %0 " : "=m" (s) :: \ "r3", "r4", "r5", "r6", "r7", "r8", "r9" ); #else #define MULADDC_INIT \ asm( "lwz %%r3, %0 " :: "m" (s)); \ asm( "lwz %%r4, %0 " :: "m" (d)); \ asm( "lwz %%r5, %0 " :: "m" (c)); \ asm( "lwz %%r6, %0 " :: "m" (b)); \ asm( "addi %r3, %r3, -4 " ); \ asm( "addi %r4, %r4, -4 " ); \ asm( "addic %r5, %r5, 0 " ); #define MULADDC_CORE \ asm( "lwzu %r7, 4(%r3) " ); \ asm( "mullw %r8, %r7, %r6 " ); \ asm( "mulhwu %r9, %r7, %r6 " ); \ asm( "adde %r8, %r8, %r5 " ); \ asm( "lwz %r7, 4(%r4) " ); \ asm( "addze %r5, %r9 " ); \ asm( "addc %r8, %r8, %r7 " ); \ asm( "stwu %r8, 4(%r4) " ); #define MULADDC_STOP \ asm( "addze %r5, %r5 " ); \ asm( "addi %r4, %r4, 4 " ); \ asm( "addi %r3, %r3, 4 " ); \ asm( "stw %%r5, %0 " : "=m" (c)); \ asm( "stw %%r4, %0 " : "=m" (d)); \ asm( "stw %%r3, %0 " : "=m" (s) :: \ "r3", "r4", "r5", "r6", "r7", "r8", "r9" ); #endif #endif /* PPC32 */ #endif /* PPC64 */ #if defined(__sparc__) #define MULADDC_INIT \ asm( "ld %0, %%o0 " :: "m" (s)); \ asm( "ld %0, %%o1 " :: "m" (d)); \ asm( "ld %0, %%o2 " :: "m" (c)); \ asm( "ld %0, %%o3 " :: "m" (b)); #define MULADDC_CORE \ asm( "ld [%o0], %o4 " ); \ asm( "inc 4, %o0 " ); \ asm( "ld [%o1], %o5 " ); \ asm( "umul %o3, %o4, %o4 " ); \ asm( "addcc %o4, %o2, %o4 " ); \ asm( "rd %y, %g1 " ); \ asm( "addx %g1, 0, %g1 " ); \ asm( "addcc %o4, %o5, %o4 " ); \ asm( "st %o4, [%o1] " ); \ asm( "addx %g1, 0, %o2 " ); \ asm( "inc 4, %o1 " ); #define MULADDC_STOP \ asm( "st %%o2, %0 " : "=m" (c)); \ asm( "st %%o1, %0 " : "=m" (d)); \ asm( "st %%o0, %0 " : "=m" (s) :: \ "g1", "o0", "o1", "o2", "o3", "o4", "o5" ); #endif /* SPARCv8 */ #if defined(__microblaze__) || defined(microblaze) #define MULADDC_INIT \ asm( "lwi r3, %0 " :: "m" (s)); \ asm( "lwi r4, %0 " :: "m" (d)); \ asm( "lwi r5, %0 " :: "m" (c)); \ asm( "lwi r6, %0 " :: "m" (b)); \ asm( "andi r7, r6, 0xffff" ); \ asm( "bsrli r6, r6, 16 " ); #define MULADDC_CORE \ asm( "lhui r8, r3, 0 " ); \ asm( "addi r3, r3, 2 " ); \ asm( "lhui r9, r3, 0 " ); \ asm( "addi r3, r3, 2 " ); \ asm( "mul r10, r9, r6 " ); \ asm( "mul r11, r8, r7 " ); \ asm( "mul r12, r9, r7 " ); \ asm( "mul r13, r8, r6 " ); \ asm( "bsrli r8, r10, 16 " ); \ asm( "bsrli r9, r11, 16 " ); \ asm( "add r13, r13, r8 " ); \ asm( "add r13, r13, r9 " ); \ asm( "bslli r10, r10, 16 " ); \ asm( "bslli r11, r11, 16 " ); \ asm( "add r12, r12, r10 " ); \ asm( "addc r13, r13, r0 " ); \ asm( "add r12, r12, r11 " ); \ asm( "addc r13, r13, r0 " ); \ asm( "lwi r10, r4, 0 " ); \ asm( "add r12, r12, r10 " ); \ asm( "addc r13, r13, r0 " ); \ asm( "add r12, r12, r5 " ); \ asm( "addc r5, r13, r0 " ); \ asm( "swi r12, r4, 0 " ); \ asm( "addi r4, r4, 4 " ); #define MULADDC_STOP \ asm( "swi r5, %0 " : "=m" (c)); \ asm( "swi r4, %0 " : "=m" (d)); \ asm( "swi r3, %0 " : "=m" (s) :: \ "r3", "r4" , "r5" , "r6" , "r7" , "r8" , \ "r9", "r10", "r11", "r12", "r13" ); #endif /* MicroBlaze */ #if defined(__tricore__) #define MULADDC_INIT \ asm( "ld.a %%a2, %0 " :: "m" (s)); \ asm( "ld.a %%a3, %0 " :: "m" (d)); \ asm( "ld.w %%d4, %0 " :: "m" (c)); \ asm( "ld.w %%d1, %0 " :: "m" (b)); \ asm( "xor %d5, %d5 " ); #define MULADDC_CORE \ asm( "ld.w %d0, [%a2+] " ); \ asm( "madd.u %e2, %e4, %d0, %d1 " ); \ asm( "ld.w %d0, [%a3] " ); \ asm( "addx %d2, %d2, %d0 " ); \ asm( "addc %d3, %d3, 0 " ); \ asm( "mov %d4, %d3 " ); \ asm( "st.w [%a3+], %d2 " ); #define MULADDC_STOP \ asm( "st.w %0, %%d4 " : "=m" (c)); \ asm( "st.a %0, %%a3 " : "=m" (d)); \ asm( "st.a %0, %%a2 " : "=m" (s) :: \ "d0", "d1", "e2", "d4", "a2", "a3" ); #endif /* TriCore */ #if defined(__arm__) #if !defined(__thumb__) #define MULADDC_INIT \ asm( "ldr r0, %0 " :: "m" (s)); \ asm( "ldr r1, %0 " :: "m" (d)); \ asm( "ldr r2, %0 " :: "m" (c)); \ asm( "ldr r3, %0 " :: "m" (b)); #define MULADDC_CORE \ asm( "ldr r4, [r0], #4 " ); \ asm( "mov r5, #0 " ); \ asm( "ldr r6, [r1] " ); \ asm( "umlal r2, r5, r3, r4 " ); \ asm( "adds r7, r6, r2 " ); \ asm( "adc r2, r5, #0 " ); \ asm( "str r7, [r1], #4 " ); #define MULADDC_STOP \ asm( "str r2, %0 " : "=m" (c)); \ asm( "str r1, %0 " : "=m" (d)); \ asm( "str r0, %0 " : "=m" (s) :: \ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" ); #endif /* Thumb */ #endif /* ARMv3 */ #if defined(__alpha__) #define MULADDC_INIT \ asm( "ldq $1, %0 " :: "m" (s)); \ asm( "ldq $2, %0 " :: "m" (d)); \ asm( "ldq $3, %0 " :: "m" (c)); \ asm( "ldq $4, %0 " :: "m" (b)); #define MULADDC_CORE \ asm( "ldq $6, 0($1) " ); \ asm( "addq $1, 8, $1 " ); \ asm( "mulq $6, $4, $7 " ); \ asm( "umulh $6, $4, $6 " ); \ asm( "addq $7, $3, $7 " ); \ asm( "cmpult $7, $3, $3 " ); \ asm( "ldq $5, 0($2) " ); \ asm( "addq $7, $5, $7 " ); \ asm( "cmpult $7, $5, $5 " ); \ asm( "stq $7, 0($2) " ); \ asm( "addq $2, 8, $2 " ); \ asm( "addq $6, $3, $3 " ); \ asm( "addq $5, $3, $3 " ); #define MULADDC_STOP \ asm( "stq $3, %0 " : "=m" (c)); \ asm( "stq $2, %0 " : "=m" (d)); \ asm( "stq $1, %0 " : "=m" (s) :: \ "$1", "$2", "$3", "$4", "$5", "$6", "$7" ); #endif /* Alpha */ #if defined(__mips__) #define MULADDC_INIT \ asm( "lw $10, %0 " :: "m" (s)); \ asm( "lw $11, %0 " :: "m" (d)); \ asm( "lw $12, %0 " :: "m" (c)); \ asm( "lw $13, %0 " :: "m" (b)); #define MULADDC_CORE \ asm( "lw $14, 0($10) " ); \ asm( "multu $13, $14 " ); \ asm( "addi $10, $10, 4 " ); \ asm( "mflo $14 " ); \ asm( "mfhi $9 " ); \ asm( "addu $14, $12, $14 " ); \ asm( "lw $15, 0($11) " ); \ asm( "sltu $12, $14, $12 " ); \ asm( "addu $15, $14, $15 " ); \ asm( "sltu $14, $15, $14 " ); \ asm( "addu $12, $12, $9 " ); \ asm( "sw $15, 0($11) " ); \ asm( "addu $12, $12, $14 " ); \ asm( "addi $11, $11, 4 " ); #define MULADDC_STOP \ asm( "sw $12, %0 " : "=m" (c)); \ asm( "sw $11, %0 " : "=m" (d)); \ asm( "sw $10, %0 " : "=m" (s) :: \ "$9", "$10", "$11", "$12", "$13", "$14", "$15" ); #endif /* MIPS */ #endif /* GNUC */ #if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) #define MULADDC_INIT \ __asm mov esi, s \ __asm mov edi, d \ __asm mov ecx, c \ __asm mov ebx, b #define MULADDC_CORE \ __asm lodsd \ __asm mul ebx \ __asm add eax, ecx \ __asm adc edx, 0 \ __asm add eax, [edi] \ __asm adc edx, 0 \ __asm mov ecx, edx \ __asm stosd #if defined(POLARSSL_HAVE_SSE2) #define EMIT __asm _emit #define MULADDC_HUIT \ EMIT 0x0F EMIT 0x6E EMIT 0xC9 \ EMIT 0x0F EMIT 0x6E EMIT 0xC3 \ EMIT 0x0F EMIT 0x6E EMIT 0x1F \ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ EMIT 0x0F EMIT 0x6E EMIT 0x16 \ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \ EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \ EMIT 0x0F EMIT 0xD4 EMIT 0xDC \ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \ EMIT 0x0F EMIT 0xD4 EMIT 0xEE \ EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \ EMIT 0x0F EMIT 0xD4 EMIT 0xFC \ EMIT 0x0F EMIT 0x7E EMIT 0x0F \ EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \ EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \ EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \ EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \ EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCD \ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \ EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCF \ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \ EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \ EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCC \ EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \ EMIT 0x0F EMIT 0xD4 EMIT 0xDD \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCE \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \ EMIT 0x83 EMIT 0xC7 EMIT 0x20 \ EMIT 0x83 EMIT 0xC6 EMIT 0x20 \ EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ EMIT 0x0F EMIT 0x7E EMIT 0xC9 #define MULADDC_STOP \ EMIT 0x0F EMIT 0x77 \ __asm mov c, ecx \ __asm mov d, edi \ __asm mov s, esi \ #else #define MULADDC_STOP \ __asm mov c, ecx \ __asm mov d, edi \ __asm mov s, esi \ #endif /* SSE2 */ #endif /* MSVC */ #endif /* POLARSSL_HAVE_ASM */ #if !defined(MULADDC_CORE) #if defined(POLARSSL_HAVE_LONGLONG) #define MULADDC_INIT \ { \ t_udbl r; \ t_uint r0, r1; #define MULADDC_CORE \ r = *(s++) * (t_udbl) b; \ r0 = r; \ r1 = r >> biL; \ r0 += c; r1 += (r0 < c); \ r0 += *d; r1 += (r0 < *d); \ c = r1; *(d++) = r0; #define MULADDC_STOP \ } #else #define MULADDC_INIT \ { \ t_uint s0, s1, b0, b1; \ t_uint r0, r1, rx, ry; \ b0 = ( b << biH ) >> biH; \ b1 = ( b >> biH ); #define MULADDC_CORE \ s0 = ( *s << biH ) >> biH; \ s1 = ( *s >> biH ); s++; \ rx = s0 * b1; r0 = s0 * b0; \ ry = s1 * b0; r1 = s1 * b1; \ r1 += ( rx >> biH ); \ r1 += ( ry >> biH ); \ rx <<= biH; ry <<= biH; \ r0 += rx; r1 += (r0 < rx); \ r0 += ry; r1 += (r0 < ry); \ r0 += c; r1 += (r0 < c); \ r0 += *d; r1 += (r0 < *d); \ c = r1; *(d++) = r0; #define MULADDC_STOP \ } #endif /* C (generic) */ #endif /* C (longlong) */ #endif /* bn_mul.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/x509.h0000644000014601777760000006603612165464055024006 0ustar00jenkinsnogroup00000000000000/** * \file x509.h * * \brief X.509 certificate and private key decoding * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_X509_H #define POLARSSL_X509_H #include "asn1.h" #include "rsa.h" #include "dhm.h" /** * \addtogroup x509_module * \{ */ /** * \name X509 Error codes * \{ */ #define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x2080 /**< Unavailable feature, e.g. RSA hashing/encryption combination. */ #define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x2100 /**< The PEM-encoded certificate contains invalid elements, e.g. invalid character. */ #define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x2180 /**< The certificate format is invalid, e.g. different type expected. */ #define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x2200 /**< The certificate version element is invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x2280 /**< The serial tag or value is invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x2300 /**< The algorithm tag or value is invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x2380 /**< The name tag or value is invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x2400 /**< The date tag or value is invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x2480 /**< The pubkey tag or value is invalid (only RSA is supported). */ #define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x2500 /**< The signature tag or value invalid. */ #define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x2580 /**< The extension tag or value is invalid. */ #define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x2600 /**< Certificate or CRL has an unsupported version number. */ #define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x2680 /**< Signature algorithm (oid) is unsupported. */ #define POLARSSL_ERR_X509_UNKNOWN_PK_ALG -0x2700 /**< Key algorithm is unsupported (only RSA is supported). */ #define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x2780 /**< Certificate signature algorithms do not match. (see \c ::x509_cert sig_oid) */ #define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x2800 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */ #define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x2880 /**< Unsupported RSA key version */ #define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x2900 /**< Invalid RSA key tag or value. */ #define POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT -0x2980 /**< Format not recognized as DER or PEM. */ #define POLARSSL_ERR_X509_INVALID_INPUT -0x2A00 /**< Input invalid. */ #define POLARSSL_ERR_X509_MALLOC_FAILED -0x2A80 /**< Allocation of memory failed. */ #define POLARSSL_ERR_X509_FILE_IO_ERROR -0x2B00 /**< Read/write of file failed. */ /* \} name */ /** * \name X509 Verify codes * \{ */ #define BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */ #define BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */ #define BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */ #define BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */ #define BADCRL_NOT_TRUSTED 0x10 /**< CRL is not correctly signed by the trusted CA. */ #define BADCRL_EXPIRED 0x20 /**< CRL is expired. */ #define BADCERT_MISSING 0x40 /**< Certificate was missing. */ #define BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was skipped. */ /* \} name */ /* \} addtogroup x509_module */ /* * various object identifiers */ #define X520_COMMON_NAME 3 #define X520_COUNTRY 6 #define X520_LOCALITY 7 #define X520_STATE 8 #define X520_ORGANIZATION 10 #define X520_ORG_UNIT 11 #define PKCS9_EMAIL 1 #define X509_OUTPUT_DER 0x01 #define X509_OUTPUT_PEM 0x02 #define PEM_LINE_LENGTH 72 #define X509_ISSUER 0x01 #define X509_SUBJECT 0x02 #define OID_X520 "\x55\x04" #define OID_CN OID_X520 "\x03" #define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01" #define OID_PKCS1_RSA OID_PKCS1 "\x01" #define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" #define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09" #define OID_PKCS9_EMAIL OID_PKCS9 "\x01" /** ISO arc for standard certificate and CRL extensions */ #define OID_ID_CE "\x55\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */ /** * Private Internet Extensions * { iso(1) identified-organization(3) dod(6) internet(1) * security(5) mechanisms(5) pkix(7) } */ #define OID_PKIX "\x2B\x06\x01\x05\x05\x07" /* * OIDs for standard certificate extensions */ #define OID_AUTHORITY_KEY_IDENTIFIER OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */ #define OID_SUBJECT_KEY_IDENTIFIER OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */ #define OID_KEY_USAGE OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */ #define OID_CERTIFICATE_POLICIES OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */ #define OID_POLICY_MAPPINGS OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */ #define OID_SUBJECT_ALT_NAME OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */ #define OID_ISSUER_ALT_NAME OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */ #define OID_SUBJECT_DIRECTORY_ATTRS OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */ #define OID_BASIC_CONSTRAINTS OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */ #define OID_NAME_CONSTRAINTS OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */ #define OID_POLICY_CONSTRAINTS OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */ #define OID_EXTENDED_KEY_USAGE OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */ #define OID_CRL_DISTRIBUTION_POINTS OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */ #define OID_INIHIBIT_ANYPOLICY OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */ #define OID_FRESHEST_CRL OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */ /* * X.509 v3 Key Usage Extension flags */ #define KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */ #define KU_NON_REPUDIATION (0x40) /* bit 1 */ #define KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */ #define KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */ #define KU_KEY_AGREEMENT (0x08) /* bit 4 */ #define KU_KEY_CERT_SIGN (0x04) /* bit 5 */ #define KU_CRL_SIGN (0x02) /* bit 6 */ /* * X.509 v3 Extended key usage OIDs */ #define OID_ANY_EXTENDED_KEY_USAGE OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */ #define OID_KP OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */ #define OID_SERVER_AUTH OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */ #define OID_CLIENT_AUTH OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */ #define OID_CODE_SIGNING OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */ #define OID_EMAIL_PROTECTION OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */ #define OID_TIME_STAMPING OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */ #define OID_OCSP_SIGNING OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */ #define STRING_SERVER_AUTH "TLS Web Server Authentication" #define STRING_CLIENT_AUTH "TLS Web Client Authentication" #define STRING_CODE_SIGNING "Code Signing" #define STRING_EMAIL_PROTECTION "E-mail Protection" #define STRING_TIME_STAMPING "Time Stamping" #define STRING_OCSP_SIGNING "OCSP Signing" /* * OIDs for CRL extensions */ #define OID_PRIVATE_KEY_USAGE_PERIOD OID_ID_CE "\x10" #define OID_CRL_NUMBER OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */ /* * Netscape certificate extensions */ #define OID_NETSCAPE "\x60\x86\x48\x01\x86\xF8\x42" /**< Netscape OID */ #define OID_NS_CERT OID_NETSCAPE "\x01" #define OID_NS_CERT_TYPE OID_NS_CERT "\x01" #define OID_NS_BASE_URL OID_NS_CERT "\x02" #define OID_NS_REVOCATION_URL OID_NS_CERT "\x03" #define OID_NS_CA_REVOCATION_URL OID_NS_CERT "\x04" #define OID_NS_RENEWAL_URL OID_NS_CERT "\x07" #define OID_NS_CA_POLICY_URL OID_NS_CERT "\x08" #define OID_NS_SSL_SERVER_NAME OID_NS_CERT "\x0C" #define OID_NS_COMMENT OID_NS_CERT "\x0D" #define OID_NS_DATA_TYPE OID_NETSCAPE "\x02" #define OID_NS_CERT_SEQUENCE OID_NS_DATA_TYPE "\x05" /* * Netscape certificate types * (http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html) */ #define NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */ #define NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */ #define NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */ #define NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */ #define NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */ #define NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */ #define NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */ #define NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */ #define EXT_AUTHORITY_KEY_IDENTIFIER (1 << 0) #define EXT_SUBJECT_KEY_IDENTIFIER (1 << 1) #define EXT_KEY_USAGE (1 << 2) #define EXT_CERTIFICATE_POLICIES (1 << 3) #define EXT_POLICY_MAPPINGS (1 << 4) #define EXT_SUBJECT_ALT_NAME (1 << 5) #define EXT_ISSUER_ALT_NAME (1 << 6) #define EXT_SUBJECT_DIRECTORY_ATTRS (1 << 7) #define EXT_BASIC_CONSTRAINTS (1 << 8) #define EXT_NAME_CONSTRAINTS (1 << 9) #define EXT_POLICY_CONSTRAINTS (1 << 10) #define EXT_EXTENDED_KEY_USAGE (1 << 11) #define EXT_CRL_DISTRIBUTION_POINTS (1 << 12) #define EXT_INIHIBIT_ANYPOLICY (1 << 13) #define EXT_FRESHEST_CRL (1 << 14) #define EXT_NS_CERT_TYPE (1 << 16) /* * Storage format identifiers * Recognized formats: PEM and DER */ #define X509_FORMAT_DER 1 #define X509_FORMAT_PEM 2 /** * \addtogroup x509_module * \{ */ /** * \name Structures for parsing X.509 certificates and CRLs * \{ */ /** * Type-length-value structure that allows for ASN1 using DER. */ typedef asn1_buf x509_buf; /** * Container for ASN1 bit strings. */ typedef asn1_bitstring x509_bitstring; /** * Container for ASN1 named information objects. * It allows for Relative Distinguished Names (e.g. cn=polarssl,ou=code,etc.). */ typedef struct _x509_name { x509_buf oid; /**< The object identifier. */ x509_buf val; /**< The named value. */ struct _x509_name *next; /**< The next named information object. */ } x509_name; /** * Container for a sequence of ASN.1 items */ typedef asn1_sequence x509_sequence; /** Container for date and time (precision in seconds). */ typedef struct _x509_time { int year, mon, day; /**< Date. */ int hour, min, sec; /**< Time. */ } x509_time; /** * Container for an X.509 certificate. The certificate may be chained. */ typedef struct _x509_cert { x509_buf raw; /**< The raw certificate data (DER). */ x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ int version; /**< The X.509 version. (0=v1, 1=v2, 2=v3) */ x509_buf serial; /**< Unique id for certificate issued by a specific CA. */ x509_buf sig_oid1; /**< Signature algorithm, e.g. sha1RSA */ x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */ x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */ x509_name issuer; /**< The parsed issuer data (named information object). */ x509_name subject; /**< The parsed subject data (named information object). */ x509_time valid_from; /**< Start time of certificate validity. */ x509_time valid_to; /**< End time of certificate validity. */ x509_buf pk_oid; /**< Subject public key info. Includes the public key algorithm and the key itself. */ rsa_context rsa; /**< Container for the RSA context. Only RSA is supported for public keys at this time. */ x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */ x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */ x509_buf v3_ext; /**< Optional X.509 v3 extensions. Only Basic Contraints are supported at this time. */ int ext_types; /**< Bit string containing detected and parsed extensions */ int ca_istrue; /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */ int max_pathlen; /**< Optional Basic Constraint extension value: The maximum path length to the root certificate. */ unsigned char key_usage; /**< Optional key usage extension value: See the values below */ x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */ unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values below */ x509_buf sig_oid2; /**< Signature algorithm. Must match sig_oid1. */ x509_buf sig; /**< Signature: hash of the tbs part signed with the private key. */ int sig_alg; /**< Internal representation of the signature algorithm, e.g. SIG_RSA_MD2 */ struct _x509_cert *next; /**< Next certificate in the CA-chain. */ } x509_cert; /** * Certificate revocation list entry. * Contains the CA-specific serial numbers and revocation dates. */ typedef struct _x509_crl_entry { x509_buf raw; x509_buf serial; x509_time revocation_date; x509_buf entry_ext; struct _x509_crl_entry *next; } x509_crl_entry; /** * Certificate revocation list structure. * Every CRL may have multiple entries. */ typedef struct _x509_crl { x509_buf raw; /**< The raw certificate data (DER). */ x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ int version; x509_buf sig_oid1; x509_buf issuer_raw; /**< The raw issuer data (DER). */ x509_name issuer; /**< The parsed issuer data (named information object). */ x509_time this_update; x509_time next_update; x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */ x509_buf crl_ext; x509_buf sig_oid2; x509_buf sig; int sig_alg; struct _x509_crl *next; } x509_crl; /** \} name Structures for parsing X.509 certificates and CRLs */ /** \} addtogroup x509_module */ /** * \name Structures for writing X.509 certificates. * XvP: commented out as they are not used. * - typedef struct _x509_node x509_node; * - typedef struct _x509_raw x509_raw; */ /* typedef struct _x509_node { unsigned char *data; unsigned char *p; unsigned char *end; size_t len; } x509_node; typedef struct _x509_raw { x509_node raw; x509_node tbs; x509_node version; x509_node serial; x509_node tbs_signalg; x509_node issuer; x509_node validity; x509_node subject; x509_node subpubkey; x509_node signalg; x509_node sign; } x509_raw; */ #ifdef __cplusplus extern "C" { #endif /** * \name Functions to read in DHM parameters, a certificate, CRL or private RSA key * \{ */ /** \ingroup x509_module */ /** * \brief Parse one or more certificates and add them * to the chained list. Parses permissively. If some * certificates can be parsed, the result is the number * of failed certificates it encountered. If none complete * correctly, the first error is returned. * * \param chain points to the start of the chain * \param buf buffer holding the certificate data * \param buflen size of the buffer * * \return 0 if all certificates parsed successfully, a positive number * if partly successful or a specific X509 or PEM error code */ int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ); /** \ingroup x509_module */ /** * \brief Load one or more certificates and add them * to the chained list. Parses permissively. If some * certificates can be parsed, the result is the number * of failed certificates it encountered. If none complete * correctly, the first error is returned. * * \param chain points to the start of the chain * \param path filename to read the certificates from * * \return 0 if all certificates parsed successfully, a positive number * if partly successful or a specific X509 or PEM error code */ int x509parse_crtfile( x509_cert *chain, const char *path ); /** \ingroup x509_module */ /** * \brief Parse one or more CRLs and add them * to the chained list * * \param chain points to the start of the chain * \param buf buffer holding the CRL data * \param buflen size of the buffer * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen ); /** \ingroup x509_module */ /** * \brief Load one or more CRLs and add them * to the chained list * * \param chain points to the start of the chain * \param path filename to read the CRLs from * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_crlfile( x509_crl *chain, const char *path ); /** \ingroup x509_module */ /** * \brief Parse a private RSA key * * \param rsa RSA context to be initialized * \param key input buffer * \param keylen size of the buffer * \param pwd password for decryption (optional) * \param pwdlen size of the password * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_key( rsa_context *rsa, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen ); /** \ingroup x509_module */ /** * \brief Load and parse a private RSA key * * \param rsa RSA context to be initialized * \param path filename to read the private key from * \param password password to decrypt the file (can be NULL) * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_keyfile( rsa_context *rsa, const char *path, const char *password ); /** \ingroup x509_module */ /** * \brief Parse a public RSA key * * \param rsa RSA context to be initialized * \param key input buffer * \param keylen size of the buffer * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_public_key( rsa_context *rsa, const unsigned char *key, size_t keylen ); /** \ingroup x509_module */ /** * \brief Load and parse a public RSA key * * \param rsa RSA context to be initialized * \param path filename to read the private key from * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_public_keyfile( rsa_context *rsa, const char *path ); /** \ingroup x509_module */ /** * \brief Parse DHM parameters * * \param dhm DHM context to be initialized * \param dhmin input buffer * \param dhminlen size of the buffer * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen ); /** \ingroup x509_module */ /** * \brief Load and parse DHM parameters * * \param dhm DHM context to be initialized * \param path filename to read the DHM Parameters from * * \return 0 if successful, or a specific X509 or PEM error code */ int x509parse_dhmfile( dhm_context *dhm, const char *path ); /** \} name Functions to read in DHM parameters, a certificate, CRL or private RSA key */ /** * \brief Store the certificate DN in printable form into buf; * no more than size characters will be written. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param dn The X509 name to represent * * \return The amount of data written to the buffer, or -1 in * case of an error. */ int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn ); /** * \brief Store the certificate serial in printable form into buf; * no more than size characters will be written. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param serial The X509 serial to represent * * \return The amount of data written to the buffer, or -1 in * case of an error. */ int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial ); /** * \brief Returns an informational string about the * certificate. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param prefix A line prefix * \param crt The X509 certificate to represent * * \return The amount of data written to the buffer, or -1 in * case of an error. */ int x509parse_cert_info( char *buf, size_t size, const char *prefix, const x509_cert *crt ); /** * \brief Returns an informational string about the * CRL. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param prefix A line prefix * \param crl The X509 CRL to represent * * \return The amount of data written to the buffer, or -1 in * case of an error. */ int x509parse_crl_info( char *buf, size_t size, const char *prefix, const x509_crl *crl ); /** * \brief Give an known OID, return its descriptive string. * * \param oid buffer containing the oid * * \return Return a string if the OID is known, * or NULL otherwise. */ const char *x509_oid_get_description( x509_buf *oid ); /* * \brief Give an OID, return a string version of its OID number. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param oid Buffer containing the OID * * \return The amount of data written to the buffer, or -1 in * case of an error. */ int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid ); /** * \brief Check a given x509_time against the system time and check * if it is valid. * * \param time x509_time to check * * \return Return 0 if the x509_time is still valid, * or 1 otherwise. */ int x509parse_time_expired( const x509_time *time ); /** * \name Functions to verify a certificate * \{ */ /** \ingroup x509_module */ /** * \brief Verify the certificate signature * * \param crt a certificate to be verified * \param trust_ca the trusted CA chain * \param ca_crl the CRL chain for trusted CA's * \param cn expected Common Name (can be set to * NULL if the CN must not be verified) * \param flags result of the verification * \param f_vrfy verification function * \param p_vrfy verification parameter * * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED, * in which case *flags will have one or more of * the following values set: * BADCERT_EXPIRED -- * BADCERT_REVOKED -- * BADCERT_CN_MISMATCH -- * BADCERT_NOT_TRUSTED * * \note TODO: add two arguments, depth and crl */ int x509parse_verify( x509_cert *crt, x509_cert *trust_ca, x509_crl *ca_crl, const char *cn, int *flags, int (*f_vrfy)(void *, x509_cert *, int, int), void *p_vrfy ); /** * \brief Verify the certificate signature * * \param crt a certificate to be verified * \param crl the CRL to verify against * * \return 1 if the certificate is revoked, 0 otherwise * */ int x509parse_revoked( const x509_cert *crt, const x509_crl *crl ); /** \} name Functions to verify a certificate */ /** * \name Functions to clear a certificate, CRL or private RSA key * \{ */ /** \ingroup x509_module */ /** * \brief Unallocate all certificate data * * \param crt Certificate chain to free */ void x509_free( x509_cert *crt ); /** \ingroup x509_module */ /** * \brief Unallocate all CRL data * * \param crl CRL chain to free */ void x509_crl_free( x509_crl *crl ); /** \} name Functions to clear a certificate, CRL or private RSA key */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int x509_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* x509.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/ctr_drbg.h0000644000014601777760000002057412165464055025064 0ustar00jenkinsnogroup00000000000000/** * \file ctr_drbg.h * * \brief CTR_DRBG based on AES-256 (NIST SP 800-90) * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_CTR_DRBG_H #define POLARSSL_CTR_DRBG_H #include #include "aes.h" #define POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */ #define POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< Too many random requested in single call. */ #define POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< Input too large (Entropy + additional). */ #define POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read/write error in file. */ #define CTR_DRBG_BLOCKSIZE 16 /**< Block size used by the cipher */ #define CTR_DRBG_KEYSIZE 32 /**< Key size used by the cipher */ #define CTR_DRBG_KEYBITS ( CTR_DRBG_KEYSIZE * 8 ) #define CTR_DRBG_SEEDLEN ( CTR_DRBG_KEYSIZE + CTR_DRBG_BLOCKSIZE ) /**< The seed length (counter + AES key) */ #define CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default */ #define CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ #define CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ #define CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ #define CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ #define CTR_DRBG_PR_OFF 0 /**< No prediction resistance */ #define CTR_DRBG_PR_ON 1 /**< Prediction resistance enabled */ #ifdef __cplusplus extern "C" { #endif /** * \brief CTR_DRBG context structure */ typedef struct { unsigned char counter[16]; /*!< counter (V) */ int reseed_counter; /*!< reseed counter */ int prediction_resistance; /*!< enable prediction resistance (Automatic reseed before every random generation) */ size_t entropy_len; /*!< amount of entropy grabbed on each (re)seed */ int reseed_interval; /*!< reseed interval */ aes_context aes_ctx; /*!< AES context */ /* * Callbacks (Entropy) */ int (*f_entropy)(void *, unsigned char *, size_t); void *p_entropy; /*!< context for the entropy function */ } ctr_drbg_context; /** * \brief CTR_DRBG initialization * * Note: Personalization data can be provided in addition to the more generic * entropy source to make this instantiation as unique as possible. * * \param ctx CTR_DRBG context to be initialized * \param f_entropy Entropy callback (p_entropy, buffer to fill, buffer * length) * \param p_entropy Entropy context * \param custom Personalization data (Device specific identifiers) * (Can be NULL) * \param len Length of personalization data * * \return 0 if successful, or * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED */ int ctr_drbg_init( ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len ); /** * \brief Enable / disable prediction resistance (Default: Off) * * Note: If enabled, entropy is used for ctx->entropy_len before each call! * Only use this if you have ample supply of good entropy! * * \param ctx CTR_DRBG context * \param resistance CTR_DRBG_PR_ON or CTR_DRBG_PR_OFF */ void ctr_drbg_set_prediction_resistance( ctr_drbg_context *ctx, int resistance ); /** * \brief Set the amount of entropy grabbed on each (re)seed * (Default: CTR_DRBG_ENTROPY_LEN) * * \param ctx CTR_DRBG context * \param len Amount of entropy to grab */ void ctr_drbg_set_entropy_len( ctr_drbg_context *ctx, size_t len ); /** * \brief Set the reseed interval * (Default: CTR_DRBG_RESEED_INTERVAL) * * \param ctx CTR_DRBG context * \param interval Reseed interval */ void ctr_drbg_set_reseed_interval( ctr_drbg_context *ctx, int interval ); /** * \brief CTR_DRBG reseeding (extracts data from entropy source) * * \param ctx CTR_DRBG context * \param additional Additional data to add to state (Can be NULL) * \param len Length of additional data * * \return 0 if successful, or * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED */ int ctr_drbg_reseed( ctr_drbg_context *ctx, const unsigned char *additional, size_t len ); /** * \brief CTR_DRBG update state * * \param ctx CTR_DRBG context * \param additional Additional data to update state with * \param add_len Length of additional data */ void ctr_drbg_update( ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ); /** * \brief CTR_DRBG generate random with additional update input * * Note: Automatically reseeds if reseed_counter is reached. * * \param p_rng CTR_DRBG context * \param output Buffer to fill * \param output_len Length of the buffer * \param additional Additional data to update with (Can be NULL) * \param add_len Length of additional data * * \return 0 if successful, or * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or * POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG */ int ctr_drbg_random_with_add( void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len ); /** * \brief CTR_DRBG generate random * * Note: Automatically reseeds if reseed_counter is reached. * * \param p_rng CTR_DRBG context * \param output Buffer to fill * \param output_len Length of the buffer * * \return 0 if successful, or * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or * POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG */ int ctr_drbg_random( void *p_rng, unsigned char *output, size_t output_len ); #if defined(POLARSSL_FS_IO) /** * \brief Write a seed file * * \param path Name of the file * * \return 0 if successful, 1 on file error, or * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED */ int ctr_drbg_write_seed_file( ctr_drbg_context *ctx, const char *path ); /** * \brief Read and update a seed file. Seed is added to this * instance * * \param path Name of the file * * \return 0 if successful, 1 on file error, * POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG */ int ctr_drbg_update_seed_file( ctr_drbg_context *ctx, const char *path ); #endif /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int ctr_drbg_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* ctr_drbg.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/arc4.h0000644000014601777760000000422512165464055024122 0ustar00jenkinsnogroup00000000000000/** * \file arc4.h * * \brief The ARCFOUR stream cipher * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_ARC4_H #define POLARSSL_ARC4_H #include /** * \brief ARC4 context structure */ typedef struct { int x; /*!< permutation index */ int y; /*!< permutation index */ unsigned char m[256]; /*!< permutation table */ } arc4_context; #ifdef __cplusplus extern "C" { #endif /** * \brief ARC4 key schedule * * \param ctx ARC4 context to be initialized * \param key the secret key * \param keylen length of the key */ void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen ); /** * \brief ARC4 cipher function * * \param ctx ARC4 context * \param length length of the input data * \param input buffer holding the input data * \param output buffer for the output data * * \return 0 if successful */ int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output ); /* * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int arc4_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* arc4.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/aes.h0000644000014601777760000001336712165464055024050 0ustar00jenkinsnogroup00000000000000/** * \file aes.h * * \brief AES block cipher * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_AES_H #define POLARSSL_AES_H #include #define AES_ENCRYPT 1 #define AES_DECRYPT 0 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ /** * \brief AES context structure */ typedef struct { int nr; /*!< number of rounds */ unsigned long *rk; /*!< AES round keys */ unsigned long buf[68]; /*!< unaligned data */ } aes_context; #ifdef __cplusplus extern "C" { #endif /** * \brief AES key schedule (encryption) * * \param ctx AES context to be initialized * \param key encryption key * \param keysize must be 128, 192 or 256 * * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH */ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize ); /** * \brief AES key schedule (decryption) * * \param ctx AES context to be initialized * \param key decryption key * \param keysize must be 128, 192 or 256 * * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH */ int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize ); /** * \brief AES-ECB block encryption/decryption * * \param ctx AES context * \param mode AES_ENCRYPT or AES_DECRYPT * \param input 16-byte input block * \param output 16-byte output block * * \return 0 if successful */ int aes_crypt_ecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); /** * \brief AES-CBC buffer encryption/decryption * Length should be a multiple of the block * size (16 bytes) * * \param ctx AES context * \param mode AES_ENCRYPT or AES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_INPUT_LENGTH */ int aes_crypt_cbc( aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); /** * \brief AES-CFB128 buffer encryption/decryption. * * Note: Due to the nature of CFB you should use the same key schedule for * both encryption and decryption. So a context initialized with * aes_setkey_enc() for both AES_ENCRYPT and AES_DECRYPT. * * both * \param ctx AES context * \param mode AES_ENCRYPT or AES_DECRYPT * \param length length of the input data * \param iv_off offset in IV (updated after use) * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful */ int aes_crypt_cfb128( aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ); /* * \brief AES-CTR buffer encryption/decryption * * Warning: You have to keep the maximum use of your counter in mind! * * Note: Due to the nature of CTR you should use the same key schedule for * both encryption and decryption. So a context initialized with * aes_setkey_enc() for both AES_ENCRYPT and AES_DECRYPT. * * \param length The length of the data * \param nc_off The offset in the current stream_block (for resuming * within current cipher stream). The offset pointer to * should be 0 at the start of a stream. * \param nonce_counter The 128-bit nonce and counter. * \param stream_block The saved stream-block for resuming. Is overwritten * by the function. * \param input The input data stream * \param output The output data stream * * \return 0 if successful */ int aes_crypt_ctr( aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int aes_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* aes.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/bignum.h0000644000014601777760000004617412165464055024563 0ustar00jenkinsnogroup00000000000000/** * \file bignum.h * * \brief Multi-precision integer library * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_BIGNUM_H #define POLARSSL_BIGNUM_H #include #include #include "config.h" #define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or writing to a file. */ #define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to function. */ #define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid character in the digit string. */ #define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to write to. */ #define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are negative or result in illegal output. */ #define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for division is zero, which is not allowed. */ #define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ #define POLARSSL_ERR_MPI_MALLOC_FAILED -0x0010 /**< Memory allocation failed. */ #define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup /* * Maximum size MPIs are allowed to grow to in number of limbs. */ #define POLARSSL_MPI_MAX_LIMBS 10000 /* * Maximum window size used for modular exponentiation. Default: 6 * Minimum value: 1. Maximum value: 6. * * Result is an array of ( 2 << POLARSSL_MPI_WINDOW_SIZE ) MPIs used * for the sliding window calculation. (So 64 by default) * * Reduction in size, reduces speed. */ #define POLARSSL_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ /* * Maximum size of MPIs allowed in bits and bytes for user-MPIs. * ( Default: 512 bytes => 4096 bits ) * * Note: Calculations can results temporarily in larger MPIs. So the number * of limbs required (POLARSSL_MPI_MAX_LIMBS) is higher. */ #define POLARSSL_MPI_MAX_SIZE 512 /**< Maximum number of bytes for usable MPIs. */ #define POLARSSL_MPI_MAX_BITS ( 8 * POLARSSL_MPI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */ /* * When reading from files with mpi_read_file() the buffer should have space * for a (short) label, the MPI (in the provided radix), the newline * characters and the '\0'. * * By default we assume at least a 10 char label, a minimum radix of 10 * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars). */ #define POLARSSL_MPI_READ_BUFFER_SIZE 1250 /* * Define the base integer type, architecture-wise */ #if defined(POLARSSL_HAVE_INT8) typedef signed char t_sint; typedef unsigned char t_uint; typedef unsigned short t_udbl; #else #if defined(POLARSSL_HAVE_INT16) typedef signed short t_sint; typedef unsigned short t_uint; typedef unsigned long t_udbl; #else typedef signed long t_sint; typedef unsigned long t_uint; #if defined(_MSC_VER) && defined(_M_IX86) typedef unsigned __int64 t_udbl; #else #if defined(__GNUC__) && ( \ defined(__amd64__) || defined(__x86_64__) || \ defined(__ppc64__) || defined(__powerpc64__) || \ defined(__ia64__) || defined(__alpha__) || \ (defined(__sparc__) && defined(__arch64__)) || \ defined(__s390x__) ) typedef unsigned int t_udbl __attribute__((mode(TI))); #define POLARSSL_HAVE_LONGLONG #else #if defined(POLARSSL_HAVE_LONGLONG) typedef unsigned long long t_udbl; #endif #endif #endif #endif #endif /** * \brief MPI structure */ typedef struct { int s; /*!< integer sign */ size_t n; /*!< total # of limbs */ t_uint *p; /*!< pointer to limbs */ } mpi; #ifdef __cplusplus extern "C" { #endif /** * \brief Initialize one MPI * * \param X One MPI to initialize. */ void mpi_init( mpi *X ); /** * \brief Unallocate one MPI * * \param X One MPI to unallocate. */ void mpi_free( mpi *X ); /** * \brief Enlarge to the specified number of limbs * * \param X MPI to grow * \param nblimbs The target number of limbs * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_grow( mpi *X, size_t nblimbs ); /** * \brief Copy the contents of Y into X * * \param X Destination MPI * \param Y Source MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_copy( mpi *X, const mpi *Y ); /** * \brief Swap the contents of X and Y * * \param X First MPI value * \param Y Second MPI value */ void mpi_swap( mpi *X, mpi *Y ); /** * \brief Set value from integer * * \param X MPI to set * \param z Value to use * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_lset( mpi *X, t_sint z ); /* * \brief Get a specific bit from X * * \param X MPI to use * \param pos Zero-based index of the bit in X * * \return Either a 0 or a 1 */ int mpi_get_bit( mpi *X, size_t pos ); /* * \brief Set a bit of X to a specific value of 0 or 1 * * \note Will grow X if necessary to set a bit to 1 in a not yet * existing limb. Will not grow if bit should be set to 0 * * \param X MPI to use * \param pos Zero-based index of the bit in X * \param val The value to set the bit to (0 or 1) * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 */ int mpi_set_bit( mpi *X, size_t pos, unsigned char val ); /** * \brief Return the number of least significant bits * * \param X MPI to use */ size_t mpi_lsb( const mpi *X ); /** * \brief Return the number of most significant bits * * \param X MPI to use */ size_t mpi_msb( const mpi *X ); /** * \brief Return the total size in bytes * * \param X MPI to use */ size_t mpi_size( const mpi *X ); /** * \brief Import from an ASCII string * * \param X Destination MPI * \param radix Input numeric base * \param s Null-terminated string buffer * * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code */ int mpi_read_string( mpi *X, int radix, const char *s ); /** * \brief Export into an ASCII string * * \param X Source MPI * \param radix Output numeric base * \param s String buffer * \param slen String buffer size * * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code. * *slen is always updated to reflect the amount * of data that has (or would have) been written. * * \note Call this function with *slen = 0 to obtain the * minimum required buffer size in *slen. */ int mpi_write_string( const mpi *X, int radix, char *s, size_t *slen ); /** * \brief Read X from an opened file * * \param X Destination MPI * \param radix Input numeric base * \param fin Input file handle * * \return 0 if successful, POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if * the file read buffer is too small or a * POLARSSL_ERR_MPI_XXX error code */ int mpi_read_file( mpi *X, int radix, FILE *fin ); /** * \brief Write X into an opened file, or stdout if fout is NULL * * \param p Prefix, can be NULL * \param X Source MPI * \param radix Output numeric base * \param fout Output file handle (can be NULL) * * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code * * \note Set fout == NULL to print X on the console. */ int mpi_write_file( const char *p, const mpi *X, int radix, FILE *fout ); /** * \brief Import X from unsigned binary data, big endian * * \param X Destination MPI * \param buf Input buffer * \param buflen Input buffer size * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_read_binary( mpi *X, const unsigned char *buf, size_t buflen ); /** * \brief Export X into unsigned binary data, big endian * * \param X Source MPI * \param buf Output buffer * \param buflen Output buffer size * * \return 0 if successful, * POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough */ int mpi_write_binary( const mpi *X, unsigned char *buf, size_t buflen ); /** * \brief Left-shift: X <<= count * * \param X MPI to shift * \param count Amount to shift * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_shift_l( mpi *X, size_t count ); /** * \brief Right-shift: X >>= count * * \param X MPI to shift * \param count Amount to shift * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_shift_r( mpi *X, size_t count ); /** * \brief Compare unsigned values * * \param X Left-hand MPI * \param Y Right-hand MPI * * \return 1 if |X| is greater than |Y|, * -1 if |X| is lesser than |Y| or * 0 if |X| is equal to |Y| */ int mpi_cmp_abs( const mpi *X, const mpi *Y ); /** * \brief Compare signed values * * \param X Left-hand MPI * \param Y Right-hand MPI * * \return 1 if X is greater than Y, * -1 if X is lesser than Y or * 0 if X is equal to Y */ int mpi_cmp_mpi( const mpi *X, const mpi *Y ); /** * \brief Compare signed values * * \param X Left-hand MPI * \param z The integer value to compare to * * \return 1 if X is greater than z, * -1 if X is lesser than z or * 0 if X is equal to z */ int mpi_cmp_int( const mpi *X, t_sint z ); /** * \brief Unsigned addition: X = |A| + |B| * * \param X Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B ); /** * \brief Unsigned substraction: X = |A| - |B| * * \param X Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A */ int mpi_sub_abs( mpi *X, const mpi *A, const mpi *B ); /** * \brief Signed addition: X = A + B * * \param X Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_add_mpi( mpi *X, const mpi *A, const mpi *B ); /** * \brief Signed substraction: X = A - B * * \param X Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_sub_mpi( mpi *X, const mpi *A, const mpi *B ); /** * \brief Signed addition: X = A + b * * \param X Destination MPI * \param A Left-hand MPI * \param b The integer value to add * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_add_int( mpi *X, const mpi *A, t_sint b ); /** * \brief Signed substraction: X = A - b * * \param X Destination MPI * \param A Left-hand MPI * \param b The integer value to subtract * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_sub_int( mpi *X, const mpi *A, t_sint b ); /** * \brief Baseline multiplication: X = A * B * * \param X Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_mul_mpi( mpi *X, const mpi *A, const mpi *B ); /** * \brief Baseline multiplication: X = A * b * Note: b is an unsigned integer type, thus * Negative values of b are ignored. * * \param X Destination MPI * \param A Left-hand MPI * \param b The integer value to multiply with * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_mul_int( mpi *X, const mpi *A, t_sint b ); /** * \brief Division by mpi: A = Q * B + R * * \param Q Destination MPI for the quotient * \param R Destination MPI for the rest value * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0 * * \note Either Q or R can be NULL. */ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B ); /** * \brief Division by int: A = Q * b + R * * \param Q Destination MPI for the quotient * \param R Destination MPI for the rest value * \param A Left-hand MPI * \param b Integer to divide by * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0 * * \note Either Q or R can be NULL. */ int mpi_div_int( mpi *Q, mpi *R, const mpi *A, t_sint b ); /** * \brief Modulo: R = A mod B * * \param R Destination MPI for the rest value * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0, * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B < 0 */ int mpi_mod_mpi( mpi *R, const mpi *A, const mpi *B ); /** * \brief Modulo: r = A mod b * * \param r Destination t_uint * \param A Left-hand MPI * \param b Integer to divide by * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0, * POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0 */ int mpi_mod_int( t_uint *r, const mpi *A, t_sint b ); /** * \brief Sliding-window exponentiation: X = A^E mod N * * \param X Destination MPI * \param A Left-hand MPI * \param E Exponent MPI * \param N Modular MPI * \param _RR Speed-up MPI used for recalculations * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even * * \note _RR is used to avoid re-computing R*R mod N across * multiple calls, which speeds up things a bit. It can * be set to NULL if the extra performance is unneeded. */ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR ); /** * \brief Fill an MPI X with size bytes of random * * \param X Destination MPI * \param size Size in bytes * \param f_rng RNG function * \param p_rng RNG parameter * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_fill_random( mpi *X, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Greatest common divisor: G = gcd(A, B) * * \param G Destination MPI * \param A Left-hand MPI * \param B Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed */ int mpi_gcd( mpi *G, const mpi *A, const mpi *B ); /** * \brief Modular inverse: X = A^-1 mod N * * \param X Destination MPI * \param A Left-hand MPI * \param N Right-hand MPI * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N */ int mpi_inv_mod( mpi *X, const mpi *A, const mpi *N ); /** * \brief Miller-Rabin primality test * * \param X MPI to check * \param f_rng RNG function * \param p_rng RNG parameter * * \return 0 if successful (probably prime), * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime */ int mpi_is_prime( mpi *X, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Prime number generation * * \param X Destination MPI * \param nbits Required size of X in bits ( 3 <= nbits <= POLARSSL_MPI_MAX_BITS ) * \param dh_flag If 1, then (X-1)/2 will be prime too * \param f_rng RNG function * \param p_rng RNG parameter * * \return 0 if successful (probably prime), * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, * POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3 */ int mpi_gen_prime( mpi *X, size_t nbits, int dh_flag, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mpi_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* bignum.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/ssl.h0000644000014601777760000006213212165464055024073 0ustar00jenkinsnogroup00000000000000/** * \file ssl.h * * \brief SSL/TLS functions. * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_SSL_H #define POLARSSL_SSL_H #include #include "net.h" #include "dhm.h" #include "rsa.h" #include "md5.h" #include "sha1.h" #include "x509.h" #include "config.h" #if defined(POLARSSL_PKCS11_C) #include "pkcs11.h" #endif #if defined(_MSC_VER) && !defined(inline) #define inline _inline #else #if defined(__ARMCC_VERSION) && !defined(inline) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ /* * SSL Error codes */ #define POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE -0x7080 /**< The requested feature is not available. */ #define POLARSSL_ERR_SSL_BAD_INPUT_DATA -0x7100 /**< Bad input parameters to function. */ #define POLARSSL_ERR_SSL_INVALID_MAC -0x7180 /**< Verification of the message MAC failed. */ #define POLARSSL_ERR_SSL_INVALID_RECORD -0x7200 /**< An invalid SSL record was received. */ #define POLARSSL_ERR_SSL_CONN_EOF -0x7280 /**< The connection indicated an EOF. */ #define POLARSSL_ERR_SSL_UNKNOWN_CIPHER -0x7300 /**< An unknown cipher was received. */ #define POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN -0x7380 /**< The server has no ciphersuites in common with the client. */ #define POLARSSL_ERR_SSL_NO_SESSION_FOUND -0x7400 /**< No session to recover was found. */ #define POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE -0x7480 /**< No client certification received from the client, but required by the authentication mode. */ #define POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE -0x7500 /**< Our own certificate(s) is/are too large to send in an SSL message.*/ #define POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED -0x7580 /**< The own certificate is not set, but needed by the server. */ #define POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED -0x7600 /**< The own private key is not set, but needed. */ #define POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED -0x7680 /**< No CA Chain is set, but required to operate. */ #define POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE -0x7700 /**< An unexpected message was received from our peer. */ #define POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE -0x7780 /**< A fatal alert message was received from our peer. */ #define POLARSSL_ERR_SSL_PEER_VERIFY_FAILED -0x7800 /**< Verification of our peer failed. */ #define POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY -0x7880 /**< The peer notified us that the connection is going to be closed. */ #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO -0x7900 /**< Processing of the ClientHello handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO -0x7980 /**< Processing of the ServerHello handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE -0x7A00 /**< Processing of the Certificate handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80 /**< Processing of the CertificateRequest handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00 /**< Processing of the ServerKeyExchange handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80 /**< Processing of the ServerHelloDone handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00 /**< Processing of the ClientKeyExchange handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP -0x7C80 /**< Processing of the ClientKeyExchange handshake message failed in DHM Read Public. */ #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS -0x7D00 /**< Processing of the ClientKeyExchange handshake message failed in DHM Calculate Secret. */ #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80 /**< Processing of the CertificateVerify handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00 /**< Processing of the ChangeCipherSpec handshake message failed. */ #define POLARSSL_ERR_SSL_BAD_HS_FINISHED -0x7E80 /**< Processing of the Finished handshake message failed. */ #define POLARSSL_ERR_SSL_MALLOC_FAILED -0x7F00 /**< Memory allocation failed */ /* * Various constants */ #define SSL_MAJOR_VERSION_3 3 #define SSL_MINOR_VERSION_0 0 /*!< SSL v3.0 */ #define SSL_MINOR_VERSION_1 1 /*!< TLS v1.0 */ #define SSL_MINOR_VERSION_2 2 /*!< TLS v1.1 */ #define SSL_IS_CLIENT 0 #define SSL_IS_SERVER 1 #define SSL_COMPRESS_NULL 0 #define SSL_VERIFY_NONE 0 #define SSL_VERIFY_OPTIONAL 1 #define SSL_VERIFY_REQUIRED 2 #define SSL_MAX_CONTENT_LEN 16384 /* * Allow an extra 512 bytes for the record header * and encryption overhead (counter + MAC + padding). */ #define SSL_BUFFER_LEN (SSL_MAX_CONTENT_LEN + 512) /* * Supported ciphersuites */ #define SSL_RSA_RC4_128_MD5 0x04 #define SSL_RSA_RC4_128_SHA 0x05 #define SSL_RSA_DES_168_SHA 0x0A #define SSL_EDH_RSA_DES_168_SHA 0x16 #define SSL_RSA_AES_128_SHA 0x2F #define SSL_EDH_RSA_AES_128_SHA 0x33 #define SSL_RSA_AES_256_SHA 0x35 #define SSL_EDH_RSA_AES_256_SHA 0x39 #define SSL_RSA_CAMELLIA_128_SHA 0x41 #define SSL_EDH_RSA_CAMELLIA_128_SHA 0x45 #define SSL_RSA_CAMELLIA_256_SHA 0x84 #define SSL_EDH_RSA_CAMELLIA_256_SHA 0x88 /* * Message, alert and handshake types */ #define SSL_MSG_CHANGE_CIPHER_SPEC 20 #define SSL_MSG_ALERT 21 #define SSL_MSG_HANDSHAKE 22 #define SSL_MSG_APPLICATION_DATA 23 #define SSL_ALERT_LEVEL_WARNING 1 #define SSL_ALERT_LEVEL_FATAL 2 #define SSL_ALERT_MSG_CLOSE_NOTIFY 0 #define SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 #define SSL_ALERT_MSG_BAD_RECORD_MAC 20 #define SSL_ALERT_MSG_DECRYPTION_FAILED 21 #define SSL_ALERT_MSG_RECORD_OVERFLOW 22 #define SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 #define SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 #define SSL_ALERT_MSG_NO_CERT 41 #define SSL_ALERT_MSG_BAD_CERT 42 #define SSL_ALERT_MSG_UNSUPPORTED_CERT 43 #define SSL_ALERT_MSG_CERT_REVOKED 44 #define SSL_ALERT_MSG_CERT_EXPIRED 45 #define SSL_ALERT_MSG_CERT_UNKNOWN 46 #define SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 #define SSL_ALERT_MSG_UNKNOWN_CA 48 #define SSL_ALERT_MSG_ACCESS_DENIED 49 #define SSL_ALERT_MSG_DECODE_ERROR 50 #define SSL_ALERT_MSG_DECRYPT_ERROR 51 #define SSL_ALERT_MSG_EXPORT_RESTRICTION 60 #define SSL_ALERT_MSG_PROTOCOL_VERSION 70 #define SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 #define SSL_ALERT_MSG_INTERNAL_ERROR 80 #define SSL_ALERT_MSG_USER_CANCELED 90 #define SSL_ALERT_MSG_NO_RENEGOTIATION 100 #define SSL_HS_HELLO_REQUEST 0 #define SSL_HS_CLIENT_HELLO 1 #define SSL_HS_SERVER_HELLO 2 #define SSL_HS_CERTIFICATE 11 #define SSL_HS_SERVER_KEY_EXCHANGE 12 #define SSL_HS_CERTIFICATE_REQUEST 13 #define SSL_HS_SERVER_HELLO_DONE 14 #define SSL_HS_CERTIFICATE_VERIFY 15 #define SSL_HS_CLIENT_KEY_EXCHANGE 16 #define SSL_HS_FINISHED 20 /* * TLS extensions */ #define TLS_EXT_SERVERNAME 0 #define TLS_EXT_SERVERNAME_HOSTNAME 0 /* * SSL state machine */ typedef enum { SSL_HELLO_REQUEST, SSL_CLIENT_HELLO, SSL_SERVER_HELLO, SSL_SERVER_CERTIFICATE, SSL_SERVER_KEY_EXCHANGE, SSL_CERTIFICATE_REQUEST, SSL_SERVER_HELLO_DONE, SSL_CLIENT_CERTIFICATE, SSL_CLIENT_KEY_EXCHANGE, SSL_CERTIFICATE_VERIFY, SSL_CLIENT_CHANGE_CIPHER_SPEC, SSL_CLIENT_FINISHED, SSL_SERVER_CHANGE_CIPHER_SPEC, SSL_SERVER_FINISHED, SSL_FLUSH_BUFFERS, SSL_HANDSHAKE_OVER } ssl_states; typedef struct _ssl_session ssl_session; typedef struct _ssl_context ssl_context; /* * This structure is used for session resuming. */ struct _ssl_session { time_t start; /*!< starting time */ int ciphersuite; /*!< chosen ciphersuite */ size_t length; /*!< session id length */ unsigned char id[32]; /*!< session identifier */ unsigned char master[48]; /*!< the master secret */ ssl_session *next; /*!< next session entry */ }; struct _ssl_context { /* * Miscellaneous */ int state; /*!< SSL handshake: current state */ int major_ver; /*!< equal to SSL_MAJOR_VERSION_3 */ int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ int max_major_ver; /*!< max. major version from client */ int max_minor_ver; /*!< max. minor version from client */ /* * Callbacks (RNG, debug, I/O, verification) */ int (*f_rng)(void *, unsigned char *, size_t); void (*f_dbg)(void *, int, const char *); int (*f_recv)(void *, unsigned char *, size_t); int (*f_send)(void *, const unsigned char *, size_t); int (*f_vrfy)(void *, x509_cert *, int, int); void *p_rng; /*!< context for the RNG function */ void *p_dbg; /*!< context for the debug function */ void *p_recv; /*!< context for reading operations */ void *p_send; /*!< context for writing operations */ void *p_vrfy; /*!< context for verification */ /* * Session layer */ int resume; /*!< session resuming flag */ int timeout; /*!< sess. expiration time */ ssl_session *session; /*!< current session data */ int (*s_get)(ssl_context *); /*!< (server) get callback */ int (*s_set)(ssl_context *); /*!< (server) set callback */ /* * Record layer (incoming data) */ unsigned char *in_ctr; /*!< 64-bit incoming message counter */ unsigned char *in_hdr; /*!< 5-byte record header (in_ctr+8) */ unsigned char *in_msg; /*!< the message contents (in_hdr+5) */ unsigned char *in_offt; /*!< read offset in application data */ int in_msgtype; /*!< record header: message type */ size_t in_msglen; /*!< record header: message length */ size_t in_left; /*!< amount of data read so far */ size_t in_hslen; /*!< current handshake message length */ int nb_zero; /*!< # of 0-length encrypted messages */ /* * Record layer (outgoing data) */ unsigned char *out_ctr; /*!< 64-bit outgoing message counter */ unsigned char *out_hdr; /*!< 5-byte record header (out_ctr+8) */ unsigned char *out_msg; /*!< the message contents (out_hdr+5) */ int out_msgtype; /*!< record header: message type */ size_t out_msglen; /*!< record header: message length */ size_t out_left; /*!< amount of data not yet written */ /* * PKI layer */ rsa_context *rsa_key; /*!< own RSA private key */ #if defined(POLARSSL_PKCS11_C) pkcs11_context *pkcs11_key; /*!< own PKCS#11 RSA private key */ #endif x509_cert *own_cert; /*!< own X.509 certificate */ x509_cert *ca_chain; /*!< own trusted CA chain */ x509_crl *ca_crl; /*!< trusted CA CRLs */ x509_cert *peer_cert; /*!< peer X.509 cert chain */ const char *peer_cn; /*!< expected peer CN */ int endpoint; /*!< 0: client, 1: server */ int authmode; /*!< verification mode */ int client_auth; /*!< flag for client auth. */ int verify_result; /*!< verification result */ /* * Crypto layer */ dhm_context dhm_ctx; /*!< DHM key exchange */ md5_context fin_md5; /*!< Finished MD5 checksum */ sha1_context fin_sha1; /*!< Finished SHA-1 checksum */ int do_crypt; /*!< en(de)cryption flag */ int *ciphersuites; /*!< allowed ciphersuites */ size_t pmslen; /*!< premaster length */ unsigned int keylen; /*!< symmetric key length */ size_t minlen; /*!< min. ciphertext length */ size_t ivlen; /*!< IV length */ size_t maclen; /*!< MAC length */ unsigned char randbytes[64]; /*!< random bytes */ unsigned char premaster[256]; /*!< premaster secret */ unsigned char iv_enc[16]; /*!< IV (encryption) */ unsigned char iv_dec[16]; /*!< IV (decryption) */ unsigned char mac_enc[32]; /*!< MAC (encryption) */ unsigned char mac_dec[32]; /*!< MAC (decryption) */ unsigned long ctx_enc[128]; /*!< encryption context */ unsigned long ctx_dec[128]; /*!< decryption context */ /* * TLS extensions */ unsigned char *hostname; size_t hostname_len; }; #ifdef __cplusplus extern "C" { #endif extern int ssl_default_ciphersuites[]; /** * \brief Returns the list of ciphersuites supported by the SSL/TLS module. * * \return a statically allocated array of ciphersuites, the last * entry is 0. */ static inline const int *ssl_list_ciphersuites( void ) { return ssl_default_ciphersuites; } /** * \brief Return the name of the ciphersuite associated with the given * ID * * \param ciphersuite_id SSL ciphersuite ID * * \return a string containing the ciphersuite name */ const char *ssl_get_ciphersuite_name( const int ciphersuite_id ); /** * \brief Return the ID of the ciphersuite associated with the given * name * * \param ciphersuite_name SSL ciphersuite name * * \return the ID with the ciphersuite or 0 if not found */ int ssl_get_ciphersuite_id( const char *ciphersuite_name ); /** * \brief Initialize an SSL context * * \param ssl SSL context * * \return 0 if successful, or POLARSSL_ERR_SSL_MALLOC_FAILED if * memory allocation failed */ int ssl_init( ssl_context *ssl ); /** * \brief Reset an already initialized SSL context for re-use * while retaining application-set variables, function * pointers and data. * * \param ssl SSL context */ void ssl_session_reset( ssl_context *ssl ); /** * \brief Set the current endpoint type * * \param ssl SSL context * \param endpoint must be SSL_IS_CLIENT or SSL_IS_SERVER */ void ssl_set_endpoint( ssl_context *ssl, int endpoint ); /** * \brief Set the certificate verification mode * * \param ssl SSL context * \param authmode can be: * * SSL_VERIFY_NONE: peer certificate is not checked (default), * this is insecure and SHOULD be avoided. * * SSL_VERIFY_OPTIONAL: peer certificate is checked, however the * handshake continues even if verification failed; * ssl_get_verify_result() can be called after the * handshake is complete. * * SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, * handshake is aborted if verification failed. */ void ssl_set_authmode( ssl_context *ssl, int authmode ); /** * \brief Set the verification callback (Optional). * * If set, the verification callback is called once for every * certificate in the chain. The verification function has the * following parameter: (void *parameter, x509_cert certificate, * int certifcate_depth, int preverify_ok). It should * return 0 on SUCCESS. * * \param ssl SSL context * \param f_vrfy verification function * \param p_vrfy verification parameter */ void ssl_set_verify( ssl_context *ssl, int (*f_vrfy)(void *, x509_cert *, int, int), void *p_vrfy ); /** * \brief Set the random number generator callback * * \param ssl SSL context * \param f_rng RNG function * \param p_rng RNG parameter */ void ssl_set_rng( ssl_context *ssl, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Set the debug callback * * \param ssl SSL context * \param f_dbg debug function * \param p_dbg debug parameter */ void ssl_set_dbg( ssl_context *ssl, void (*f_dbg)(void *, int, const char *), void *p_dbg ); /** * \brief Set the underlying BIO read and write callbacks * * \param ssl SSL context * \param f_recv read callback * \param p_recv read parameter * \param f_send write callback * \param p_send write parameter */ void ssl_set_bio( ssl_context *ssl, int (*f_recv)(void *, unsigned char *, size_t), void *p_recv, int (*f_send)(void *, const unsigned char *, size_t), void *p_send ); /** * \brief Set the session callbacks (server-side only) * * \param ssl SSL context * \param s_get session get callback * \param s_set session set callback */ void ssl_set_scb( ssl_context *ssl, int (*s_get)(ssl_context *), int (*s_set)(ssl_context *) ); /** * \brief Set the session resuming flag, timeout and data * * \param ssl SSL context * \param resume if 0 (default), the session will not be resumed * \param timeout session timeout in seconds, or 0 (no timeout) * \param session session context */ void ssl_set_session( ssl_context *ssl, int resume, int timeout, ssl_session *session ); /** * \brief Set the list of allowed ciphersuites * * \param ssl SSL context * \param ciphersuites 0-terminated list of allowed ciphersuites */ void ssl_set_ciphersuites( ssl_context *ssl, int *ciphersuites ); /** * \brief Set the data required to verify peer certificate * * \param ssl SSL context * \param ca_chain trusted CA chain * \param ca_crl trusted CA CRLs * \param peer_cn expected peer CommonName (or NULL) * * \note TODO: add two more parameters: depth and crl */ void ssl_set_ca_chain( ssl_context *ssl, x509_cert *ca_chain, x509_crl *ca_crl, const char *peer_cn ); /** * \brief Set own certificate and private key * * \param ssl SSL context * \param own_cert own public certificate * \param rsa_key own private RSA key */ void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert, rsa_context *rsa_key ); #if defined(POLARSSL_PKCS11_C) /** * \brief Set own certificate and PKCS#11 private key * * \param ssl SSL context * \param own_cert own public certificate * \param pkcs11_key own PKCS#11 RSA key */ void ssl_set_own_cert_pkcs11( ssl_context *ssl, x509_cert *own_cert, pkcs11_context *pkcs11_key ); #endif /** * \brief Set the Diffie-Hellman public P and G values, * read as hexadecimal strings (server-side only) * * \param ssl SSL context * \param dhm_P Diffie-Hellman-Merkle modulus * \param dhm_G Diffie-Hellman-Merkle generator * * \return 0 if successful */ int ssl_set_dh_param( ssl_context *ssl, const char *dhm_P, const char *dhm_G ); /** * \brief Set the Diffie-Hellman public P and G values, * read from existing context (server-side only) * * \param ssl SSL context * \param dhm_ctx Diffie-Hellman-Merkle context * * \return 0 if successful */ int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx ); /** * \brief Set hostname for ServerName TLS Extension * * * \param ssl SSL context * \param hostname the server hostname * * \return 0 if successful or POLARSSL_ERR_SSL_MALLOC_FAILED */ int ssl_set_hostname( ssl_context *ssl, const char *hostname ); /** * \brief Set the maximum supported version sent from the client side * * \param ssl SSL context * \param major Major version number (only SSL_MAJOR_VERSION_3 supported) * \param minor Minor version number (SSL_MINOR_VERSION_0, * SSL_MINOR_VERSION_1 and SSL_MINOR_VERSION_2 supported) */ void ssl_set_max_version( ssl_context *ssl, int major, int minor ); /** * \brief Return the number of data bytes available to read * * \param ssl SSL context * * \return how many bytes are available in the read buffer */ size_t ssl_get_bytes_avail( const ssl_context *ssl ); /** * \brief Return the result of the certificate verification * * \param ssl SSL context * * \return 0 if successful, or a combination of: * BADCERT_EXPIRED * BADCERT_REVOKED * BADCERT_CN_MISMATCH * BADCERT_NOT_TRUSTED */ int ssl_get_verify_result( const ssl_context *ssl ); /** * \brief Return the name of the current ciphersuite * * \param ssl SSL context * * \return a string containing the ciphersuite name */ const char *ssl_get_ciphersuite( const ssl_context *ssl ); /** * \brief Return the current SSL version (SSLv3/TLSv1/etc) * * \param ssl SSL context * * \return a string containing the SSL version */ const char *ssl_get_version( const ssl_context *ssl ); /** * \brief Perform the SSL handshake * * \param ssl SSL context * * \return 0 if successful, POLARSSL_ERR_NET_WANT_READ, * POLARSSL_ERR_NET_WANT_WRITE, or a specific SSL error code. */ int ssl_handshake( ssl_context *ssl ); /** * \brief Read at most 'len' application data bytes * * \param ssl SSL context * \param buf buffer that will hold the data * \param len how many bytes must be read * * \return This function returns the number of bytes read, 0 for EOF, * or a negative error code. */ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ); /** * \brief Write exactly 'len' application data bytes * * \param ssl SSL context * \param buf buffer holding the data * \param len how many bytes must be written * * \return This function returns the number of bytes written, * or a negative error code. * * \note When this function returns POLARSSL_ERR_NET_WANT_WRITE, * it must be called later with the *same* arguments, * until it returns a positive value. */ int ssl_write( ssl_context *ssl, const unsigned char *buf, size_t len ); /** * \brief Notify the peer that the connection is being closed * * \param ssl SSL context */ int ssl_close_notify( ssl_context *ssl ); /** * \brief Free an SSL context * * \param ssl SSL context */ void ssl_free( ssl_context *ssl ); /* * Internal functions (do not call directly) */ int ssl_handshake_client( ssl_context *ssl ); int ssl_handshake_server( ssl_context *ssl ); int ssl_derive_keys( ssl_context *ssl ); void ssl_calc_verify( ssl_context *ssl, unsigned char hash[36] ); int ssl_read_record( ssl_context *ssl ); /** * \return 0 if successful, POLARSSL_ERR_SSL_CONN_EOF on EOF or * another negative error code. */ int ssl_fetch_input( ssl_context *ssl, size_t nb_want ); int ssl_write_record( ssl_context *ssl ); int ssl_flush_output( ssl_context *ssl ); int ssl_parse_certificate( ssl_context *ssl ); int ssl_write_certificate( ssl_context *ssl ); int ssl_parse_change_cipher_spec( ssl_context *ssl ); int ssl_write_change_cipher_spec( ssl_context *ssl ); int ssl_parse_finished( ssl_context *ssl ); int ssl_write_finished( ssl_context *ssl ); #ifdef __cplusplus } #endif #endif /* ssl.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/sha1.h0000644000014601777760000001025412165464055024124 0ustar00jenkinsnogroup00000000000000/** * \file sha1.h * * \brief SHA-1 cryptographic hash function * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_SHA1_H #define POLARSSL_SHA1_H #include #define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076 /**< Read/write error in file. */ /** * \brief SHA-1 context structure */ typedef struct { unsigned long total[2]; /*!< number of bytes processed */ unsigned long state[5]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ unsigned char ipad[64]; /*!< HMAC: inner padding */ unsigned char opad[64]; /*!< HMAC: outer padding */ } sha1_context; #ifdef __cplusplus extern "C" { #endif /** * \brief SHA-1 context setup * * \param ctx context to be initialized */ void sha1_starts( sha1_context *ctx ); /** * \brief SHA-1 process buffer * * \param ctx SHA-1 context * \param input buffer holding the data * \param ilen length of the input data */ void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-1 final digest * * \param ctx SHA-1 context * \param output SHA-1 checksum result */ void sha1_finish( sha1_context *ctx, unsigned char output[20] ); /** * \brief Output = SHA-1( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output SHA-1 checksum result */ void sha1( const unsigned char *input, size_t ilen, unsigned char output[20] ); /** * \brief Output = SHA-1( file contents ) * * \param path input file name * \param output SHA-1 checksum result * * \return 0 if successful, or POLARSSL_ERR_SHA1_FILE_IO_ERROR */ int sha1_file( const char *path, unsigned char output[20] ); /** * \brief SHA-1 HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key */ void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keylen ); /** * \brief SHA-1 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-1 HMAC final digest * * \param ctx HMAC context * \param output SHA-1 HMAC checksum result */ void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] ); /** * \brief SHA-1 HMAC context reset * * \param ctx HMAC context to be reset */ void sha1_hmac_reset( sha1_context *ctx ); /** * \brief Output = HMAC-SHA-1( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-SHA-1 result */ void sha1_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[20] ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int sha1_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* sha1.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/pkcs11.h0000644000014601777760000001030412165464055024366 0ustar00jenkinsnogroup00000000000000/** * \file pkcs11.h * * \brief Wrapper for PKCS#11 library libpkcs11-helper * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_PKCS11_H #define POLARSSL_PKCS11_H #include "config.h" #if defined(POLARSSL_PKCS11_C) #include "x509.h" #include /** * Context for PKCS #11 private keys. */ typedef struct { pkcs11h_certificate_t pkcs11h_cert; int len; } pkcs11_context; /** * Fill in a PolarSSL certificate, based on the given PKCS11 helper certificate. * * \param cert X.509 certificate to fill * \param pkcs11h_cert PKCS #11 helper certificate * * \return 0 on success. */ int pkcs11_x509_cert_init( x509_cert *cert, pkcs11h_certificate_t pkcs11h_cert ); /** * Initialise a pkcs11_context, storing the given certificate. Note that the * pkcs11_context will take over control of the certificate, freeing it when * done. * * \param priv_key Private key structure to fill. * \param pkcs11_cert PKCS #11 helper certificate * * \return 0 on success */ int pkcs11_priv_key_init( pkcs11_context *priv_key, pkcs11h_certificate_t pkcs11_cert ); /** * Free the contents of the given private key context. Note that the structure * itself is not freed. * * \param priv_key Private key structure to cleanup */ void pkcs11_priv_key_free( pkcs11_context *priv_key ); /** * \brief Do an RSA private key decrypt, then remove the message padding * * \param ctx PKCS #11 context * \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature * \param input buffer holding the encrypted data * \param output buffer that will hold the plaintext * \param olen will contain the plaintext length * \param output_max_len maximum length of the output buffer * * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code * * \note The output buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise * an error is thrown. */ int pkcs11_decrypt( pkcs11_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, unsigned int output_max_len ); /** * \brief Do a private RSA to sign a message digest * * \param ctx PKCS #11 context * \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,384,512} * \param hashlen message digest length (for SIG_RSA_RAW only) * \param hash buffer holding the message digest * \param sig buffer that will hold the ciphertext * * \return 0 if the signing operation was successful, * or an POLARSSL_ERR_RSA_XXX error code * * \note The "sig" buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int pkcs11_sign( pkcs11_context *ctx, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); #endif /* POLARSSL_PKCS11_C */ #endif /* POLARSSL_PKCS11_H */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/cipher_wrap.h0000644000014601777760000000534512165464055025600 0ustar00jenkinsnogroup00000000000000/** * \file cipher_wrap.h * * \brief Cipher wrappers. * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_CIPHER_WRAP_H #define POLARSSL_CIPHER_WRAP_H #include "config.h" #include "cipher.h" #ifdef __cplusplus extern "C" { #endif #if defined(POLARSSL_AES_C) extern const cipher_info_t aes_128_cbc_info; extern const cipher_info_t aes_192_cbc_info; extern const cipher_info_t aes_256_cbc_info; #if defined(POLARSSL_CIPHER_MODE_CFB) extern const cipher_info_t aes_128_cfb128_info; extern const cipher_info_t aes_192_cfb128_info; extern const cipher_info_t aes_256_cfb128_info; #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) extern const cipher_info_t aes_128_ctr_info; extern const cipher_info_t aes_192_ctr_info; extern const cipher_info_t aes_256_ctr_info; #endif /* POLARSSL_CIPHER_MODE_CTR */ #endif /* defined(POLARSSL_AES_C) */ #if defined(POLARSSL_CAMELLIA_C) extern const cipher_info_t camellia_128_cbc_info; extern const cipher_info_t camellia_192_cbc_info; extern const cipher_info_t camellia_256_cbc_info; #if defined(POLARSSL_CIPHER_MODE_CFB) extern const cipher_info_t camellia_128_cfb128_info; extern const cipher_info_t camellia_192_cfb128_info; extern const cipher_info_t camellia_256_cfb128_info; #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) extern const cipher_info_t camellia_128_ctr_info; extern const cipher_info_t camellia_192_ctr_info; extern const cipher_info_t camellia_256_ctr_info; #endif /* POLARSSL_CIPHER_MODE_CTR */ #endif /* defined(POLARSSL_CAMELLIA_C) */ #if defined(POLARSSL_DES_C) extern const cipher_info_t des_cbc_info; extern const cipher_info_t des_ede_cbc_info; extern const cipher_info_t des_ede3_cbc_info; #endif /* defined(POLARSSL_DES_C) */ #ifdef __cplusplus } #endif #endif /* POLARSSL_CIPHER_WRAP_H */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/config.h0000644000014601777760000003305112165464055024535 0ustar00jenkinsnogroup00000000000000/** * \file config.h * * \brief Configuration options (set of defines) * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This set of compile-time options may be used to enable * or disable features selectively, and reduce the global * memory footprint. */ #ifndef POLARSSL_CONFIG_H #define POLARSSL_CONFIG_H #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) #define _CRT_SECURE_NO_DEPRECATE 1 #endif /** * \name SECTION: System support * * This section sets system specific settings. * \{ */ /** * \def POLARSSL_HAVE_INT8 * * The system uses 8-bit wide native integers. * * Uncomment if native integers are 8-bit wide. #define POLARSSL_HAVE_INT8 */ /** * \def POLARSSL_HAVE_INT16 * * The system uses 16-bit wide native integers. * * Uncomment if native integers are 16-bit wide. #define POLARSSL_HAVE_INT16 */ /** * \def POLARSSL_HAVE_LONGLONG * * The compiler supports the use of long long. * * Uncomment if the compiler supports long long. #define POLARSSL_HAVE_LONGLONG */ /** * \def POLARSSL_HAVE_ASM * * The compiler has support for asm() * * Uncomment to enable the use of assembly code. * * Requires support for asm() in compiler. * * Used in: * library/timing.c * library/padlock.c * include/polarssl/bn_mul.h * */ #define POLARSSL_HAVE_ASM /** * \def POLARSSL_HAVE_SSE2 * * CPI supports SSE2 instruction set. * * Uncomment if the CPU supports SSE2 (IA-32 specific). * #define POLARSSL_HAVE_SSE2 */ /* \} name */ /** * \name SECTION: PolarSSL feature support * * This section sets support for features that are or are not needed * within the modules that are enabled. * \{ */ /** * \def POLARSSL_AES_ROM_TABLES * * Store the AES tables in ROM. * * Uncomment this macro to store the AES tables in ROM. * #define POLARSSL_AES_ROM_TABLES */ /** * \def POLARSSL_CIPHER_MODE_CFB * * Enable Cipher Feedback mode (CFB) for symmetric ciphers. */ #define POLARSSL_CIPHER_MODE_CFB /** * \def POLARSSL_CIPHER_MODE_CTR * * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. */ #define POLARSSL_CIPHER_MODE_CTR /** * \def POLARSSL_DEBUG_MSG * * Requires: POLARSSL_DEBUG_C * * Enable all SSL/TLS debugging messages. */ #define POLARSSL_DEBUG_MSG /** * \def POLARSSL_GENPRIME * * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C * * Enable the RSA prime-number generation code. */ #define POLARSSL_GENPRIME /** * \def POLARSSL_FS_IO * * Enable functions that use the filesystem. */ #define POLARSSL_FS_IO /** * \def POLARSSL_NO_DEFAULT_ENTROPY_SOURCES * * Do not add default entropy sources. These are the platform specific, * hardclock and HAVEGE based poll functions. * * This is useful to have more control over the added entropy sources in an * application. * * Uncomment this macro to prevent loading of default entropy functions. #define POLARSSL_NO_DEFAULT_ENTROPY_SOURCES */ /** * \def POLARSSL_NO_PLATFORM_ENTROPY * * Do not use built-in platform entropy functions. * This is useful if your platform does not support * standards like the /dev/urandom or Windows CryptoAPI. * * Uncomment this macro to disable the built-in platform entropy functions. #define POLARSSL_NO_PLATFORM_ENTROPY */ /** * \def POLARSSL_PKCS1_V21 * * Requires: POLARSSL_MD_C, POLARSSL_RSA_C * * Enable support for PKCS#1 v2.1 encoding. * This enables support for RSAES-OAEP and RSASSA-PSS operations. */ #define POLARSSL_PKCS1_V21 /** * \def POLARSSL_RSA_NO_CRT * * Do not use the Chinese Remainder Theorem for the RSA private operation. * * Uncomment this macro to disable the use of CRT in RSA. * #define POLARSSL_RSA_NO_CRT */ /** * \def POLARSSL_SELF_TEST * * Enable the checkup functions (*_self_test). */ #define POLARSSL_SELF_TEST /** * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION * * If set, the X509 parser will not break-off when parsing an X509 certificate * and encountering an unknown critical extension. * * Uncomment to prevent an error. * #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION */ /* \} name */ /** * \name SECTION: PolarSSL modules * * This section enables or disables entire modules in PolarSSL * \{ */ /** * \def POLARSSL_AES_C * * Enable the AES block cipher. * * Module: library/aes.c * Caller: library/ssl_tls.c * library/pem.c * library/ctr_drbg.c * * This module enables the following ciphersuites: * SSL_RSA_AES_128_SHA * SSL_RSA_AES_256_SHA * SSL_EDH_RSA_AES_256_SHA */ #define POLARSSL_AES_C /** * \def POLARSSL_ARC4_C * * Enable the ARCFOUR stream cipher. * * Module: library/arc4.c * Caller: library/ssl_tls.c * * This module enables the following ciphersuites: * SSL_RSA_RC4_128_MD5 * SSL_RSA_RC4_128_SHA */ #define POLARSSL_ARC4_C /** * \def POLARSSL_ASN1_PARSE_C * * Enable the generic ASN1 parser. * * Module: library/asn1.c * Caller: library/x509parse.c */ #define POLARSSL_ASN1_PARSE_C /** * \def POLARSSL_BASE64_C * * Enable the Base64 module. * * Module: library/base64.c * Caller: library/pem.c * * This module is required for PEM support (required by X.509). */ #define POLARSSL_BASE64_C /** * \def POLARSSL_BIGNUM_C * * Enable the multo-precision integer library. * * Module: library/bignum.c * Caller: library/dhm.c * library/rsa.c * library/ssl_tls.c * library/x509parse.c * * This module is required for RSA and DHM support. */ #define POLARSSL_BIGNUM_C /** * \def POLARSSL_CAMELLIA_C * * Enable the Camellia block cipher. * * Module: library/camellia.c * Caller: library/ssl_tls.c * * This module enabled the following cipher suites: * SSL_RSA_CAMELLIA_128_SHA * SSL_RSA_CAMELLIA_256_SHA * SSL_EDH_RSA_CAMELLIA_256_SHA */ #define POLARSSL_CAMELLIA_C /** * \def POLARSSL_CERTS_C * * Enable the test certificates. * * Module: library/certs.c * Caller: * * This module is used for testing (ssl_client/server). */ #define POLARSSL_CERTS_C /** * \def POLARSSL_CIPHER_C * * Enable the generic cipher layer. * * Module: library/cipher.c * Caller: * * Uncomment to enable generic cipher wrappers. */ #define POLARSSL_CIPHER_C /** * \def POLARSSL_CTR_DRBG_C * * Enable the CTR_DRBG AES-256-based random generator * * Module: library/ctr_drbg.c * Caller: * * Requires: POLARSSL_AES_C * * This module provides the CTR_DRBG AES-256 random number generator. */ #define POLARSSL_CTR_DRBG_C /** * \def POLARSSL_DEBUG_C * * Enable the debug functions. * * Module: library/debug.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * * This module provides debugging functions. */ #define POLARSSL_DEBUG_C /** * \def POLARSSL_DES_C * * Enable the DES block cipher. * * Module: library/des.c * Caller: library/ssl_tls.c * * This module enables the following ciphersuites: * SSL_RSA_DES_168_SHA * SSL_EDH_RSA_DES_168_SHA */ #define POLARSSL_DES_C /** * \def POLARSSL_DHM_C * * Enable the Diffie-Hellman-Merkle key exchange. * * Module: library/dhm.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * This module enables the following ciphersuites: * SSL_EDH_RSA_DES_168_SHA * SSL_EDH_RSA_AES_256_SHA * SSL_EDH_RSA_CAMELLIA_256_SHA */ #define POLARSSL_DHM_C /** * \def POLARSSL_ENTROPY_C * * Enable the platform-specific entropy code. * * Module: library/entropy.c * Caller: * * Requires: POLARSSL_SHA4_C * * This module provides a generic entropy pool */ #define POLARSSL_ENTROPY_C /** * \def POLARSSL_ERROR_C * * Enable error code to error string conversion. * * Module: library/error.c * Caller: * * This module enables err_strerror(). */ #define POLARSSL_ERROR_C /** * \def POLARSSL_HAVEGE_C * * Enable the HAVEGE random generator. * * Module: library/havege.c * Caller: * * Requires: POLARSSL_TIMING_C * * This module enables the HAVEGE random number generator. */ #define POLARSSL_HAVEGE_C /** * \def POLARSSL_MD_C * * Enable the generic message digest layer. * * Module: library/md.c * Caller: * * Uncomment to enable generic message digest wrappers. */ #define POLARSSL_MD_C /** * \def POLARSSL_MD2_C * * Enable the MD2 hash algorithm * * Module: library/md2.c * Caller: library/x509parse.c * * Uncomment to enable support for (rare) MD2-signed X.509 certs. * #define POLARSSL_MD2_C */ /** * \def POLARSSL_MD4_C * * Enable the MD4 hash algorithm * * Module: library/md4.c * Caller: library/x509parse.c * * Uncomment to enable support for (rare) MD4-signed X.509 certs. * #define POLARSSL_MD4_C */ /** * \def POLARSSL_MD5_C * * Enable the MD5 hash algorithm * * Module: library/md5.c * Caller: library/ssl_tls.c * library/x509parse.c * * This module is required for SSL/TLS and X.509. */ #define POLARSSL_MD5_C /** * \def POLARSSL_NET_C * * Enable the TCP/IP networking routines. * * Module: library/net.c * Caller: * * This module provides TCP/IP networking routines. */ #define POLARSSL_NET_C /** * \def POLARSSL_PADLOCK_C * * Enable VIA Padlock support on x86. * * Module: library/padlock.c * Caller: library/aes.c * * This modules adds support for the VIA PadLock on x86. */ #define POLARSSL_PADLOCK_C /** * \def POLARSSL_PEM_C * * Enable PEM decoding * * Module: library/pem.c * Caller: library/x509parse.c * * Requires: POLARSSL_BASE64_C * * This modules adds support for decoding PEM files. */ #define POLARSSL_PEM_C /** * \def POLARSSL_PKCS11_C * * Enable support for PKCS#11 smartcard support. * * Module: library/ssl_srv.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * Requires: POLARSSL_SSL_TLS_C * * This module is required for SSL/TLS PKCS #11 smartcard support. * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) #define POLARSSL_PKCS11_C */ /** * \def POLARSSL_RSA_C * * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * library/x509.c * * Requires: POLARSSL_BIGNUM_C * * This module is required for SSL/TLS and MD5-signed certificates. */ #define POLARSSL_RSA_C /** * \def POLARSSL_SHA1_C * * Enable the SHA1 cryptographic hash algorithm. * * Module: library/sha1.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * library/x509parse.c * * This module is required for SSL/TLS and SHA1-signed certificates. */ #define POLARSSL_SHA1_C /** * \def POLARSSL_SHA2_C * * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. * * Module: library/sha2.c * Caller: library/md_wrap.c * library/x509parse.c * * This module adds support for SHA-224 and SHA-256. */ #define POLARSSL_SHA2_C /** * \def POLARSSL_SHA4_C * * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. * * Module: library/sha4.c * Caller: library/md_wrap.c * library/x509parse.c * * This module adds support for SHA-384 and SHA-512. */ #define POLARSSL_SHA4_C /** * \def POLARSSL_SSL_CLI_C * * Enable the SSL/TLS client code. * * Module: library/ssl_cli.c * Caller: * * Requires: POLARSSL_SSL_TLS_C * * This module is required for SSL/TLS client support. */ #define POLARSSL_SSL_CLI_C /* * \def POLARSSL_SSL_SRV_C * * Enable the SSL/TLS server code. * * Module: library/ssl_srv.c * Caller: * * Requires: POLARSSL_SSL_TLS_C * * This module is required for SSL/TLS server support. */ #define POLARSSL_SSL_SRV_C /** * \def POLARSSL_SSL_TLS_C * * Enable the generic SSL/TLS code. * * Module: library/ssl_tls.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * Requires: POLARSSL_MD5_C, POLARSSL_SHA1_C, POLARSSL_X509_PARSE_C * * This module is required for SSL/TLS. */ #define POLARSSL_SSL_TLS_C /** * \def POLARSSL_TIMING_C * * Enable the portable timing interface. * * Module: library/timing.c * Caller: library/havege.c * * This module is used by the HAVEGE random number generator. */ #define POLARSSL_TIMING_C /** * \def POLARSSL_VERSION_C * * Enable run-time version information. * * Module: library/version.c * * This module provides run-time version information. */ #define POLARSSL_VERSION_C /** * \def POLARSSL_X509_PARSE_C * * Enable X.509 certificate parsing. * * Module: library/x509parse.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * * Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_BIGNUM_C, POLARSSL_RSA_C * * This module is required for X.509 certificate parsing. */ #define POLARSSL_X509_PARSE_C /** * \def POLARSSL_XTEA_C * * Enable the XTEA block cipher. * * Module: library/xtea.c * Caller: */ #define POLARSSL_XTEA_C /* \} name */ #endif /* config.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/md5.h0000644000014601777760000001024512165464055023755 0ustar00jenkinsnogroup00000000000000/** * \file md5.h * * \brief MD5 message digest algorithm (hash function) * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_MD5_H #define POLARSSL_MD5_H #include #define POLARSSL_ERR_MD5_FILE_IO_ERROR -0x0074 /**< Read/write error in file. */ /** * \brief MD5 context structure */ typedef struct { unsigned long total[2]; /*!< number of bytes processed */ unsigned long state[4]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ unsigned char ipad[64]; /*!< HMAC: inner padding */ unsigned char opad[64]; /*!< HMAC: outer padding */ } md5_context; #ifdef __cplusplus extern "C" { #endif /** * \brief MD5 context setup * * \param ctx context to be initialized */ void md5_starts( md5_context *ctx ); /** * \brief MD5 process buffer * * \param ctx MD5 context * \param input buffer holding the data * \param ilen length of the input data */ void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD5 final digest * * \param ctx MD5 context * \param output MD5 checksum result */ void md5_finish( md5_context *ctx, unsigned char output[16] ); /** * \brief Output = MD5( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD5 checksum result */ void md5( const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Output = MD5( file contents ) * * \param path input file name * \param output MD5 checksum result * * \return 0 if successful, or POLARSSL_ERR_MD5_FILE_IO_ERROR */ int md5_file( const char *path, unsigned char output[16] ); /** * \brief MD5 HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key */ void md5_hmac_starts( md5_context *ctx, const unsigned char *key, size_t keylen ); /** * \brief MD5 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void md5_hmac_update( md5_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD5 HMAC final digest * * \param ctx HMAC context * \param output MD5 HMAC checksum result */ void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ); /** * \brief MD5 HMAC context reset * * \param ctx HMAC context to be reset */ void md5_hmac_reset( md5_context *ctx ); /** * \brief Output = HMAC-MD5( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-MD5 result */ void md5_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int md5_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* md5.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/entropy_poll.h0000644000014601777760000000426412165464055026022 0ustar00jenkinsnogroup00000000000000/** * \file entropy_poll.h * * \brief Platform-specific and custom entropy polling functions * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_ENTROPY_POLL_H #define POLARSSL_ENTROPY_POLL_H #include #include "config.h" #ifdef __cplusplus extern "C" { #endif /* * Default thresholds for built-in sources */ #define ENTROPY_MIN_PLATFORM 128 /**< Minimum for platform source */ #define ENTROPY_MIN_HAVEGE 128 /**< Minimum for HAVEGE */ #define ENTROPY_MIN_HARDCLOCK 32 /**< Minimum for hardclock() */ #if !defined(POLARSSL_NO_PLATFORM_ENTROPY) /** * \brief Platform-specific entropy poll callback */ int platform_entropy_poll( void *data, unsigned char *output, size_t len, size_t *olen ); #endif #if defined(POLARSSL_HAVEGE_C) /** * \brief HAVEGE based entropy poll callback * * Requires an HAVEGE state as its data pointer. */ int havege_poll( void *data, unsigned char *output, size_t len, size_t *olen ); #endif #if defined(POLARSSL_TIMING_C) /** * \brief hardclock-based entropy poll callback */ int hardclock_poll( void *data, unsigned char *output, size_t len, size_t *olen ); #endif #ifdef __cplusplus } #endif #endif /* entropy_poll.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/timing.h0000644000014601777760000000356312165464055024564 0ustar00jenkinsnogroup00000000000000/** * \file timing.h * * \brief Portable interface to the CPU cycle counter * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_TIMING_H #define POLARSSL_TIMING_H /** * \brief timer structure */ struct hr_time { unsigned char opaque[32]; }; #ifdef __cplusplus extern "C" { #endif extern volatile int alarmed; /** * \brief Return the CPU cycle counter value */ unsigned long hardclock( void ); /** * \brief Return the elapsed time in milliseconds * * \param val points to a timer structure * \param reset if set to 1, the timer is restarted */ unsigned long get_timer( struct hr_time *val, int reset ); /** * \brief Setup an alarm clock * * \param seconds delay before the "alarmed" flag is set */ void set_alarm( int seconds ); /** * \brief Sleep for a certain amount of time * * \param milliseconds delay in milliseconds */ void m_sleep( int milliseconds ); #ifdef __cplusplus } #endif #endif /* timing.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/openssl.h0000644000014601777760000001165712165464055024763 0ustar00jenkinsnogroup00000000000000/** * \file openssl.h * * \brief OpenSSL wrapper (definitions, inline functions). * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * OpenSSL wrapper contributed by David Barett */ #ifndef POLARSSL_OPENSSL_H #define POLARSSL_OPENSSL_H #include "aes.h" #include "md5.h" #include "rsa.h" #include "sha1.h" #define AES_SIZE 16 #define AES_BLOCK_SIZE 16 #define AES_KEY aes_context #define MD5_CTX md5_context #define SHA_CTX sha1_context #define SHA1_Init( CTX ) \ sha1_starts( (CTX) ) #define SHA1_Update( CTX, BUF, LEN ) \ sha1_update( (CTX), (unsigned char *)(BUF), (LEN) ) #define SHA1_Final( OUT, CTX ) \ sha1_finish( (CTX), (OUT) ) #define MD5_Init( CTX ) \ md5_starts( (CTX) ) #define MD5_Update( CTX, BUF, LEN ) \ md5_update( (CTX), (unsigned char *)(BUF), (LEN) ) #define MD5_Final( OUT, CTX ) \ md5_finish( (CTX), (OUT) ) #define AES_set_encrypt_key( KEY, KEYSIZE, CTX ) \ aes_setkey_enc( (CTX), (KEY), (KEYSIZE) ) #define AES_set_decrypt_key( KEY, KEYSIZE, CTX ) \ aes_setkey_dec( (CTX), (KEY), (KEYSIZE) ) #define AES_cbc_encrypt( INPUT, OUTPUT, LEN, CTX, IV, MODE ) \ aes_crypt_cbc( (CTX), (MODE), (LEN), (IV), (INPUT), (OUTPUT) ) /* * RSA stuff follows. TODO: needs cleanup */ inline int __RSA_Passthrough( void *output, void *input, int size ) { memcpy( output, input, size ); return size; } inline rsa_context* d2i_RSA_PUBKEY( void *ignore, unsigned char **bufptr, int len ) { unsigned char *buffer = *(unsigned char **) bufptr; rsa_context *rsa; /* * Not a general-purpose parser: only parses public key from *exactly* * openssl genrsa -out privkey.pem 512 (or 1024) * openssl rsa -in privkey.pem -out privatekey.der -outform der * openssl rsa -in privkey.pem -out pubkey.der -outform der -pubout * * TODO: make a general-purpose parse */ if( ignore != 0 || ( len != 94 && len != 162 ) ) return( 0 ); rsa = (rsa_context *) malloc( sizeof( rsa_rsa ) ); if( rsa == NULL ) return( 0 ); memset( rsa, 0, sizeof( rsa_context ) ); if( ( len == 94 && mpi_read_binary( &rsa->N, &buffer[ 25], 64 ) == 0 && mpi_read_binary( &rsa->E, &buffer[ 91], 3 ) == 0 ) || ( len == 162 && mpi_read_binary( &rsa->N, &buffer[ 29], 128 ) == 0 ) && mpi_read_binary( &rsa->E, &buffer[159], 3 ) == 0 ) { /* * key read successfully */ rsa->len = ( mpi_msb( &rsa->N ) + 7 ) >> 3; return( rsa ); } else { memset( rsa, 0, sizeof( rsa_context ) ); free( rsa ); return( 0 ); } } #define RSA rsa_context #define RSA_PKCS1_PADDING 1 /* ignored; always encrypt with this */ #define RSA_size( CTX ) (CTX)->len #define RSA_free( CTX ) rsa_free( CTX ) #define ERR_get_error( ) "ERR_get_error() not supported" #define RSA_blinding_off( IGNORE ) #define d2i_RSAPrivateKey( a, b, c ) new rsa_context /* TODO: C++ bleh */ inline int RSA_public_decrypt ( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { int outsize=size; if( !rsa_pkcs1_decrypt( key, RSA_PUBLIC, &outsize, input, output ) ) return outsize; else return -1; } inline int RSA_private_decrypt( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { int outsize=size; if( !rsa_pkcs1_decrypt( key, RSA_PRIVATE, &outsize, input, output ) ) return outsize; else return -1; } inline int RSA_public_encrypt ( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { if( !rsa_pkcs1_encrypt( key, RSA_PUBLIC, size, input, output ) ) return RSA_size(key); else return -1; } inline int RSA_private_encrypt( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { if( !rsa_pkcs1_encrypt( key, RSA_PRIVATE, size, input, output ) ) return RSA_size(key); else return -1; } #ifdef __cplusplus } #endif #endif /* openssl.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/entropy.h0000644000014601777760000001100212165464055024760 0ustar00jenkinsnogroup00000000000000/** * \file entropy.h * * \brief Entropy accumulator implementation * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_ENTROPY_H #define POLARSSL_ENTROPY_H #include #include "config.h" #include "sha4.h" #if defined(POLARSSL_HAVEGE_C) #include "havege.h" #endif #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C /**< Critical entropy source failure. */ #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E /**< No more sources can be added. */ #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 /**< No sources have been added to poll. */ #define ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ #define ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ #define ENTROPY_BLOCK_SIZE 64 /**< Block size of entropy accumulator (SHA-512) */ #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES #ifdef __cplusplus extern "C" { #endif /** * \brief Entropy poll callback pointer * * \param data Callback-specific data pointer * \param output Data to fill * \param len Maximum size to provide * \param olen The actual amount of bytes put into the buffer (Can be 0) * * \return 0 if no critical failures occurred, * POLARSSL_ERR_ENTROPY_SOURCE_FAILED otherwise */ typedef int (*f_source_ptr)(void *, unsigned char *, size_t, size_t *); /** * \brief Entropy source state */ typedef struct { f_source_ptr f_source; /**< The entropy source callback */ void * p_source; /**< The callback data pointer */ size_t size; /**< Amount received */ size_t threshold; /**< Minimum level required before release */ } source_state; /** * \brief Entropy context structure */ typedef struct { sha4_context accumulator; int source_count; source_state source[ENTROPY_MAX_SOURCES]; #if defined(POLARSSL_HAVEGE_C) havege_state havege_data; #endif } entropy_context; /** * \brief Initialize the context * * \param ctx Entropy context to initialize */ void entropy_init( entropy_context *ctx ); /** * \brief Adds an entropy source to poll * * \param ctx Entropy context * \param f_source Entropy function * \param p_source Function data * \param threshold Minimum required from source before entropy is released * ( with entropy_func() ) * * \return 0 if successful or POLARSSL_ERR_ENTROPY_MAX_SOURCES */ int entropy_add_source( entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold ); /** * \brief Trigger an extra gather poll for the accumulator * * \param ctx Entropy context * * \return 0 if successful, or POLARSSL_ERR_ENTROPY_SOURCE_FAILED */ int entropy_gather( entropy_context *ctx ); /** * \brief Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) * * \param data Entropy context * \param output Buffer to fill * \param len Length of buffer * * \return 0 if successful, or POLARSSL_ERR_ENTROPY_SOURCE_FAILED */ int entropy_func( void *data, unsigned char *output, size_t len ); /** * \brief Add data to the accumulator manually * * \param ctx Entropy context * \param data Data to add * \param len Length of data * * \return 0 if successful */ int entropy_update_manual( entropy_context *ctx, const unsigned char *data, size_t len ); #ifdef __cplusplus } #endif #endif /* entropy.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/pem.h0000644000014601777760000000670212165464055024054 0ustar00jenkinsnogroup00000000000000/** * \file pem.h * * \brief Privacy Enhanced Mail (PEM) decoding * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_PEM_H #define POLARSSL_PEM_H #include /** * \name PEM Error codes * These error codes are returned in case of errors reading the * PEM data. * \{ */ #define POLARSSL_ERR_PEM_NO_HEADER_PRESENT -0x1080 /**< No PEM header found. */ #define POLARSSL_ERR_PEM_INVALID_DATA -0x1100 /**< PEM string is not as expected. */ #define POLARSSL_ERR_PEM_MALLOC_FAILED -0x1180 /**< Failed to allocate memory. */ #define POLARSSL_ERR_PEM_INVALID_ENC_IV -0x1200 /**< RSA IV is not in hex-format. */ #define POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG -0x1280 /**< Unsupported key encryption algorithm. */ #define POLARSSL_ERR_PEM_PASSWORD_REQUIRED -0x1300 /**< Private key password can't be empty. */ #define POLARSSL_ERR_PEM_PASSWORD_MISMATCH -0x1380 /**< Given private key password does not allow for correct decryption. */ #define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE -0x1400 /**< Unavailable feature, e.g. hashing/encryption combination. */ /* \} name */ /** * \brief PEM context structure */ typedef struct { unsigned char *buf; /*!< buffer for decoded data */ size_t buflen; /*!< length of the buffer */ unsigned char *info; /*!< buffer for extra header information */ } pem_context; #ifdef __cplusplus extern "C" { #endif /** * \brief PEM context setup * * \param ctx context to be initialized */ void pem_init( pem_context *ctx ); /** * \brief Read a buffer for PEM information and store the resulting * data into the specified context buffers. * * \param ctx context to use * \param header header string to seek and expect * \param footer footer string to seek and expect * \param data source data to look in * \param pwd password for decryption (can be NULL) * \param pwdlen length of password * \param use_len destination for total length used * * \return 0 on success, ior a specific PEM error code */ int pem_read_buffer( pem_context *ctx, char *header, char *footer, const unsigned char *data, const unsigned char *pwd, size_t pwdlen, size_t *use_len ); /** * \brief PEM context memory freeing * * \param ctx context to be freed */ void pem_free( pem_context *ctx ); #ifdef __cplusplus } #endif #endif /* pem.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/md.h0000644000014601777760000002525712165464055023701 0ustar00jenkinsnogroup00000000000000/** * \file md.h * * \brief Generic message digest wrapper * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_MD_H #define POLARSSL_MD_H #include #if defined(_MSC_VER) && !defined(inline) #define inline _inline #else #if defined(__ARMCC_VERSION) && !defined(inline) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */ #define POLARSSL_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ #define POLARSSL_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */ #define POLARSSL_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */ typedef enum { POLARSSL_MD_NONE=0, POLARSSL_MD_MD2, POLARSSL_MD_MD4, POLARSSL_MD_MD5, POLARSSL_MD_SHA1, POLARSSL_MD_SHA224, POLARSSL_MD_SHA256, POLARSSL_MD_SHA384, POLARSSL_MD_SHA512, } md_type_t; #define POLARSSL_MD_MAX_SIZE 64 /* longest known is SHA512 */ /** * Message digest information. Allows message digest functions to be called * in a generic way. */ typedef struct { /** Digest identifier */ md_type_t type; /** Name of the message digest */ const char * name; /** Output length of the digest function */ int size; /** Digest initialisation function */ void (*starts_func)( void *ctx ); /** Digest update function */ void (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); /** Digest finalisation function */ void (*finish_func)( void *ctx, unsigned char *output ); /** Generic digest function */ void (*digest_func)( const unsigned char *input, size_t ilen, unsigned char *output ); /** Generic file digest function */ int (*file_func)( const char *path, unsigned char *output ); /** HMAC Initialisation function */ void (*hmac_starts_func)( void *ctx, const unsigned char *key, size_t keylen ); /** HMAC update function */ void (*hmac_update_func)( void *ctx, const unsigned char *input, size_t ilen ); /** HMAC finalisation function */ void (*hmac_finish_func)( void *ctx, unsigned char *output); /** HMAC context reset function */ void (*hmac_reset_func)( void *ctx ); /** Generic HMAC function */ void (*hmac_func)( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); /** Free the given context */ void (*ctx_free_func)( void *ctx ); } md_info_t; /** * Generic message digest context. */ typedef struct { /** Information about the associated message digest */ const md_info_t *md_info; /** Digest-specific context */ void *md_ctx; } md_context_t; #define MD_CONTEXT_T_INIT { \ NULL, /* md_info */ \ NULL, /* md_ctx */ \ } #ifdef __cplusplus extern "C" { #endif /** * \brief Returns the list of digests supported by the generic digest module. * * \return a statically allocated array of digests, the last entry * is 0. */ const int *md_list( void ); /** * \brief Returns the message digest information associated with the * given digest name. * * \param md_name Name of the digest to search for. * * \return The message digest information associated with md_name or * NULL if not found. */ const md_info_t *md_info_from_string( const char *md_name ); /** * \brief Returns the message digest information associated with the * given digest type. * * \param md_type type of digest to search for. * * \return The message digest information associated with md_type or * NULL if not found. */ const md_info_t *md_info_from_type( md_type_t md_type ); /** * \brief Initialises and fills the message digest context structure with * the appropriate values. * * \param ctx context to initialise. May not be NULL. The * digest-specific context (ctx->md_ctx) must be NULL. It will * be allocated, and must be freed using md_free_ctx() later. * \param md_info message digest to use. * * \returns \c 0 on success, \c POLARSSL_ERR_MD_BAD_INPUT_DATA on * parameter failure, \c POLARSSL_ERR_MD_ALLOC_FAILED if * allocation of the digest-specific context failed. */ int md_init_ctx( md_context_t *ctx, const md_info_t *md_info ); /** * \brief Free the message-specific context of ctx. Freeing ctx itself * remains the responsibility of the caller. * * \param ctx Free the message-specific context * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_free_ctx( md_context_t *ctx ); /** * \brief Returns the size of the message digest output. * * \param md_info message digest info * * \return size of the message digest output. */ static inline unsigned char md_get_size( const md_info_t *md_info ) { return md_info->size; } /** * \brief Returns the type of the message digest output. * * \param md_info message digest info * * \return type of the message digest output. */ static inline md_type_t md_get_type( const md_info_t *md_info ) { return md_info->type; } /** * \brief Returns the name of the message digest output. * * \param md_info message digest info * * \return name of the message digest output. */ static inline const char *md_get_name( const md_info_t *md_info ) { return md_info->name; } /** * \brief Set-up the given context for a new message digest * * \param ctx generic message digest context. * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_starts( md_context_t *ctx ); /** * \brief Generic message digest process buffer * * \param ctx Generic message digest context * \param input buffer holding the datal * \param ilen length of the input data * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_update( md_context_t *ctx, const unsigned char *input, size_t ilen ); /** * \brief Generic message digest final digest * * \param ctx Generic message digest context * \param output Generic message digest checksum result * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_finish( md_context_t *ctx, unsigned char *output ); /** * \brief Output = message_digest( input buffer ) * * \param md_info message digest info * \param input buffer holding the data * \param ilen length of the input data * \param output Generic message digest checksum result * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md( const md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output ); /** * \brief Output = message_digest( file contents ) * * \param md_info message digest info * \param path input file name * \param output generic message digest checksum result * * \return 0 if successful, POLARSSL_ERR_MD_FILE_OPEN_FAILED if fopen * failed, POLARSSL_ERR_MD_FILE_READ_FAILED if fread failed, * POLARSSL_ERR_MD_BAD_INPUT_DATA if md_info was NULL. */ int md_file( const md_info_t *md_info, const char *path, unsigned char *output ); /** * \brief Generic HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen ); /** * \brief Generic HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen ); /** * \brief Generic HMAC final digest * * \param ctx HMAC context * \param output Generic HMAC checksum result * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_hmac_finish( md_context_t *ctx, unsigned char *output); /** * \brief Generic HMAC context reset * * \param ctx HMAC context to be reset * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_hmac_reset( md_context_t *ctx ); /** * \brief Output = Generic_HMAC( hmac key, input buffer ) * * \param md_info message digest info * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output Generic HMAC-result * * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ); #ifdef __cplusplus } #endif #endif /* POLARSSL_MD_H */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/certs.h0000644000014601777760000000264412165464055024414 0ustar00jenkinsnogroup00000000000000/** * \file certs.h * * \brief Sample certificates and DHM parameters for testing * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_CERTS_H #define POLARSSL_CERTS_H #ifdef __cplusplus extern "C" { #endif extern const char test_ca_crt[]; extern const char test_ca_key[]; extern const char test_ca_pwd[]; extern const char test_srv_crt[]; extern const char test_srv_key[]; extern const char test_cli_crt[]; extern const char test_cli_key[]; extern const char test_dhm_params[]; #ifdef __cplusplus } #endif #endif /* certs.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/sha4.h0000644000014601777760000001145512165464055024133 0ustar00jenkinsnogroup00000000000000/** * \file sha4.h * * \brief SHA-384 and SHA-512 cryptographic hash function * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_SHA4_H #define POLARSSL_SHA4_H #include #define POLARSSL_ERR_SHA4_FILE_IO_ERROR -0x007A /**< Read/write error in file. */ #if defined(_MSC_VER) || defined(__WATCOMC__) #define UL64(x) x##ui64 #define long64 __int64 #else #define UL64(x) x##ULL #define long64 long long #endif /** * \brief SHA-512 context structure */ typedef struct { unsigned long64 total[2]; /*!< number of bytes processed */ unsigned long64 state[8]; /*!< intermediate digest state */ unsigned char buffer[128]; /*!< data block being processed */ unsigned char ipad[128]; /*!< HMAC: inner padding */ unsigned char opad[128]; /*!< HMAC: outer padding */ int is384; /*!< 0 => SHA-512, else SHA-384 */ } sha4_context; #ifdef __cplusplus extern "C" { #endif /** * \brief SHA-512 context setup * * \param ctx context to be initialized * \param is384 0 = use SHA512, 1 = use SHA384 */ void sha4_starts( sha4_context *ctx, int is384 ); /** * \brief SHA-512 process buffer * * \param ctx SHA-512 context * \param input buffer holding the data * \param ilen length of the input data */ void sha4_update( sha4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-512 final digest * * \param ctx SHA-512 context * \param output SHA-384/512 checksum result */ void sha4_finish( sha4_context *ctx, unsigned char output[64] ); /** * \brief Output = SHA-512( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output SHA-384/512 checksum result * \param is384 0 = use SHA512, 1 = use SHA384 */ void sha4( const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ); /** * \brief Output = SHA-512( file contents ) * * \param path input file name * \param output SHA-384/512 checksum result * \param is384 0 = use SHA512, 1 = use SHA384 * * \return 0 if successful, or POLARSSL_ERR_SHA4_FILE_IO_ERROR */ int sha4_file( const char *path, unsigned char output[64], int is384 ); /** * \brief SHA-512 HMAC context setup * * \param ctx HMAC context to be initialized * \param is384 0 = use SHA512, 1 = use SHA384 * \param key HMAC secret key * \param keylen length of the HMAC key */ void sha4_hmac_starts( sha4_context *ctx, const unsigned char *key, size_t keylen, int is384 ); /** * \brief SHA-512 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void sha4_hmac_update( sha4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-512 HMAC final digest * * \param ctx HMAC context * \param output SHA-384/512 HMAC checksum result */ void sha4_hmac_finish( sha4_context *ctx, unsigned char output[64] ); /** * \brief SHA-512 HMAC context reset * * \param ctx HMAC context to be reset */ void sha4_hmac_reset( sha4_context *ctx ); /** * \brief Output = HMAC-SHA-512( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-SHA-384/512 result * \param is384 0 = use SHA512, 1 = use SHA384 */ void sha4_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int sha4_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* sha4.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/des.h0000644000014601777760000001443012165464055024043 0ustar00jenkinsnogroup00000000000000/** * \file des.h * * \brief DES block cipher * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_DES_H #define POLARSSL_DES_H #include #define DES_ENCRYPT 1 #define DES_DECRYPT 0 #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0032 /**< The data input has an invalid length. */ #define DES_KEY_SIZE 8 /** * \brief DES context structure */ typedef struct { int mode; /*!< encrypt/decrypt */ unsigned long sk[32]; /*!< DES subkeys */ } des_context; /** * \brief Triple-DES context structure */ typedef struct { int mode; /*!< encrypt/decrypt */ unsigned long sk[96]; /*!< 3DES subkeys */ } des3_context; #ifdef __cplusplus extern "C" { #endif /** * \brief Set key parity on the given key to odd. * * DES keys are 56 bits long, but each byte is padded with * a parity bit to allow verification. * * \param key 8-byte secret key */ void des_key_set_parity( unsigned char key[DES_KEY_SIZE] ); /** * \brief Check that key parity on the given key is odd. * * DES keys are 56 bits long, but each byte is padded with * a parity bit to allow verification. * * \param key 8-byte secret key * * \return 0 is parity was ok, 1 if parity was not correct. */ int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] ); /** * \brief Check that key is not a weak or semi-weak DES key * * \param key 8-byte secret key * * \return 0 if no weak key was found, 1 if a weak key was identified. */ int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] ); /** * \brief DES key schedule (56-bit, encryption) * * \param ctx DES context to be initialized * \param key 8-byte secret key * * \return 0 */ int des_setkey_enc( des_context *ctx, const unsigned char key[DES_KEY_SIZE] ); /** * \brief DES key schedule (56-bit, decryption) * * \param ctx DES context to be initialized * \param key 8-byte secret key * * \return 0 */ int des_setkey_dec( des_context *ctx, const unsigned char key[DES_KEY_SIZE] ); /** * \brief Triple-DES key schedule (112-bit, encryption) * * \param ctx 3DES context to be initialized * \param key 16-byte secret key * * \return 0 */ int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (112-bit, decryption) * * \param ctx 3DES context to be initialized * \param key 16-byte secret key * * \return 0 */ int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (168-bit, encryption) * * \param ctx 3DES context to be initialized * \param key 24-byte secret key * * \return 0 */ int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ); /** * \brief Triple-DES key schedule (168-bit, decryption) * * \param ctx 3DES context to be initialized * \param key 24-byte secret key * * \return 0 */ int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ); /** * \brief DES-ECB block encryption/decryption * * \param ctx DES context * \param input 64-bit input block * \param output 64-bit output block * * \return 0 if successful */ int des_crypt_ecb( des_context *ctx, const unsigned char input[8], unsigned char output[8] ); /** * \brief DES-CBC buffer encryption/decryption * * \param ctx DES context * \param mode DES_ENCRYPT or DES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data */ int des_crypt_cbc( des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ); /** * \brief 3DES-ECB block encryption/decryption * * \param ctx 3DES context * \param input 64-bit input block * \param output 64-bit output block * * \return 0 if successful */ int des3_crypt_ecb( des3_context *ctx, const unsigned char input[8], unsigned char output[8] ); /** * \brief 3DES-CBC buffer encryption/decryption * * \param ctx 3DES context * \param mode DES_ENCRYPT or DES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful, or POLARSSL_ERR_DES_INVALID_INPUT_LENGTH */ int des3_crypt_cbc( des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ); /* * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int des_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* des.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/error.h0000644000014601777760000000560312165464055024423 0ustar00jenkinsnogroup00000000000000/** * \file error.h * * \brief Error to string translation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_ERROR_H #define POLARSSL_ERROR_H /** * Error code layout. * * Currently we try to keep all error codes within the negative space of 16 * bytes signed integers to support all platforms (-0x0000 - -0x8000). In * addition we'd like to give two layers of information on the error if * possible. * * For that purpose the error codes are segmented in the following manner: * * 16 bit error code bit-segmentation * * 1 bit - Intentionally not used * 3 bits - High level module ID * 5 bits - Module-dependent error code * 6 bits - Low level module errors * 1 bit - Intentionally not used * * Low-level module errors (0x007E-0x0002) * * Module Nr Codes assigned * MPI 7 0x0002-0x0010 * ASN1 6 0x0014-0x001E * AES 2 0x0020-0x0022 * CAMELLIA 2 0x0024-0x0026 * XTEA 1 0x0028-0x0028 * BASE64 2 0x002A-0x002C * PADLOCK 1 0x0030-0x0030 * DES 1 0x0032-0x0032 * NET 11 0x0040-0x0054 * CTR_DBRG 3 0x0034-0x003A * ENTROPY 3 0x003C-0x0040 * MD2 1 0x0070-0x0070 * MD4 1 0x0072-0x0072 * MD5 1 0x0074-0x0074 * SHA1 1 0x0076-0x0076 * SHA2 1 0x0078-0x0078 * SHA4 1 0x007A-0x007A * * High-level module nr (3 bits - 0x1...-0x8...) * Name ID Nr of Errors * PEM 1 8 * X509 2 21 * DHM 3 6 * RSA 4 9 * MD 5 4 * CIPHER 6 5 * SSL 7 30 * * Module dependent error code (5 bits 0x.08.-0x.F8.) */ #ifdef __cplusplus extern "C" { #endif /** * \brief Translate a PolarSSL error code into a string representation, * Result is truncated if necessary and always includes a terminating * null byte. * * \param errnum error code * \param buffer buffer to place representation in * \param buflen length of the buffer */ void error_strerror( int errnum, char *buffer, size_t buflen ); #ifdef __cplusplus } #endif #endif /* error.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/cipher.h0000644000014601777760000003614112165464055024545 0ustar00jenkinsnogroup00000000000000/** * \file cipher.h * * \brief Generic cipher wrapper. * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_CIPHER_H #define POLARSSL_CIPHER_H #include #if defined(_MSC_VER) && !defined(inline) #define inline _inline #else #if defined(__ARMCC_VERSION) && !defined(inline) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ #define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */ #define POLARSSL_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters to function. */ #define POLARSSL_ERR_CIPHER_ALLOC_FAILED -0x6180 /**< Failed to allocate memory. */ #define POLARSSL_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */ #define POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */ typedef enum { POLARSSL_CIPHER_ID_NONE = 0, POLARSSL_CIPHER_ID_AES, POLARSSL_CIPHER_ID_DES, POLARSSL_CIPHER_ID_3DES, POLARSSL_CIPHER_ID_CAMELLIA, } cipher_id_t; typedef enum { POLARSSL_CIPHER_NONE = 0, POLARSSL_CIPHER_AES_128_CBC, POLARSSL_CIPHER_AES_192_CBC, POLARSSL_CIPHER_AES_256_CBC, POLARSSL_CIPHER_AES_128_CFB128, POLARSSL_CIPHER_AES_192_CFB128, POLARSSL_CIPHER_AES_256_CFB128, POLARSSL_CIPHER_AES_128_CTR, POLARSSL_CIPHER_AES_192_CTR, POLARSSL_CIPHER_AES_256_CTR, POLARSSL_CIPHER_CAMELLIA_128_CBC, POLARSSL_CIPHER_CAMELLIA_192_CBC, POLARSSL_CIPHER_CAMELLIA_256_CBC, POLARSSL_CIPHER_CAMELLIA_128_CFB128, POLARSSL_CIPHER_CAMELLIA_192_CFB128, POLARSSL_CIPHER_CAMELLIA_256_CFB128, POLARSSL_CIPHER_CAMELLIA_128_CTR, POLARSSL_CIPHER_CAMELLIA_192_CTR, POLARSSL_CIPHER_CAMELLIA_256_CTR, POLARSSL_CIPHER_DES_CBC, POLARSSL_CIPHER_DES_EDE_CBC, POLARSSL_CIPHER_DES_EDE3_CBC } cipher_type_t; typedef enum { POLARSSL_MODE_NONE = 0, POLARSSL_MODE_CBC, POLARSSL_MODE_CFB128, POLARSSL_MODE_OFB, POLARSSL_MODE_CTR, } cipher_mode_t; typedef enum { POLARSSL_OPERATION_NONE = -1, POLARSSL_DECRYPT = 0, POLARSSL_ENCRYPT, } operation_t; enum { /** Undefined key length */ POLARSSL_KEY_LENGTH_NONE = 0, /** Key length, in bits (including parity), for DES keys */ POLARSSL_KEY_LENGTH_DES = 64, /** Key length, in bits (including parity), for DES in two key EDE */ POLARSSL_KEY_LENGTH_DES_EDE = 128, /** Key length, in bits (including parity), for DES in three-key EDE */ POLARSSL_KEY_LENGTH_DES_EDE3 = 192, /** Maximum length of any IV, in bytes */ POLARSSL_MAX_IV_LENGTH = 16, }; /** * Base cipher information. The non-mode specific functions and values. */ typedef struct { /** Base Cipher type (e.g. POLARSSL_CIPHER_ID_AES) */ cipher_id_t cipher; /** Encrypt using CBC */ int (*cbc_func)( void *ctx, operation_t mode, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ); /** Encrypt using CFB128 */ int (*cfb128_func)( void *ctx, operation_t mode, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ); /** Encrypt using CTR */ int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ); /** Set key for encryption purposes */ int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_length); /** Set key for decryption purposes */ int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_length); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); /** Free the given context */ void (*ctx_free_func)( void *ctx ); } cipher_base_t; /** * Cipher information. Allows cipher functions to be called in a generic way. */ typedef struct { /** Full cipher identifier (e.g. POLARSSL_CIPHER_AES_256_CBC) */ cipher_type_t type; /** Cipher mode (e.g. POLARSSL_MODE_CBC) */ cipher_mode_t mode; /** Cipher key length, in bits (default length for variable sized ciphers) * (Includes parity bits for ciphers like DES) */ unsigned int key_length; /** Name of the cipher */ const char * name; /** IV size, in bytes */ unsigned int iv_size; /** block size, in bytes */ unsigned int block_size; /** Base cipher information and functions */ const cipher_base_t *base; } cipher_info_t; /** * Generic cipher context. */ typedef struct { /** Information about the associated cipher */ const cipher_info_t *cipher_info; /** Key length to use */ int key_length; /** Operation that the context's key has been initialised for */ operation_t operation; /** Buffer for data that hasn't been encrypted yet */ unsigned char unprocessed_data[POLARSSL_MAX_IV_LENGTH]; /** Number of bytes that still need processing */ size_t unprocessed_len; /** Current IV or NONCE_COUNTER for CTR-mode */ unsigned char iv[POLARSSL_MAX_IV_LENGTH]; /** Cipher-specific context */ void *cipher_ctx; } cipher_context_t; #ifdef __cplusplus extern "C" { #endif /** * \brief Returns the list of ciphers supported by the generic cipher module. * * \return a statically allocated array of ciphers, the last entry * is 0. */ const int *cipher_list( void ); /** * \brief Returns the cipher information structure associated * with the given cipher name. * * \param cipher_name Name of the cipher to search for. * * \return the cipher information structure associated with the * given cipher_name, or NULL if not found. */ const cipher_info_t *cipher_info_from_string( const char *cipher_name ); /** * \brief Returns the cipher information structure associated * with the given cipher type. * * \param cipher_type Type of the cipher to search for. * * \return the cipher information structure associated with the * given cipher_type, or NULL if not found. */ const cipher_info_t *cipher_info_from_type( const cipher_type_t cipher_type ); /** * \brief Initialises and fills the cipher context structure with * the appropriate values. * * \param ctx context to initialise. May not be NULL. * \param cipher_info cipher to use. * * \return \c 0 on success, * \c POLARSSL_ERR_CIPHER_BAD_INPUT_DATA on parameter failure, * \c POLARSSL_ERR_CIPHER_ALLOC_FAILED if allocation of the * cipher-specific context failed. */ int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info ); /** * \brief Free the cipher-specific context of ctx. Freeing ctx * itself remains the responsibility of the caller. * * \param ctx Free the cipher-specific context * * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if * parameter verification fails. */ int cipher_free_ctx( cipher_context_t *ctx ); /** * \brief Returns the block size of the given cipher. * * \param ctx cipher's context. Must have been initialised. * * \return size of the cipher's blocks, or 0 if ctx has not been * initialised. */ static inline unsigned int cipher_get_block_size( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return 0; return ctx->cipher_info->block_size; } /** * \brief Returns the mode of operation for the cipher. * (e.g. POLARSSL_MODE_CBC) * * \param ctx cipher's context. Must have been initialised. * * \return mode of operation, or POLARSSL_MODE_NONE if ctx * has not been initialised. */ static inline cipher_mode_t cipher_get_cipher_mode( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return POLARSSL_MODE_NONE; return ctx->cipher_info->mode; } /** * \brief Returns the size of the cipher's IV. * * \param ctx cipher's context. Must have been initialised. * * \return size of the cipher's IV, or 0 if ctx has not been * initialised. */ static inline int cipher_get_iv_size( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return 0; return ctx->cipher_info->iv_size; } /** * \brief Returns the type of the given cipher. * * \param ctx cipher's context. Must have been initialised. * * \return type of the cipher, or POLARSSL_CIPHER_NONE if ctx has * not been initialised. */ static inline cipher_type_t cipher_get_type( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return 0; return ctx->cipher_info->type; } /** * \brief Returns the name of the given cipher, as a string. * * \param ctx cipher's context. Must have been initialised. * * \return name of the cipher, or NULL if ctx was not initialised. */ static inline const char *cipher_get_name( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return 0; return ctx->cipher_info->name; } /** * \brief Returns the key length of the cipher. * * \param ctx cipher's context. Must have been initialised. * * \return cipher's key length, in bits, or * POLARSSL_KEY_LENGTH_NONE if ctx has not been * initialised. */ static inline int cipher_get_key_size ( const cipher_context_t *ctx ) { if( NULL == ctx ) return POLARSSL_KEY_LENGTH_NONE; return ctx->key_length; } /** * \brief Returns the operation of the given cipher. * * \param ctx cipher's context. Must have been initialised. * * \return operation (POLARSSL_ENCRYPT or POLARSSL_DECRYPT), * or POLARSSL_OPERATION_NONE if ctx has not been * initialised. */ static inline operation_t cipher_get_operation( const cipher_context_t *ctx ) { if( NULL == ctx || NULL == ctx->cipher_info ) return POLARSSL_OPERATION_NONE; return ctx->operation; } /** * \brief Set the key to use with the given context. * * \param ctx generic cipher context. May not be NULL. Must have been * initialised using cipher_context_from_type or * cipher_context_from_string. * \param key The key to use. * \param key_length key length to use, in bits. * \param operation Operation that the key will be used for, either * POLARSSL_ENCRYPT or POLARSSL_DECRYPT. * * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if * parameter verification fails or a cipher specific * error code. */ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, int key_length, const operation_t operation ); /** * \brief Reset the given context, setting the IV to iv * * \param ctx generic cipher context * \param iv IV to use or NONCE_COUNTER in the case of a CTR-mode cipher * * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA * if parameter verification fails. */ int cipher_reset( cipher_context_t *ctx, const unsigned char *iv ); /** * \brief Generic cipher update function. Encrypts/decrypts * using the given cipher context. Writes as many block * size'd blocks of data as possible to output. Any data * that cannot be written immediately will either be added * to the next block, or flushed when cipher_final is * called. * * \param ctx generic cipher context * \param input buffer holding the input data * \param ilen length of the input data * \param output buffer for the output data. Should be able to hold at * least ilen + block_size. Cannot be the same buffer as * input! * \param olen length of the output data, will be filled with the * actual number of bytes written. * * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if * parameter verification fails, * POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE on an * unsupported mode for a cipher or a cipher specific * error code. */ int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ); /** * \brief Generic cipher finalisation function. If data still * needs to be flushed from an incomplete block, data * contained within it will be padded with the size of * the last block, and written to the output buffer. * * \param ctx Generic cipher context * \param output buffer to write data to. Needs block_size data available. * \param olen length of the data written to the output buffer. * * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if * parameter verification fails, * POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption * expected a full block but was not provided one, * POLARSSL_ERR_CIPHER_INVALID_PADDING on invalid padding * while decrypting or a cipher specific error code. */ int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int cipher_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* POLARSSL_MD_H */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/md2.h0000644000014601777760000001027412165464055023754 0ustar00jenkinsnogroup00000000000000/** * \file md2.h * * \brief MD2 message digest algorithm (hash function) * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_MD2_H #define POLARSSL_MD2_H #include #define POLARSSL_ERR_MD2_FILE_IO_ERROR -0x0070 /**< Read/write error in file. */ /** * \brief MD2 context structure */ typedef struct { unsigned char cksum[16]; /*!< checksum of the data block */ unsigned char state[48]; /*!< intermediate digest state */ unsigned char buffer[16]; /*!< data block being processed */ unsigned char ipad[16]; /*!< HMAC: inner padding */ unsigned char opad[16]; /*!< HMAC: outer padding */ size_t left; /*!< amount of data in buffer */ } md2_context; #ifdef __cplusplus extern "C" { #endif /** * \brief MD2 context setup * * \param ctx context to be initialized */ void md2_starts( md2_context *ctx ); /** * \brief MD2 process buffer * * \param ctx MD2 context * \param input buffer holding the data * \param ilen length of the input data */ void md2_update( md2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD2 final digest * * \param ctx MD2 context * \param output MD2 checksum result */ void md2_finish( md2_context *ctx, unsigned char output[16] ); /** * \brief Output = MD2( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD2 checksum result */ void md2( const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Output = MD2( file contents ) * * \param path input file name * \param output MD2 checksum result * * \return 0 if successful, or POLARSSL_ERR_MD2_FILE_IO_ERROR */ int md2_file( const char *path, unsigned char output[16] ); /** * \brief MD2 HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key */ void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen ); /** * \brief MD2 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void md2_hmac_update( md2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD2 HMAC final digest * * \param ctx HMAC context * \param output MD2 HMAC checksum result */ void md2_hmac_finish( md2_context *ctx, unsigned char output[16] ); /** * \brief MD2 HMAC context reset * * \param ctx HMAC context to be reset */ void md2_hmac_reset( md2_context *ctx ); /** * \brief Output = HMAC-MD2( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-MD2 result */ void md2_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int md2_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* md2.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/md4.h0000644000014601777760000001017112165464055023752 0ustar00jenkinsnogroup00000000000000/** * \file md4.h * * \brief MD4 message digest algorithm (hash function) * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_MD4_H #define POLARSSL_MD4_H #include #define POLARSSL_ERR_MD4_FILE_IO_ERROR -0x0072 /**< Read/write error in file. */ /** * \brief MD4 context structure */ typedef struct { unsigned long total[2]; /*!< number of bytes processed */ unsigned long state[4]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ unsigned char ipad[64]; /*!< HMAC: inner padding */ unsigned char opad[64]; /*!< HMAC: outer padding */ } md4_context; #ifdef __cplusplus extern "C" { #endif /** * \brief MD4 context setup * * \param ctx context to be initialized */ void md4_starts( md4_context *ctx ); /** * \brief MD4 process buffer * * \param ctx MD4 context * \param input buffer holding the data * \param ilen length of the input data */ void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD4 final digest * * \param ctx MD4 context * \param output MD4 checksum result */ void md4_finish( md4_context *ctx, unsigned char output[16] ); /** * \brief Output = MD4( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD4 checksum result */ void md4( const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Output = MD4( file contents ) * * \param path input file name * \param output MD4 checksum result * * \return 0 if successful, or POLARSSL_ERR_MD4_FILE_IO_ERROR */ int md4_file( const char *path, unsigned char output[16] ); /** * \brief MD4 HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key */ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen ); /** * \brief MD4 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD4 HMAC final digest * * \param ctx HMAC context * \param output MD4 HMAC checksum result */ void md4_hmac_finish( md4_context *ctx, unsigned char output[16] ); /** * \brief MD4 HMAC context reset * * \param ctx HMAC context to be reset */ void md4_hmac_reset( md4_context *ctx ); /** * \brief Output = HMAC-MD4( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-MD4 result */ void md4_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int md4_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* md4.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/havege.h0000644000014601777760000000340012165464055024522 0ustar00jenkinsnogroup00000000000000/** * \file havege.h * * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_HAVEGE_H #define POLARSSL_HAVEGE_H #include #define COLLECT_SIZE 1024 /** * \brief HAVEGE state structure */ typedef struct { int PT1, PT2, offset[2]; int pool[COLLECT_SIZE]; int WALK[8192]; } havege_state; #ifdef __cplusplus extern "C" { #endif /** * \brief HAVEGE initialization * * \param hs HAVEGE state to be initialized */ void havege_init( havege_state *hs ); /** * \brief HAVEGE rand function * * \param p_rng A HAVEGE state * \param output Buffer to fill * \param len Length of buffer * * \return A random int */ int havege_random( void *p_rng, unsigned char *output, size_t len ); #ifdef __cplusplus } #endif #endif /* havege.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/sha2.h0000644000014601777760000001121012165464055024116 0ustar00jenkinsnogroup00000000000000/** * \file sha2.h * * \brief SHA-224 and SHA-256 cryptographic hash function * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_SHA2_H #define POLARSSL_SHA2_H #include #define POLARSSL_ERR_SHA2_FILE_IO_ERROR -0x0078 /**< Read/write error in file. */ /** * \brief SHA-256 context structure */ typedef struct { unsigned long total[2]; /*!< number of bytes processed */ unsigned long state[8]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ unsigned char ipad[64]; /*!< HMAC: inner padding */ unsigned char opad[64]; /*!< HMAC: outer padding */ int is224; /*!< 0 => SHA-256, else SHA-224 */ } sha2_context; #ifdef __cplusplus extern "C" { #endif /** * \brief SHA-256 context setup * * \param ctx context to be initialized * \param is224 0 = use SHA256, 1 = use SHA224 */ void sha2_starts( sha2_context *ctx, int is224 ); /** * \brief SHA-256 process buffer * * \param ctx SHA-256 context * \param input buffer holding the data * \param ilen length of the input data */ void sha2_update( sha2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-256 final digest * * \param ctx SHA-256 context * \param output SHA-224/256 checksum result */ void sha2_finish( sha2_context *ctx, unsigned char output[32] ); /** * \brief Output = SHA-256( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output SHA-224/256 checksum result * \param is224 0 = use SHA256, 1 = use SHA224 */ void sha2( const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ); /** * \brief Output = SHA-256( file contents ) * * \param path input file name * \param output SHA-224/256 checksum result * \param is224 0 = use SHA256, 1 = use SHA224 * * \return 0 if successful, or POLARSSL_ERR_SHA2_FILE_IO_ERROR */ int sha2_file( const char *path, unsigned char output[32], int is224 ); /** * \brief SHA-256 HMAC context setup * * \param ctx HMAC context to be initialized * \param key HMAC secret key * \param keylen length of the HMAC key * \param is224 0 = use SHA256, 1 = use SHA224 */ void sha2_hmac_starts( sha2_context *ctx, const unsigned char *key, size_t keylen, int is224 ); /** * \brief SHA-256 HMAC process buffer * * \param ctx HMAC context * \param input buffer holding the data * \param ilen length of the input data */ void sha2_hmac_update( sha2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief SHA-256 HMAC final digest * * \param ctx HMAC context * \param output SHA-224/256 HMAC checksum result */ void sha2_hmac_finish( sha2_context *ctx, unsigned char output[32] ); /** * \brief SHA-256 HMAC context reset * * \param ctx HMAC context to be reset */ void sha2_hmac_reset( sha2_context *ctx ); /** * \brief Output = HMAC-SHA-256( hmac key, input buffer ) * * \param key HMAC secret key * \param keylen length of the HMAC key * \param input buffer holding the data * \param ilen length of the input data * \param output HMAC-SHA-224/256 result * \param is224 0 = use SHA256, 1 = use SHA224 */ void sha2_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int sha2_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* sha2.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/camellia.h0000644000014601777760000001407612165464055025045 0ustar00jenkinsnogroup00000000000000/** * \file camellia.h * * \brief Camellia block cipher * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_CAMELLIA_H #define POLARSSL_CAMELLIA_H #include #ifdef _MSC_VER #include typedef UINT32 uint32_t; #else #include #endif #define CAMELLIA_ENCRYPT 1 #define CAMELLIA_DECRYPT 0 #define POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024 /**< Invalid key length. */ #define POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */ /** * \brief CAMELLIA context structure */ typedef struct { int nr; /*!< number of rounds */ uint32_t rk[68]; /*!< CAMELLIA round keys */ } camellia_context; #ifdef __cplusplus extern "C" { #endif /** * \brief CAMELLIA key schedule (encryption) * * \param ctx CAMELLIA context to be initialized * \param key encryption key * \param keysize must be 128, 192 or 256 * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH */ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize ); /** * \brief CAMELLIA key schedule (decryption) * * \param ctx CAMELLIA context to be initialized * \param key decryption key * \param keysize must be 128, 192 or 256 * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH */ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize ); /** * \brief CAMELLIA-ECB block encryption/decryption * * \param ctx CAMELLIA context * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT * \param input 16-byte input block * \param output 16-byte output block * * \return 0 if successful */ int camellia_crypt_ecb( camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ); /** * \brief CAMELLIA-CBC buffer encryption/decryption * Length should be a multiple of the block * size (16 bytes) * * \param ctx CAMELLIA context * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ int camellia_crypt_cbc( camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ); /** * \brief CAMELLIA-CFB128 buffer encryption/decryption * * Note: Due to the nature of CFB you should use the same key schedule for * both encryption and decryption. So a context initialized with * camellia_setkey_enc() for both CAMELLIA_ENCRYPT and CAMELLIE_DECRYPT. * * \param ctx CAMELLIA context * \param mode CAMELLIA_ENCRYPT or CAMELLIA_DECRYPT * \param length length of the input data * \param iv_off offset in IV (updated after use) * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ int camellia_crypt_cfb128( camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ); /* * \brief CAMELLIA-CTR buffer encryption/decryption * * Warning: You have to keep the maximum use of your counter in mind! * * Note: Due to the nature of CTR you should use the same key schedule for * both encryption and decryption. So a context initialized with * camellia_setkey_enc() for both CAMELLIA_ENCRYPT and CAMELLIA_DECRYPT. * * \param length The length of the data * \param nc_off The offset in the current stream_block (for resuming * within current cipher stream). The offset pointer to * should be 0 at the start of a stream. * \param nonce_counter The 128-bit nonce and counter. * \param stream_block The saved stream-block for resuming. Is overwritten * by the function. * \param input The input data stream * \param output The output data stream * * \return 0 if successful */ int camellia_crypt_ctr( camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int camellia_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* camellia.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/asn1.h0000644000014601777760000001723412165464055024137 0ustar00jenkinsnogroup00000000000000/** * \file asn1.h * * \brief Generic ASN.1 parsing * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_ASN1_H #define POLARSSL_ASN1_H #include "config.h" #if defined(POLARSSL_BIGNUM_C) #include "bignum.h" #endif #include /** * \addtogroup asn1_module * \{ */ /** * \name ASN1 Error codes * These error codes are OR'ed to X509 error codes for * higher error granularity. * ASN1 is a standard to specify data structures. * \{ */ #define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014 /**< Out of data when parsing an ASN1 data structure. */ #define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016 /**< ASN1 tag was of an unexpected value. */ #define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018 /**< Error when trying to determine the length or invalid length. */ #define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A /**< Actual length differs from expected length. */ #define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C /**< Data is invalid. (not used) */ #define POLARSSL_ERR_ASN1_MALLOC_FAILED -0x001E /**< Memory allocation failed */ /* \} name */ /** * \name DER constants * These constants comply with DER encoded the ANS1 type tags. * DER encoding uses hexadecimal representation. * An example DER sequence is:\n * - 0x02 -- tag indicating INTEGER * - 0x01 -- length in octets * - 0x05 -- value * Such sequences are typically read into \c ::x509_buf. * \{ */ #define ASN1_BOOLEAN 0x01 #define ASN1_INTEGER 0x02 #define ASN1_BIT_STRING 0x03 #define ASN1_OCTET_STRING 0x04 #define ASN1_NULL 0x05 #define ASN1_OID 0x06 #define ASN1_UTF8_STRING 0x0C #define ASN1_SEQUENCE 0x10 #define ASN1_SET 0x11 #define ASN1_PRINTABLE_STRING 0x13 #define ASN1_T61_STRING 0x14 #define ASN1_IA5_STRING 0x16 #define ASN1_UTC_TIME 0x17 #define ASN1_GENERALIZED_TIME 0x18 #define ASN1_UNIVERSAL_STRING 0x1C #define ASN1_BMP_STRING 0x1E #define ASN1_PRIMITIVE 0x00 #define ASN1_CONSTRUCTED 0x20 #define ASN1_CONTEXT_SPECIFIC 0x80 /* \} name */ /* \} addtogroup asn1_module */ /** Returns the size of the binary string, without the trailing \\0 */ #define OID_SIZE(x) (sizeof(x) - 1) #ifdef __cplusplus extern "C" { #endif /** * \name Functions to parse ASN.1 data structures * \{ */ /** * Type-length-value structure that allows for ASN1 using DER. */ typedef struct _asn1_buf { int tag; /**< ASN1 type, e.g. ASN1_UTF8_STRING. */ size_t len; /**< ASN1 length, e.g. in octets. */ unsigned char *p; /**< ASN1 data, e.g. in ASCII. */ } asn1_buf; /** * Container for ASN1 bit strings. */ typedef struct _asn1_bitstring { size_t len; /**< ASN1 length, e.g. in octets. */ unsigned char unused_bits; /**< Number of unused bits at the end of the string */ unsigned char *p; /**< Raw ASN1 data for the bit string */ } asn1_bitstring; /** * Container for a sequence of ASN.1 items */ typedef struct _asn1_sequence { asn1_buf buf; /**< Buffer containing the given ASN.1 item. */ struct _asn1_sequence *next; /**< The next entry in the sequence. */ } asn1_sequence; /** * Get the length of an ASN.1 element. * Updates the pointer to immediately behind the length. * * \param p The position in the ASN.1 data * \param end End of data * \param len The variable that will receive the value * * \return 0 if successful, POLARSSL_ERR_ASN1_OUT_OF_DATA on reaching * end of data, POLARSSL_ERR_ASN1_INVALID_LENGTH if length is * unparseable. */ int asn1_get_len( unsigned char **p, const unsigned char *end, size_t *len ); /** * Get the tag and length of the tag. Check for the requested tag. * Updates the pointer to immediately behind the tag and length. * * \param p The position in the ASN.1 data * \param end End of data * \param len The variable that will receive the length * \param tag The expected tag * * \return 0 if successful, POLARSSL_ERR_ASN1_UNEXPECTED_TAG if tag did * not match requested tag, or another specific ASN.1 error code. */ int asn1_get_tag( unsigned char **p, const unsigned char *end, size_t *len, int tag ); /** * Retrieve a boolean ASN.1 tag and its value. * Updates the pointer to immediately behind the full tag. * * \param p The position in the ASN.1 data * \param end End of data * \param val The variable that will receive the value * * \return 0 if successful or a specific ASN.1 error code. */ int asn1_get_bool( unsigned char **p, const unsigned char *end, int *val ); /** * Retrieve an integer ASN.1 tag and its value. * Updates the pointer to immediately behind the full tag. * * \param p The position in the ASN.1 data * \param end End of data * \param val The variable that will receive the value * * \return 0 if successful or a specific ASN.1 error code. */ int asn1_get_int( unsigned char **p, const unsigned char *end, int *val ); /** * Retrieve a bitstring ASN.1 tag and its value. * Updates the pointer to immediately behind the full tag. * * \param p The position in the ASN.1 data * \param end End of data * \param bs The variable that will receive the value * * \return 0 if successful or a specific ASN.1 error code. */ int asn1_get_bitstring( unsigned char **p, const unsigned char *end, asn1_bitstring *bs); /** * Parses and splits an ASN.1 "SEQUENCE OF " * Updated the pointer to immediately behind the full sequence tag. * * \param p The position in the ASN.1 data * \param end End of data * \param cur First variable in the chain to fill * \param tag Type of sequence * * \return 0 if successful or a specific ASN.1 error code. */ int asn1_get_sequence_of( unsigned char **p, const unsigned char *end, asn1_sequence *cur, int tag); #if defined(POLARSSL_BIGNUM_C) /** * Retrieve a MPI value from an integer ASN.1 tag. * Updates the pointer to immediately behind the full tag. * * \param p The position in the ASN.1 data * \param end End of data * \param X The MPI that will receive the value * * \return 0 if successful or a specific ASN.1 or MPI error code. */ int asn1_get_mpi( unsigned char **p, const unsigned char *end, mpi *X ); #endif #ifdef __cplusplus } #endif #endif /* asn1.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/version.h0000644000014601777760000000460112165464055024754 0ustar00jenkinsnogroup00000000000000/** * \file version.h * * \brief Run-time version information * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * This set of compile-time defines and run-time variables can be used to * determine the version number of the PolarSSL library used. */ #ifndef POLARSSL_VERSION_H #define POLARSSL_VERSION_H #include "config.h" /** * The version number x.y.z is split into three parts. * Major, Minor, Patchlevel */ #define POLARSSL_VERSION_MAJOR 1 #define POLARSSL_VERSION_MINOR 1 #define POLARSSL_VERSION_PATCH 2 /** * The single version number has the following structure: * MMNNPP00 * Major version | Minor version | Patch version */ #define POLARSSL_VERSION_NUMBER 0x01010200 #define POLARSSL_VERSION_STRING "1.1.2" #define POLARSSL_VERSION_STRING_FULL "PolarSSL 1.1.2" #if defined(POLARSSL_VERSION_C) /** * Get the version number. * * \return The constructed version number in the format * MMNNPP00 (Major, Minor, Patch). */ unsigned int version_get_number( void ); /** * Get the version string ("x.y.z"). * * \param string The string that will receive the value. * (Should be at least 9 bytes in size) */ void version_get_string( char *string ); /** * Get the full version string ("PolarSSL x.y.z"). * * \param string The string that will receive the value. * (Should be at least 18 bytes in size) */ void version_get_string_full( char *string ); #endif /* POLARSSL_VERSION_C */ #endif /* version.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/base64.h0000644000014601777760000000560112165464055024354 0ustar00jenkinsnogroup00000000000000/** * \file base64.h * * \brief RFC 1521 base64 encoding/decoding * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_BASE64_H #define POLARSSL_BASE64_H #include #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */ #ifdef __cplusplus extern "C" { #endif /** * \brief Encode a buffer into base64 format * * \param dst destination buffer * \param dlen size of the buffer * \param src source buffer * \param slen amount of data to be encoded * * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL. * *dlen is always updated to reflect the amount * of data that has (or would have) been written. * * \note Call this function with *dlen = 0 to obtain the * required buffer size in *dlen */ int base64_encode( unsigned char *dst, size_t *dlen, const unsigned char *src, size_t slen ); /** * \brief Decode a base64-formatted buffer * * \param dst destination buffer * \param dlen size of the buffer * \param src source buffer * \param slen amount of data to be decoded * * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not * correct. *dlen is always updated to reflect the amount * of data that has (or would have) been written. * * \note Call this function with *dlen = 0 to obtain the * required buffer size in *dlen */ int base64_decode( unsigned char *dst, size_t *dlen, const unsigned char *src, size_t slen ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int base64_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* base64.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/include/polarssl/net.h0000644000014601777760000001323612165464055024061 0ustar00jenkinsnogroup00000000000000/** * \file net.h * * \brief Network communication functions * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef POLARSSL_NET_H #define POLARSSL_NET_H #include #define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0040 /**< Failed to get an IP address for the given hostname. */ #define POLARSSL_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */ #define POLARSSL_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */ #define POLARSSL_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */ #define POLARSSL_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */ #define POLARSSL_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */ #define POLARSSL_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */ #define POLARSSL_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */ #define POLARSSL_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */ #define POLARSSL_ERR_NET_WANT_READ -0x0052 /**< Connection requires a read call. */ #define POLARSSL_ERR_NET_WANT_WRITE -0x0054 /**< Connection requires a write call. */ #define POLARSSL_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ #ifdef __cplusplus extern "C" { #endif /** * \brief Initiate a TCP connection with host:port * * \param fd Socket to use * \param host Host to connect to * \param port Port to connect to * * \return 0 if successful, or one of: * POLARSSL_ERR_NET_SOCKET_FAILED, * POLARSSL_ERR_NET_UNKNOWN_HOST, * POLARSSL_ERR_NET_CONNECT_FAILED */ int net_connect( int *fd, const char *host, int port ); /** * \brief Create a listening socket on bind_ip:port. * If bind_ip == NULL, all interfaces are binded. * * \param fd Socket to use * \param bind_ip IP to bind to, can be NULL * \param port Port number to use * * \return 0 if successful, or one of: * POLARSSL_ERR_NET_SOCKET_FAILED, * POLARSSL_ERR_NET_BIND_FAILED, * POLARSSL_ERR_NET_LISTEN_FAILED */ int net_bind( int *fd, const char *bind_ip, int port ); /** * \brief Accept a connection from a remote client * * \param bind_fd Relevant socket * \param client_fd Will contain the connected client socket * \param client_ip Will contain the client IP address * * \return 0 if successful, POLARSSL_ERR_NET_ACCEPT_FAILED, or * POLARSSL_ERR_NET_WOULD_BLOCK is bind_fd was set to * non-blocking and accept() is blocking. */ int net_accept( int bind_fd, int *client_fd, void *client_ip ); /** * \brief Set the socket blocking * * \param fd Socket to set * * \return 0 if successful, or a non-zero error code */ int net_set_block( int fd ); /** * \brief Set the socket non-blocking * * \param fd Socket to set * * \return 0 if successful, or a non-zero error code */ int net_set_nonblock( int fd ); /** * \brief Portable usleep helper * * \param usec Amount of microseconds to sleep * * \note Real amount of time slept will not be less than * select()'s timeout granularity (typically, 10ms). */ void net_usleep( unsigned long usec ); /** * \brief Read at most 'len' characters. If no error occurs, * the actual amount read is returned. * * \param ctx Socket * \param buf The buffer to write to * \param len Maximum length of the buffer * * \return This function returns the number of bytes received, * or a non-zero error code; POLARSSL_ERR_NET_WANT_READ * indicates read() is blocking. */ int net_recv( void *ctx, unsigned char *buf, size_t len ); /** * \brief Write at most 'len' characters. If no error occurs, * the actual amount read is returned. * * \param ctx Socket * \param buf The buffer to read from * \param len The length of the buffer * * \return This function returns the number of bytes sent, * or a non-zero error code; POLARSSL_ERR_NET_WANT_WRITE * indicates write() is blocking. */ int net_send( void *ctx, const unsigned char *buf, size_t len ); /** * \brief Gracefully shutdown the connection * * \param fd The socket to close */ void net_close( int fd ); #ifdef __cplusplus } #endif #endif /* net.h */ pdns-3.3/pdns/ext/polarssl-1.1.2/Makefile0000644000014601777760000000066512165464055021302 0ustar00jenkinsnogroup00000000000000 DESTDIR=/usr/local PREFIX=polarssl_ .SILENT: all: cd library && $(MAKE) all && cd .. install: uninstall: distclean: clean clean: cd library && $(MAKE) clean && cd .. check: distdir: mkdir -p $(distdir) cp ChangeLog LICENSE Makefile README $(distdir) mkdir $(distdir)/library mkdir -p $(distdir)/include/polarssl cp library/Makefile library/*.c $(distdir)/library cp include/polarssl/*.h $(distdir)/include/polarssl pdns-3.3/pdns/ext/polarssl-1.1.2/library/0000755000014601777760000000000012165464055021277 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/ext/polarssl-1.1.2/library/pem.c0000644000014601777760000002366012165464055022233 0ustar00jenkinsnogroup00000000000000/* * Privacy Enhanced Mail (PEM) decoding * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_PEM_C) #include "polarssl/pem.h" #include "polarssl/base64.h" #include "polarssl/des.h" #include "polarssl/aes.h" #include "polarssl/md5.h" #include "polarssl/cipher.h" #include void pem_init( pem_context *ctx ) { memset( ctx, 0, sizeof( pem_context ) ); } #if defined(POLARSSL_MD5_C) && (defined(POLARSSL_DES_C) || defined(POLARSSL_AES_C)) /* * Read a 16-byte hex string and convert it to binary */ static int pem_get_iv( const unsigned char *s, unsigned char *iv, size_t iv_len ) { size_t i, j, k; memset( iv, 0, iv_len ); for( i = 0; i < iv_len * 2; i++, s++ ) { if( *s >= '0' && *s <= '9' ) j = *s - '0'; else if( *s >= 'A' && *s <= 'F' ) j = *s - '7'; else if( *s >= 'a' && *s <= 'f' ) j = *s - 'W'; else return( POLARSSL_ERR_PEM_INVALID_ENC_IV ); k = ( ( i & 1 ) != 0 ) ? j : j << 4; iv[i >> 1] = (unsigned char)( iv[i >> 1] | k ); } return( 0 ); } static void pem_pbkdf1( unsigned char *key, size_t keylen, unsigned char *iv, const unsigned char *pwd, size_t pwdlen ) { md5_context md5_ctx; unsigned char md5sum[16]; size_t use_len; /* * key[ 0..15] = MD5(pwd || IV) */ md5_starts( &md5_ctx ); md5_update( &md5_ctx, pwd, pwdlen ); md5_update( &md5_ctx, iv, 8 ); md5_finish( &md5_ctx, md5sum ); if( keylen <= 16 ) { memcpy( key, md5sum, keylen ); memset( &md5_ctx, 0, sizeof( md5_ctx ) ); memset( md5sum, 0, 16 ); return; } memcpy( key, md5sum, 16 ); /* * key[16..23] = MD5(key[ 0..15] || pwd || IV]) */ md5_starts( &md5_ctx ); md5_update( &md5_ctx, md5sum, 16 ); md5_update( &md5_ctx, pwd, pwdlen ); md5_update( &md5_ctx, iv, 8 ); md5_finish( &md5_ctx, md5sum ); use_len = 16; if( keylen < 32 ) use_len = keylen - 16; memcpy( key + 16, md5sum, use_len ); memset( &md5_ctx, 0, sizeof( md5_ctx ) ); memset( md5sum, 0, 16 ); } #if defined(POLARSSL_DES_C) /* * Decrypt with DES-CBC, using PBKDF1 for key derivation */ static void pem_des_decrypt( unsigned char des_iv[8], unsigned char *buf, size_t buflen, const unsigned char *pwd, size_t pwdlen ) { des_context des_ctx; unsigned char des_key[8]; pem_pbkdf1( des_key, 8, des_iv, pwd, pwdlen ); des_setkey_dec( &des_ctx, des_key ); des_crypt_cbc( &des_ctx, DES_DECRYPT, buflen, des_iv, buf, buf ); memset( &des_ctx, 0, sizeof( des_ctx ) ); memset( des_key, 0, 8 ); } /* * Decrypt with 3DES-CBC, using PBKDF1 for key derivation */ static void pem_des3_decrypt( unsigned char des3_iv[8], unsigned char *buf, size_t buflen, const unsigned char *pwd, size_t pwdlen ) { des3_context des3_ctx; unsigned char des3_key[24]; pem_pbkdf1( des3_key, 24, des3_iv, pwd, pwdlen ); des3_set3key_dec( &des3_ctx, des3_key ); des3_crypt_cbc( &des3_ctx, DES_DECRYPT, buflen, des3_iv, buf, buf ); memset( &des3_ctx, 0, sizeof( des3_ctx ) ); memset( des3_key, 0, 24 ); } #endif /* POLARSSL_DES_C */ #if defined(POLARSSL_AES_C) /* * Decrypt with AES-XXX-CBC, using PBKDF1 for key derivation */ static void pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen, unsigned char *buf, size_t buflen, const unsigned char *pwd, size_t pwdlen ) { aes_context aes_ctx; unsigned char aes_key[32]; pem_pbkdf1( aes_key, keylen, aes_iv, pwd, pwdlen ); aes_setkey_dec( &aes_ctx, aes_key, keylen * 8 ); aes_crypt_cbc( &aes_ctx, AES_DECRYPT, buflen, aes_iv, buf, buf ); memset( &aes_ctx, 0, sizeof( aes_ctx ) ); memset( aes_key, 0, keylen ); } #endif /* POLARSSL_AES_C */ #endif /* POLARSSL_MD5_C && (POLARSSL_AES_C || POLARSSL_DES_C) */ int pem_read_buffer( pem_context *ctx, char *header, char *footer, const unsigned char *data, const unsigned char *pwd, size_t pwdlen, size_t *use_len ) { int ret, enc; size_t len; unsigned char *buf; unsigned char *s1, *s2; #if defined(POLARSSL_MD5_C) && (defined(POLARSSL_DES_C) || defined(POLARSSL_AES_C)) unsigned char pem_iv[16]; cipher_type_t enc_alg = POLARSSL_CIPHER_NONE; #else ((void) pwd); ((void) pwdlen); #endif /* POLARSSL_MD5_C && (POLARSSL_AES_C || POLARSSL_DES_C) */ if( ctx == NULL ) return( POLARSSL_ERR_PEM_INVALID_DATA ); s1 = (unsigned char *) strstr( (char *) data, header ); if( s1 == NULL ) return( POLARSSL_ERR_PEM_NO_HEADER_PRESENT ); s2 = (unsigned char *) strstr( (char *) data, footer ); if( s2 == NULL || s2 <= s1 ) return( POLARSSL_ERR_PEM_INVALID_DATA ); s1 += strlen( header ); if( *s1 == '\r' ) s1++; if( *s1 == '\n' ) s1++; else return( POLARSSL_ERR_PEM_INVALID_DATA ); enc = 0; if( memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 ) { #if defined(POLARSSL_MD5_C) && (defined(POLARSSL_DES_C) || defined(POLARSSL_AES_C)) enc++; s1 += 22; if( *s1 == '\r' ) s1++; if( *s1 == '\n' ) s1++; else return( POLARSSL_ERR_PEM_INVALID_DATA ); #if defined(POLARSSL_DES_C) if( memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 ) { enc_alg = POLARSSL_CIPHER_DES_EDE3_CBC; s1 += 23; if( pem_get_iv( s1, pem_iv, 8 ) != 0 ) return( POLARSSL_ERR_PEM_INVALID_ENC_IV ); s1 += 16; } else if( memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 ) { enc_alg = POLARSSL_CIPHER_DES_CBC; s1 += 18; if( pem_get_iv( s1, pem_iv, 8) != 0 ) return( POLARSSL_ERR_PEM_INVALID_ENC_IV ); s1 += 16; } #endif /* POLARSSL_DES_C */ #if defined(POLARSSL_AES_C) if( memcmp( s1, "DEK-Info: AES-", 14 ) == 0 ) { if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 ) enc_alg = POLARSSL_CIPHER_AES_128_CBC; else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 ) enc_alg = POLARSSL_CIPHER_AES_192_CBC; else if( memcmp( s1, "DEK-Info: AES-256-CBC,", 22 ) == 0 ) enc_alg = POLARSSL_CIPHER_AES_256_CBC; else return( POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG ); s1 += 22; if( pem_get_iv( s1, pem_iv, 16 ) != 0 ) return( POLARSSL_ERR_PEM_INVALID_ENC_IV ); s1 += 32; } #endif /* POLARSSL_AES_C */ if( enc_alg == POLARSSL_CIPHER_NONE ) return( POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG ); if( *s1 == '\r' ) s1++; if( *s1 == '\n' ) s1++; else return( POLARSSL_ERR_PEM_INVALID_DATA ); #else return( POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE ); #endif /* POLARSSL_MD5_C && (POLARSSL_AES_C || POLARSSL_DES_C) */ } len = 0; ret = base64_decode( NULL, &len, s1, s2 - s1 ); if( ret == POLARSSL_ERR_BASE64_INVALID_CHARACTER ) return( POLARSSL_ERR_PEM_INVALID_DATA + ret ); if( ( buf = (unsigned char *) malloc( len ) ) == NULL ) return( POLARSSL_ERR_PEM_MALLOC_FAILED ); if( ( ret = base64_decode( buf, &len, s1, s2 - s1 ) ) != 0 ) { free( buf ); return( POLARSSL_ERR_PEM_INVALID_DATA + ret ); } if( enc != 0 ) { #if defined(POLARSSL_MD5_C) && (defined(POLARSSL_DES_C) || defined(POLARSSL_AES_C)) if( pwd == NULL ) { free( buf ); return( POLARSSL_ERR_PEM_PASSWORD_REQUIRED ); } #if defined(POLARSSL_DES_C) if( enc_alg == POLARSSL_CIPHER_DES_EDE3_CBC ) pem_des3_decrypt( pem_iv, buf, len, pwd, pwdlen ); else if( enc_alg == POLARSSL_CIPHER_DES_CBC ) pem_des_decrypt( pem_iv, buf, len, pwd, pwdlen ); #endif /* POLARSSL_DES_C */ #if defined(POLARSSL_AES_C) if( enc_alg == POLARSSL_CIPHER_AES_128_CBC ) pem_aes_decrypt( pem_iv, 16, buf, len, pwd, pwdlen ); else if( enc_alg == POLARSSL_CIPHER_AES_192_CBC ) pem_aes_decrypt( pem_iv, 24, buf, len, pwd, pwdlen ); else if( enc_alg == POLARSSL_CIPHER_AES_256_CBC ) pem_aes_decrypt( pem_iv, 32, buf, len, pwd, pwdlen ); #endif /* POLARSSL_AES_C */ if( buf[0] != 0x30 || buf[1] != 0x82 || buf[4] != 0x02 || buf[5] != 0x01 ) { free( buf ); return( POLARSSL_ERR_PEM_PASSWORD_MISMATCH ); } #else return( POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE ); #endif } ctx->buf = buf; ctx->buflen = len; s2 += strlen( footer ); if( *s2 == '\r' ) s2++; if( *s2 == '\n' ) s2++; *use_len = s2 - data; return( 0 ); } void pem_free( pem_context *ctx ) { if( ctx->buf ) free( ctx->buf ); if( ctx->info ) free( ctx->info ); memset( ctx, 0, sizeof( pem_context ) ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/bignum.c0000644000014601777760000012615412165464055022735 0ustar00jenkinsnogroup00000000000000/* * Multi-precision integer library * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * This MPI implementation is based on: * * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf * http://www.stillhq.com/extracted/gnupg-api/mpi/ * http://math.libtomcrypt.com/files/tommath.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_BIGNUM_C) #include "polarssl/bignum.h" #include "polarssl/bn_mul.h" #include #define ciL (sizeof(t_uint)) /* chars in limb */ #define biL (ciL << 3) /* bits in limb */ #define biH (ciL << 2) /* half limb size */ /* * Convert between bits/chars and number of limbs */ #define BITS_TO_LIMBS(i) (((i) + biL - 1) / biL) #define CHARS_TO_LIMBS(i) (((i) + ciL - 1) / ciL) /* * Initialize one MPI */ void mpi_init( mpi *X ) { if( X == NULL ) return; X->s = 1; X->n = 0; X->p = NULL; } /* * Unallocate one MPI */ void mpi_free( mpi *X ) { if( X == NULL ) return; if( X->p != NULL ) { memset( X->p, 0, X->n * ciL ); free( X->p ); } X->s = 1; X->n = 0; X->p = NULL; } /* * Enlarge to the specified number of limbs */ int mpi_grow( mpi *X, size_t nblimbs ) { t_uint *p; if( nblimbs > POLARSSL_MPI_MAX_LIMBS ) return( POLARSSL_ERR_MPI_MALLOC_FAILED ); if( X->n < nblimbs ) { if( ( p = (t_uint *) malloc( nblimbs * ciL ) ) == NULL ) return( POLARSSL_ERR_MPI_MALLOC_FAILED ); memset( p, 0, nblimbs * ciL ); if( X->p != NULL ) { memcpy( p, X->p, X->n * ciL ); memset( X->p, 0, X->n * ciL ); free( X->p ); } X->n = nblimbs; X->p = p; } return( 0 ); } /* * Copy the contents of Y into X */ int mpi_copy( mpi *X, const mpi *Y ) { int ret; size_t i; if( X == Y ) return( 0 ); for( i = Y->n - 1; i > 0; i-- ) if( Y->p[i] != 0 ) break; i++; X->s = Y->s; MPI_CHK( mpi_grow( X, i ) ); memset( X->p, 0, X->n * ciL ); memcpy( X->p, Y->p, i * ciL ); cleanup: return( ret ); } /* * Swap the contents of X and Y */ void mpi_swap( mpi *X, mpi *Y ) { mpi T; memcpy( &T, X, sizeof( mpi ) ); memcpy( X, Y, sizeof( mpi ) ); memcpy( Y, &T, sizeof( mpi ) ); } /* * Set value from integer */ int mpi_lset( mpi *X, t_sint z ) { int ret; MPI_CHK( mpi_grow( X, 1 ) ); memset( X->p, 0, X->n * ciL ); X->p[0] = ( z < 0 ) ? -z : z; X->s = ( z < 0 ) ? -1 : 1; cleanup: return( ret ); } /* * Get a specific bit */ int mpi_get_bit( mpi *X, size_t pos ) { if( X->n * biL <= pos ) return( 0 ); return ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01; } /* * Set a bit to a specific value of 0 or 1 */ int mpi_set_bit( mpi *X, size_t pos, unsigned char val ) { int ret = 0; size_t off = pos / biL; size_t idx = pos % biL; if( val != 0 && val != 1 ) return POLARSSL_ERR_MPI_BAD_INPUT_DATA; if( X->n * biL <= pos ) { if( val == 0 ) return ( 0 ); MPI_CHK( mpi_grow( X, off + 1 ) ); } X->p[off] = ( X->p[off] & ~( 0x01 << idx ) ) | ( val << idx ); cleanup: return( ret ); } /* * Return the number of least significant bits */ size_t mpi_lsb( const mpi *X ) { size_t i, j, count = 0; for( i = 0; i < X->n; i++ ) for( j = 0; j < biL; j++, count++ ) if( ( ( X->p[i] >> j ) & 1 ) != 0 ) return( count ); return( 0 ); } /* * Return the number of most significant bits */ size_t mpi_msb( const mpi *X ) { size_t i, j; for( i = X->n - 1; i > 0; i-- ) if( X->p[i] != 0 ) break; for( j = biL; j > 0; j-- ) if( ( ( X->p[i] >> ( j - 1 ) ) & 1 ) != 0 ) break; return( ( i * biL ) + j ); } /* * Return the total size in bytes */ size_t mpi_size( const mpi *X ) { return( ( mpi_msb( X ) + 7 ) >> 3 ); } /* * Convert an ASCII character to digit value */ static int mpi_get_digit( t_uint *d, int radix, char c ) { *d = 255; if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30; if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37; if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57; if( *d >= (t_uint) radix ) return( POLARSSL_ERR_MPI_INVALID_CHARACTER ); return( 0 ); } /* * Import from an ASCII string */ int mpi_read_string( mpi *X, int radix, const char *s ) { int ret; size_t i, j, slen, n; t_uint d; mpi T; if( radix < 2 || radix > 16 ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); mpi_init( &T ); slen = strlen( s ); if( radix == 16 ) { n = BITS_TO_LIMBS( slen << 2 ); MPI_CHK( mpi_grow( X, n ) ); MPI_CHK( mpi_lset( X, 0 ) ); for( i = slen, j = 0; i > 0; i--, j++ ) { if( i == 1 && s[i - 1] == '-' ) { X->s = -1; break; } MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) ); X->p[j / (2 * ciL)] |= d << ( (j % (2 * ciL)) << 2 ); } } else { MPI_CHK( mpi_lset( X, 0 ) ); for( i = 0; i < slen; i++ ) { if( i == 0 && s[i] == '-' ) { X->s = -1; continue; } MPI_CHK( mpi_get_digit( &d, radix, s[i] ) ); MPI_CHK( mpi_mul_int( &T, X, radix ) ); if( X->s == 1 ) { MPI_CHK( mpi_add_int( X, &T, d ) ); } else { MPI_CHK( mpi_sub_int( X, &T, d ) ); } } } cleanup: mpi_free( &T ); return( ret ); } /* * Helper to write the digits high-order first */ static int mpi_write_hlp( mpi *X, int radix, char **p ) { int ret; t_uint r; if( radix < 2 || radix > 16 ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); MPI_CHK( mpi_mod_int( &r, X, radix ) ); MPI_CHK( mpi_div_int( X, NULL, X, radix ) ); if( mpi_cmp_int( X, 0 ) != 0 ) MPI_CHK( mpi_write_hlp( X, radix, p ) ); if( r < 10 ) *(*p)++ = (char)( r + 0x30 ); else *(*p)++ = (char)( r + 0x37 ); cleanup: return( ret ); } /* * Export into an ASCII string */ int mpi_write_string( const mpi *X, int radix, char *s, size_t *slen ) { int ret = 0; size_t n; char *p; mpi T; if( radix < 2 || radix > 16 ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); n = mpi_msb( X ); if( radix >= 4 ) n >>= 1; if( radix >= 16 ) n >>= 1; n += 3; if( *slen < n ) { *slen = n; return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL ); } p = s; mpi_init( &T ); if( X->s == -1 ) *p++ = '-'; if( radix == 16 ) { int c; size_t i, j, k; for( i = X->n, k = 0; i > 0; i-- ) { for( j = ciL; j > 0; j-- ) { c = ( X->p[i - 1] >> ( ( j - 1 ) << 3) ) & 0xFF; if( c == 0 && k == 0 && ( i + j + 3 ) != 0 ) continue; p += sprintf( p, "%02X", c ); k = 1; } } } else { MPI_CHK( mpi_copy( &T, X ) ); if( T.s == -1 ) T.s = 1; MPI_CHK( mpi_write_hlp( &T, radix, &p ) ); } *p++ = '\0'; *slen = p - s; cleanup: mpi_free( &T ); return( ret ); } #if defined(POLARSSL_FS_IO) /* * Read X from an opened file */ int mpi_read_file( mpi *X, int radix, FILE *fin ) { t_uint d; size_t slen; char *p; /* * Buffer should have space for (short) label and decimal formatted MPI, * newline characters and '\0' */ char s[ POLARSSL_MPI_READ_BUFFER_SIZE ]; memset( s, 0, sizeof( s ) ); if( fgets( s, sizeof( s ) - 1, fin ) == NULL ) return( POLARSSL_ERR_MPI_FILE_IO_ERROR ); slen = strlen( s ); if( slen == sizeof( s ) - 2 ) return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL ); if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; } if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; } p = s + slen; while( --p >= s ) if( mpi_get_digit( &d, radix, *p ) != 0 ) break; return( mpi_read_string( X, radix, p + 1 ) ); } /* * Write X into an opened file (or stdout if fout == NULL) */ int mpi_write_file( const char *p, const mpi *X, int radix, FILE *fout ) { int ret; size_t n, slen, plen; /* * Buffer should have space for minus sign, hexified MPI and '\0' */ char s[ 2 * POLARSSL_MPI_MAX_SIZE + 2 ]; n = sizeof( s ); memset( s, 0, n ); n -= 2; MPI_CHK( mpi_write_string( X, radix, s, (size_t *) &n ) ); if( p == NULL ) p = ""; plen = strlen( p ); slen = strlen( s ); s[slen++] = '\r'; s[slen++] = '\n'; if( fout != NULL ) { if( fwrite( p, 1, plen, fout ) != plen || fwrite( s, 1, slen, fout ) != slen ) return( POLARSSL_ERR_MPI_FILE_IO_ERROR ); } else printf( "%s%s", p, s ); cleanup: return( ret ); } #endif /* POLARSSL_FS_IO */ /* * Import X from unsigned binary data, big endian */ int mpi_read_binary( mpi *X, const unsigned char *buf, size_t buflen ) { int ret; size_t i, j, n; for( n = 0; n < buflen; n++ ) if( buf[n] != 0 ) break; MPI_CHK( mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) ); MPI_CHK( mpi_lset( X, 0 ) ); for( i = buflen, j = 0; i > n; i--, j++ ) X->p[j / ciL] |= ((t_uint) buf[i - 1]) << ((j % ciL) << 3); cleanup: return( ret ); } /* * Export X into unsigned binary data, big endian */ int mpi_write_binary( const mpi *X, unsigned char *buf, size_t buflen ) { size_t i, j, n; n = mpi_size( X ); if( buflen < n ) return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL ); memset( buf, 0, buflen ); for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- ) buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) ); return( 0 ); } /* * Left-shift: X <<= count */ int mpi_shift_l( mpi *X, size_t count ) { int ret; size_t i, v0, t1; t_uint r0 = 0, r1; v0 = count / (biL ); t1 = count & (biL - 1); i = mpi_msb( X ) + count; if( X->n * biL < i ) MPI_CHK( mpi_grow( X, BITS_TO_LIMBS( i ) ) ); ret = 0; /* * shift by count / limb_size */ if( v0 > 0 ) { for( i = X->n; i > v0; i-- ) X->p[i - 1] = X->p[i - v0 - 1]; for( ; i > 0; i-- ) X->p[i - 1] = 0; } /* * shift by count % limb_size */ if( t1 > 0 ) { for( i = v0; i < X->n; i++ ) { r1 = X->p[i] >> (biL - t1); X->p[i] <<= t1; X->p[i] |= r0; r0 = r1; } } cleanup: return( ret ); } /* * Right-shift: X >>= count */ int mpi_shift_r( mpi *X, size_t count ) { size_t i, v0, v1; t_uint r0 = 0, r1; v0 = count / biL; v1 = count & (biL - 1); /* * shift by count / limb_size */ if( v0 > 0 ) { for( i = 0; i < X->n - v0; i++ ) X->p[i] = X->p[i + v0]; for( ; i < X->n; i++ ) X->p[i] = 0; } /* * shift by count % limb_size */ if( v1 > 0 ) { for( i = X->n; i > 0; i-- ) { r1 = X->p[i - 1] << (biL - v1); X->p[i - 1] >>= v1; X->p[i - 1] |= r0; r0 = r1; } } return( 0 ); } /* * Compare unsigned values */ int mpi_cmp_abs( const mpi *X, const mpi *Y ) { size_t i, j; for( i = X->n; i > 0; i-- ) if( X->p[i - 1] != 0 ) break; for( j = Y->n; j > 0; j-- ) if( Y->p[j - 1] != 0 ) break; if( i == 0 && j == 0 ) return( 0 ); if( i > j ) return( 1 ); if( j > i ) return( -1 ); for( ; i > 0; i-- ) { if( X->p[i - 1] > Y->p[i - 1] ) return( 1 ); if( X->p[i - 1] < Y->p[i - 1] ) return( -1 ); } return( 0 ); } /* * Compare signed values */ int mpi_cmp_mpi( const mpi *X, const mpi *Y ) { size_t i, j; for( i = X->n; i > 0; i-- ) if( X->p[i - 1] != 0 ) break; for( j = Y->n; j > 0; j-- ) if( Y->p[j - 1] != 0 ) break; if( i == 0 && j == 0 ) return( 0 ); if( i > j ) return( X->s ); if( j > i ) return( -Y->s ); if( X->s > 0 && Y->s < 0 ) return( 1 ); if( Y->s > 0 && X->s < 0 ) return( -1 ); for( ; i > 0; i-- ) { if( X->p[i - 1] > Y->p[i - 1] ) return( X->s ); if( X->p[i - 1] < Y->p[i - 1] ) return( -X->s ); } return( 0 ); } /* * Compare signed values */ int mpi_cmp_int( const mpi *X, t_sint z ) { mpi Y; t_uint p[1]; *p = ( z < 0 ) ? -z : z; Y.s = ( z < 0 ) ? -1 : 1; Y.n = 1; Y.p = p; return( mpi_cmp_mpi( X, &Y ) ); } /* * Unsigned addition: X = |A| + |B| (HAC 14.7) */ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B ) { int ret; size_t i, j; t_uint *o, *p, c; if( X == B ) { const mpi *T = A; A = X; B = T; } if( X != A ) MPI_CHK( mpi_copy( X, A ) ); /* * X should always be positive as a result of unsigned additions. */ X->s = 1; for( j = B->n; j > 0; j-- ) if( B->p[j - 1] != 0 ) break; MPI_CHK( mpi_grow( X, j ) ); o = B->p; p = X->p; c = 0; for( i = 0; i < j; i++, o++, p++ ) { *p += c; c = ( *p < c ); *p += *o; c += ( *p < *o ); } while( c != 0 ) { if( i >= X->n ) { MPI_CHK( mpi_grow( X, i + 1 ) ); p = X->p + i; } *p += c; c = ( *p < c ); i++; } cleanup: return( ret ); } /* * Helper for mpi substraction */ static void mpi_sub_hlp( size_t n, t_uint *s, t_uint *d ) { size_t i; t_uint c, z; for( i = c = 0; i < n; i++, s++, d++ ) { z = ( *d < c ); *d -= c; c = ( *d < *s ) + z; *d -= *s; } while( c != 0 ) { z = ( *d < c ); *d -= c; c = z; i++; d++; } } /* * Unsigned substraction: X = |A| - |B| (HAC 14.9) */ int mpi_sub_abs( mpi *X, const mpi *A, const mpi *B ) { mpi TB; int ret; size_t n; if( mpi_cmp_abs( A, B ) < 0 ) return( POLARSSL_ERR_MPI_NEGATIVE_VALUE ); mpi_init( &TB ); if( X == B ) { MPI_CHK( mpi_copy( &TB, B ) ); B = &TB; } if( X != A ) MPI_CHK( mpi_copy( X, A ) ); /* * X should always be positive as a result of unsigned substractions. */ X->s = 1; ret = 0; for( n = B->n; n > 0; n-- ) if( B->p[n - 1] != 0 ) break; mpi_sub_hlp( n, B->p, X->p ); cleanup: mpi_free( &TB ); return( ret ); } /* * Signed addition: X = A + B */ int mpi_add_mpi( mpi *X, const mpi *A, const mpi *B ) { int ret, s = A->s; if( A->s * B->s < 0 ) { if( mpi_cmp_abs( A, B ) >= 0 ) { MPI_CHK( mpi_sub_abs( X, A, B ) ); X->s = s; } else { MPI_CHK( mpi_sub_abs( X, B, A ) ); X->s = -s; } } else { MPI_CHK( mpi_add_abs( X, A, B ) ); X->s = s; } cleanup: return( ret ); } /* * Signed substraction: X = A - B */ int mpi_sub_mpi( mpi *X, const mpi *A, const mpi *B ) { int ret, s = A->s; if( A->s * B->s > 0 ) { if( mpi_cmp_abs( A, B ) >= 0 ) { MPI_CHK( mpi_sub_abs( X, A, B ) ); X->s = s; } else { MPI_CHK( mpi_sub_abs( X, B, A ) ); X->s = -s; } } else { MPI_CHK( mpi_add_abs( X, A, B ) ); X->s = s; } cleanup: return( ret ); } /* * Signed addition: X = A + b */ int mpi_add_int( mpi *X, const mpi *A, t_sint b ) { mpi _B; t_uint p[1]; p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; _B.n = 1; _B.p = p; return( mpi_add_mpi( X, A, &_B ) ); } /* * Signed substraction: X = A - b */ int mpi_sub_int( mpi *X, const mpi *A, t_sint b ) { mpi _B; t_uint p[1]; p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; _B.n = 1; _B.p = p; return( mpi_sub_mpi( X, A, &_B ) ); } /* * Helper for mpi multiplication */ static void mpi_mul_hlp( size_t i, t_uint *s, t_uint *d, t_uint b ) { t_uint c = 0, t = 0; #if defined(MULADDC_HUIT) for( ; i >= 8; i -= 8 ) { MULADDC_INIT MULADDC_HUIT MULADDC_STOP } for( ; i > 0; i-- ) { MULADDC_INIT MULADDC_CORE MULADDC_STOP } #else for( ; i >= 16; i -= 16 ) { MULADDC_INIT MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_STOP } for( ; i >= 8; i -= 8 ) { MULADDC_INIT MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_CORE MULADDC_STOP } for( ; i > 0; i-- ) { MULADDC_INIT MULADDC_CORE MULADDC_STOP } #endif t++; do { *d += c; c = ( *d < c ); d++; } while( c != 0 ); } /* * Baseline multiplication: X = A * B (HAC 14.12) */ int mpi_mul_mpi( mpi *X, const mpi *A, const mpi *B ) { int ret; size_t i, j; mpi TA, TB; mpi_init( &TA ); mpi_init( &TB ); if( X == A ) { MPI_CHK( mpi_copy( &TA, A ) ); A = &TA; } if( X == B ) { MPI_CHK( mpi_copy( &TB, B ) ); B = &TB; } for( i = A->n; i > 0; i-- ) if( A->p[i - 1] != 0 ) break; for( j = B->n; j > 0; j-- ) if( B->p[j - 1] != 0 ) break; MPI_CHK( mpi_grow( X, i + j ) ); MPI_CHK( mpi_lset( X, 0 ) ); for( i++; j > 0; j-- ) mpi_mul_hlp( i - 1, A->p, X->p + j - 1, B->p[j - 1] ); X->s = A->s * B->s; cleanup: mpi_free( &TB ); mpi_free( &TA ); return( ret ); } /* * Baseline multiplication: X = A * b */ int mpi_mul_int( mpi *X, const mpi *A, t_sint b ) { mpi _B; t_uint p[1]; _B.s = 1; _B.n = 1; _B.p = p; p[0] = b; return( mpi_mul_mpi( X, A, &_B ) ); } /* * Division by mpi: A = Q * B + R (HAC 14.20) */ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B ) { int ret; size_t i, n, t, k; mpi X, Y, Z, T1, T2; if( mpi_cmp_int( B, 0 ) == 0 ) return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO ); mpi_init( &X ); mpi_init( &Y ); mpi_init( &Z ); mpi_init( &T1 ); mpi_init( &T2 ); if( mpi_cmp_abs( A, B ) < 0 ) { if( Q != NULL ) MPI_CHK( mpi_lset( Q, 0 ) ); if( R != NULL ) MPI_CHK( mpi_copy( R, A ) ); return( 0 ); } MPI_CHK( mpi_copy( &X, A ) ); MPI_CHK( mpi_copy( &Y, B ) ); X.s = Y.s = 1; MPI_CHK( mpi_grow( &Z, A->n + 2 ) ); MPI_CHK( mpi_lset( &Z, 0 ) ); MPI_CHK( mpi_grow( &T1, 2 ) ); MPI_CHK( mpi_grow( &T2, 3 ) ); k = mpi_msb( &Y ) % biL; if( k < biL - 1 ) { k = biL - 1 - k; MPI_CHK( mpi_shift_l( &X, k ) ); MPI_CHK( mpi_shift_l( &Y, k ) ); } else k = 0; n = X.n - 1; t = Y.n - 1; mpi_shift_l( &Y, biL * (n - t) ); while( mpi_cmp_mpi( &X, &Y ) >= 0 ) { Z.p[n - t]++; mpi_sub_mpi( &X, &X, &Y ); } mpi_shift_r( &Y, biL * (n - t) ); for( i = n; i > t ; i-- ) { if( X.p[i] >= Y.p[t] ) Z.p[i - t - 1] = ~0; else { #if defined(POLARSSL_HAVE_LONGLONG) t_udbl r; r = (t_udbl) X.p[i] << biL; r |= (t_udbl) X.p[i - 1]; r /= Y.p[t]; if( r > ((t_udbl) 1 << biL) - 1) r = ((t_udbl) 1 << biL) - 1; Z.p[i - t - 1] = (t_uint) r; #else /* * __udiv_qrnnd_c, from gmp/longlong.h */ t_uint q0, q1, r0, r1; t_uint d0, d1, d, m; d = Y.p[t]; d0 = ( d << biH ) >> biH; d1 = ( d >> biH ); q1 = X.p[i] / d1; r1 = X.p[i] - d1 * q1; r1 <<= biH; r1 |= ( X.p[i - 1] >> biH ); m = q1 * d0; if( r1 < m ) { q1--, r1 += d; while( r1 >= d && r1 < m ) q1--, r1 += d; } r1 -= m; q0 = r1 / d1; r0 = r1 - d1 * q0; r0 <<= biH; r0 |= ( X.p[i - 1] << biH ) >> biH; m = q0 * d0; if( r0 < m ) { q0--, r0 += d; while( r0 >= d && r0 < m ) q0--, r0 += d; } r0 -= m; Z.p[i - t - 1] = ( q1 << biH ) | q0; #endif } Z.p[i - t - 1]++; do { Z.p[i - t - 1]--; MPI_CHK( mpi_lset( &T1, 0 ) ); T1.p[0] = (t < 1) ? 0 : Y.p[t - 1]; T1.p[1] = Y.p[t]; MPI_CHK( mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) ); MPI_CHK( mpi_lset( &T2, 0 ) ); T2.p[0] = (i < 2) ? 0 : X.p[i - 2]; T2.p[1] = (i < 1) ? 0 : X.p[i - 1]; T2.p[2] = X.p[i]; } while( mpi_cmp_mpi( &T1, &T2 ) > 0 ); MPI_CHK( mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) ); MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) ); MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) ); if( mpi_cmp_int( &X, 0 ) < 0 ) { MPI_CHK( mpi_copy( &T1, &Y ) ); MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) ); MPI_CHK( mpi_add_mpi( &X, &X, &T1 ) ); Z.p[i - t - 1]--; } } if( Q != NULL ) { mpi_copy( Q, &Z ); Q->s = A->s * B->s; } if( R != NULL ) { mpi_shift_r( &X, k ); mpi_copy( R, &X ); R->s = A->s; if( mpi_cmp_int( R, 0 ) == 0 ) R->s = 1; } cleanup: mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z ); mpi_free( &T1 ); mpi_free( &T2 ); return( ret ); } /* * Division by int: A = Q * b + R * * Returns 0 if successful * 1 if memory allocation failed * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0 */ int mpi_div_int( mpi *Q, mpi *R, const mpi *A, t_sint b ) { mpi _B; t_uint p[1]; p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; _B.n = 1; _B.p = p; return( mpi_div_mpi( Q, R, A, &_B ) ); } /* * Modulo: R = A mod B */ int mpi_mod_mpi( mpi *R, const mpi *A, const mpi *B ) { int ret; if( mpi_cmp_int( B, 0 ) < 0 ) return POLARSSL_ERR_MPI_NEGATIVE_VALUE; MPI_CHK( mpi_div_mpi( NULL, R, A, B ) ); while( mpi_cmp_int( R, 0 ) < 0 ) MPI_CHK( mpi_add_mpi( R, R, B ) ); while( mpi_cmp_mpi( R, B ) >= 0 ) MPI_CHK( mpi_sub_mpi( R, R, B ) ); cleanup: return( ret ); } /* * Modulo: r = A mod b */ int mpi_mod_int( t_uint *r, const mpi *A, t_sint b ) { size_t i; t_uint x, y, z; if( b == 0 ) return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO ); if( b < 0 ) return POLARSSL_ERR_MPI_NEGATIVE_VALUE; /* * handle trivial cases */ if( b == 1 ) { *r = 0; return( 0 ); } if( b == 2 ) { *r = A->p[0] & 1; return( 0 ); } /* * general case */ for( i = A->n, y = 0; i > 0; i-- ) { x = A->p[i - 1]; y = ( y << biH ) | ( x >> biH ); z = y / b; y -= z * b; x <<= biH; y = ( y << biH ) | ( x >> biH ); z = y / b; y -= z * b; } /* * If A is negative, then the current y represents a negative value. * Flipping it to the positive side. */ if( A->s < 0 && y != 0 ) y = b - y; *r = y; return( 0 ); } /* * Fast Montgomery initialization (thanks to Tom St Denis) */ static void mpi_montg_init( t_uint *mm, const mpi *N ) { t_uint x, m0 = N->p[0]; x = m0; x += ( ( m0 + 2 ) & 4 ) << 1; x *= ( 2 - ( m0 * x ) ); if( biL >= 16 ) x *= ( 2 - ( m0 * x ) ); if( biL >= 32 ) x *= ( 2 - ( m0 * x ) ); if( biL >= 64 ) x *= ( 2 - ( m0 * x ) ); *mm = ~x + 1; } /* * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36) */ static void mpi_montmul( mpi *A, const mpi *B, const mpi *N, t_uint mm, const mpi *T ) { size_t i, n, m; t_uint u0, u1, *d; memset( T->p, 0, T->n * ciL ); d = T->p; n = N->n; m = ( B->n < n ) ? B->n : n; for( i = 0; i < n; i++ ) { /* * T = (T + u0*B + u1*N) / 2^biL */ u0 = A->p[i]; u1 = ( d[0] + u0 * B->p[0] ) * mm; mpi_mul_hlp( m, B->p, d, u0 ); mpi_mul_hlp( n, N->p, d, u1 ); *d++ = u0; d[n + 1] = 0; } memcpy( A->p, d, (n + 1) * ciL ); if( mpi_cmp_abs( A, N ) >= 0 ) mpi_sub_hlp( n, N->p, A->p ); else /* prevent timing attacks */ mpi_sub_hlp( n, A->p, T->p ); } /* * Montgomery reduction: A = A * R^-1 mod N */ static void mpi_montred( mpi *A, const mpi *N, t_uint mm, const mpi *T ) { t_uint z = 1; mpi U; U.n = U.s = z; U.p = &z; mpi_montmul( A, &U, N, mm, T ); } /* * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) */ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR ) { int ret; size_t wbits, wsize, one = 1; size_t i, j, nblimbs; size_t bufsize, nbits; t_uint ei, mm, state; mpi RR, T, W[ 2 << POLARSSL_MPI_WINDOW_SIZE ]; if( mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); /* * Init temps and window size */ mpi_montg_init( &mm, N ); mpi_init( &RR ); mpi_init( &T ); memset( W, 0, sizeof( W ) ); i = mpi_msb( E ); wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 : ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1; if( wsize > POLARSSL_MPI_WINDOW_SIZE ) wsize = POLARSSL_MPI_WINDOW_SIZE; j = N->n + 1; MPI_CHK( mpi_grow( X, j ) ); MPI_CHK( mpi_grow( &W[1], j ) ); MPI_CHK( mpi_grow( &T, j * 2 ) ); /* * If 1st call, pre-compute R^2 mod N */ if( _RR == NULL || _RR->p == NULL ) { MPI_CHK( mpi_lset( &RR, 1 ) ); MPI_CHK( mpi_shift_l( &RR, N->n * 2 * biL ) ); MPI_CHK( mpi_mod_mpi( &RR, &RR, N ) ); if( _RR != NULL ) memcpy( _RR, &RR, sizeof( mpi ) ); } else memcpy( &RR, _RR, sizeof( mpi ) ); /* * W[1] = A * R^2 * R^-1 mod N = A * R mod N */ if( mpi_cmp_mpi( A, N ) >= 0 ) mpi_mod_mpi( &W[1], A, N ); else mpi_copy( &W[1], A ); mpi_montmul( &W[1], &RR, N, mm, &T ); /* * X = R^2 * R^-1 mod N = R mod N */ MPI_CHK( mpi_copy( X, &RR ) ); mpi_montred( X, N, mm, &T ); if( wsize > 1 ) { /* * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1) */ j = one << (wsize - 1); MPI_CHK( mpi_grow( &W[j], N->n + 1 ) ); MPI_CHK( mpi_copy( &W[j], &W[1] ) ); for( i = 0; i < wsize - 1; i++ ) mpi_montmul( &W[j], &W[j], N, mm, &T ); /* * W[i] = W[i - 1] * W[1] */ for( i = j + 1; i < (one << wsize); i++ ) { MPI_CHK( mpi_grow( &W[i], N->n + 1 ) ); MPI_CHK( mpi_copy( &W[i], &W[i - 1] ) ); mpi_montmul( &W[i], &W[1], N, mm, &T ); } } nblimbs = E->n; bufsize = 0; nbits = 0; wbits = 0; state = 0; while( 1 ) { if( bufsize == 0 ) { if( nblimbs-- == 0 ) break; bufsize = sizeof( t_uint ) << 3; } bufsize--; ei = (E->p[nblimbs] >> bufsize) & 1; /* * skip leading 0s */ if( ei == 0 && state == 0 ) continue; if( ei == 0 && state == 1 ) { /* * out of window, square X */ mpi_montmul( X, X, N, mm, &T ); continue; } /* * add ei to current window */ state = 2; nbits++; wbits |= (ei << (wsize - nbits)); if( nbits == wsize ) { /* * X = X^wsize R^-1 mod N */ for( i = 0; i < wsize; i++ ) mpi_montmul( X, X, N, mm, &T ); /* * X = X * W[wbits] R^-1 mod N */ mpi_montmul( X, &W[wbits], N, mm, &T ); state--; nbits = 0; wbits = 0; } } /* * process the remaining bits */ for( i = 0; i < nbits; i++ ) { mpi_montmul( X, X, N, mm, &T ); wbits <<= 1; if( (wbits & (one << wsize)) != 0 ) mpi_montmul( X, &W[1], N, mm, &T ); } /* * X = A^E * R * R^-1 mod N = A^E mod N */ mpi_montred( X, N, mm, &T ); cleanup: for( i = (one << (wsize - 1)); i < (one << wsize); i++ ) mpi_free( &W[i] ); mpi_free( &W[1] ); mpi_free( &T ); if( _RR == NULL ) mpi_free( &RR ); return( ret ); } /* * Greatest common divisor: G = gcd(A, B) (HAC 14.54) */ int mpi_gcd( mpi *G, const mpi *A, const mpi *B ) { int ret; size_t lz, lzt; mpi TG, TA, TB; mpi_init( &TG ); mpi_init( &TA ); mpi_init( &TB ); MPI_CHK( mpi_copy( &TA, A ) ); MPI_CHK( mpi_copy( &TB, B ) ); lz = mpi_lsb( &TA ); lzt = mpi_lsb( &TB ); if ( lzt < lz ) lz = lzt; MPI_CHK( mpi_shift_r( &TA, lz ) ); MPI_CHK( mpi_shift_r( &TB, lz ) ); TA.s = TB.s = 1; while( mpi_cmp_int( &TA, 0 ) != 0 ) { MPI_CHK( mpi_shift_r( &TA, mpi_lsb( &TA ) ) ); MPI_CHK( mpi_shift_r( &TB, mpi_lsb( &TB ) ) ); if( mpi_cmp_mpi( &TA, &TB ) >= 0 ) { MPI_CHK( mpi_sub_abs( &TA, &TA, &TB ) ); MPI_CHK( mpi_shift_r( &TA, 1 ) ); } else { MPI_CHK( mpi_sub_abs( &TB, &TB, &TA ) ); MPI_CHK( mpi_shift_r( &TB, 1 ) ); } } MPI_CHK( mpi_shift_l( &TB, lz ) ); MPI_CHK( mpi_copy( G, &TB ) ); cleanup: mpi_free( &TG ); mpi_free( &TA ); mpi_free( &TB ); return( ret ); } int mpi_fill_random( mpi *X, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret; MPI_CHK( mpi_grow( X, CHARS_TO_LIMBS( size ) ) ); MPI_CHK( mpi_lset( X, 0 ) ); MPI_CHK( f_rng( p_rng, (unsigned char *) X->p, size ) ); cleanup: return( ret ); } #if defined(POLARSSL_GENPRIME) /* * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64) */ int mpi_inv_mod( mpi *X, const mpi *A, const mpi *N ) { int ret; mpi G, TA, TU, U1, U2, TB, TV, V1, V2; if( mpi_cmp_int( N, 0 ) <= 0 ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); mpi_init( &TA ); mpi_init( &TU ); mpi_init( &U1 ); mpi_init( &U2 ); mpi_init( &G ); mpi_init( &TB ); mpi_init( &TV ); mpi_init( &V1 ); mpi_init( &V2 ); MPI_CHK( mpi_gcd( &G, A, N ) ); if( mpi_cmp_int( &G, 1 ) != 0 ) { ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE; goto cleanup; } MPI_CHK( mpi_mod_mpi( &TA, A, N ) ); MPI_CHK( mpi_copy( &TU, &TA ) ); MPI_CHK( mpi_copy( &TB, N ) ); MPI_CHK( mpi_copy( &TV, N ) ); MPI_CHK( mpi_lset( &U1, 1 ) ); MPI_CHK( mpi_lset( &U2, 0 ) ); MPI_CHK( mpi_lset( &V1, 0 ) ); MPI_CHK( mpi_lset( &V2, 1 ) ); do { while( ( TU.p[0] & 1 ) == 0 ) { MPI_CHK( mpi_shift_r( &TU, 1 ) ); if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 ) { MPI_CHK( mpi_add_mpi( &U1, &U1, &TB ) ); MPI_CHK( mpi_sub_mpi( &U2, &U2, &TA ) ); } MPI_CHK( mpi_shift_r( &U1, 1 ) ); MPI_CHK( mpi_shift_r( &U2, 1 ) ); } while( ( TV.p[0] & 1 ) == 0 ) { MPI_CHK( mpi_shift_r( &TV, 1 ) ); if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 ) { MPI_CHK( mpi_add_mpi( &V1, &V1, &TB ) ); MPI_CHK( mpi_sub_mpi( &V2, &V2, &TA ) ); } MPI_CHK( mpi_shift_r( &V1, 1 ) ); MPI_CHK( mpi_shift_r( &V2, 1 ) ); } if( mpi_cmp_mpi( &TU, &TV ) >= 0 ) { MPI_CHK( mpi_sub_mpi( &TU, &TU, &TV ) ); MPI_CHK( mpi_sub_mpi( &U1, &U1, &V1 ) ); MPI_CHK( mpi_sub_mpi( &U2, &U2, &V2 ) ); } else { MPI_CHK( mpi_sub_mpi( &TV, &TV, &TU ) ); MPI_CHK( mpi_sub_mpi( &V1, &V1, &U1 ) ); MPI_CHK( mpi_sub_mpi( &V2, &V2, &U2 ) ); } } while( mpi_cmp_int( &TU, 0 ) != 0 ); while( mpi_cmp_int( &V1, 0 ) < 0 ) MPI_CHK( mpi_add_mpi( &V1, &V1, N ) ); while( mpi_cmp_mpi( &V1, N ) >= 0 ) MPI_CHK( mpi_sub_mpi( &V1, &V1, N ) ); MPI_CHK( mpi_copy( X, &V1 ) ); cleanup: mpi_free( &TA ); mpi_free( &TU ); mpi_free( &U1 ); mpi_free( &U2 ); mpi_free( &G ); mpi_free( &TB ); mpi_free( &TV ); mpi_free( &V1 ); mpi_free( &V2 ); return( ret ); } static const int small_prime[] = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, -103 }; /* * Miller-Rabin primality test (HAC 4.24) */ int mpi_is_prime( mpi *X, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret, xs; size_t i, j, n, s; mpi W, R, T, A, RR; if( mpi_cmp_int( X, 0 ) == 0 || mpi_cmp_int( X, 1 ) == 0 ) return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE ); if( mpi_cmp_int( X, 2 ) == 0 ) return( 0 ); mpi_init( &W ); mpi_init( &R ); mpi_init( &T ); mpi_init( &A ); mpi_init( &RR ); xs = X->s; X->s = 1; /* * test trivial factors first */ if( ( X->p[0] & 1 ) == 0 ) return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE ); for( i = 0; small_prime[i] > 0; i++ ) { t_uint r; if( mpi_cmp_int( X, small_prime[i] ) <= 0 ) return( 0 ); MPI_CHK( mpi_mod_int( &r, X, small_prime[i] ) ); if( r == 0 ) return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE ); } /* * W = |X| - 1 * R = W >> lsb( W ) */ MPI_CHK( mpi_sub_int( &W, X, 1 ) ); s = mpi_lsb( &W ); MPI_CHK( mpi_copy( &R, &W ) ); MPI_CHK( mpi_shift_r( &R, s ) ); i = mpi_msb( X ); /* * HAC, table 4.4 */ n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 : ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 : ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 ); for( i = 0; i < n; i++ ) { /* * pick a random A, 1 < A < |X| - 1 */ MPI_CHK( mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) ); if( mpi_cmp_mpi( &A, &W ) >= 0 ) { j = mpi_msb( &A ) - mpi_msb( &W ); MPI_CHK( mpi_shift_r( &A, j + 1 ) ); } A.p[0] |= 3; /* * A = A^R mod |X| */ MPI_CHK( mpi_exp_mod( &A, &A, &R, X, &RR ) ); if( mpi_cmp_mpi( &A, &W ) == 0 || mpi_cmp_int( &A, 1 ) == 0 ) continue; j = 1; while( j < s && mpi_cmp_mpi( &A, &W ) != 0 ) { /* * A = A * A mod |X| */ MPI_CHK( mpi_mul_mpi( &T, &A, &A ) ); MPI_CHK( mpi_mod_mpi( &A, &T, X ) ); if( mpi_cmp_int( &A, 1 ) == 0 ) break; j++; } /* * not prime if A != |X| - 1 or A == 1 */ if( mpi_cmp_mpi( &A, &W ) != 0 || mpi_cmp_int( &A, 1 ) == 0 ) { ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE; break; } } cleanup: X->s = xs; mpi_free( &W ); mpi_free( &R ); mpi_free( &T ); mpi_free( &A ); mpi_free( &RR ); return( ret ); } /* * Prime number generation */ int mpi_gen_prime( mpi *X, size_t nbits, int dh_flag, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret; size_t k, n; mpi Y; if( nbits < 3 || nbits > POLARSSL_MPI_MAX_BITS ) return( POLARSSL_ERR_MPI_BAD_INPUT_DATA ); mpi_init( &Y ); n = BITS_TO_LIMBS( nbits ); MPI_CHK( mpi_fill_random( X, n * ciL, f_rng, p_rng ) ); k = mpi_msb( X ); if( k < nbits ) MPI_CHK( mpi_shift_l( X, nbits - k ) ); if( k > nbits ) MPI_CHK( mpi_shift_r( X, k - nbits ) ); X->p[0] |= 3; if( dh_flag == 0 ) { while( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) != 0 ) { if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE ) goto cleanup; MPI_CHK( mpi_add_int( X, X, 2 ) ); } } else { MPI_CHK( mpi_sub_int( &Y, X, 1 ) ); MPI_CHK( mpi_shift_r( &Y, 1 ) ); while( 1 ) { if( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) == 0 ) { if( ( ret = mpi_is_prime( &Y, f_rng, p_rng ) ) == 0 ) break; if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE ) goto cleanup; } if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE ) goto cleanup; MPI_CHK( mpi_add_int( &Y, X, 1 ) ); MPI_CHK( mpi_add_int( X, X, 2 ) ); MPI_CHK( mpi_shift_r( &Y, 1 ) ); } } cleanup: mpi_free( &Y ); return( ret ); } #endif #if defined(POLARSSL_SELF_TEST) #define GCD_PAIR_COUNT 3 static const int gcd_pairs[GCD_PAIR_COUNT][3] = { { 693, 609, 21 }, { 1764, 868, 28 }, { 768454923, 542167814, 1 } }; /* * Checkup routine */ int mpi_self_test( int verbose ) { int ret, i; mpi A, E, N, X, Y, U, V; mpi_init( &A ); mpi_init( &E ); mpi_init( &N ); mpi_init( &X ); mpi_init( &Y ); mpi_init( &U ); mpi_init( &V ); MPI_CHK( mpi_read_string( &A, 16, "EFE021C2645FD1DC586E69184AF4A31E" \ "D5F53E93B5F123FA41680867BA110131" \ "944FE7952E2517337780CB0DB80E61AA" \ "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) ); MPI_CHK( mpi_read_string( &E, 16, "B2E7EFD37075B9F03FF989C7C5051C20" \ "34D2A323810251127E7BF8625A4F49A5" \ "F3E27F4DA8BD59C47D6DAABA4C8127BD" \ "5B5C25763222FEFCCFC38B832366C29E" ) ); MPI_CHK( mpi_read_string( &N, 16, "0066A198186C18C10B2F5ED9B522752A" \ "9830B69916E535C8F047518A889A43A5" \ "94B6BED27A168D31D4A52F88925AA8F5" ) ); MPI_CHK( mpi_mul_mpi( &X, &A, &N ) ); MPI_CHK( mpi_read_string( &U, 16, "602AB7ECA597A3D6B56FF9829A5E8B85" \ "9E857EA95A03512E2BAE7391688D264A" \ "A5663B0341DB9CCFD2C4C5F421FEC814" \ "8001B72E848A38CAE1C65F78E56ABDEF" \ "E12D3C039B8A02D6BE593F0BBBDA56F1" \ "ECF677152EF804370C1A305CAF3B5BF1" \ "30879B56C61DE584A0F53A2447A51E" ) ); if( verbose != 0 ) printf( " MPI test #1 (mul_mpi): " ); if( mpi_cmp_mpi( &X, &U ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); MPI_CHK( mpi_div_mpi( &X, &Y, &A, &N ) ); MPI_CHK( mpi_read_string( &U, 16, "256567336059E52CAE22925474705F39A94" ) ); MPI_CHK( mpi_read_string( &V, 16, "6613F26162223DF488E9CD48CC132C7A" \ "0AC93C701B001B092E4E5B9F73BCD27B" \ "9EE50D0657C77F374E903CDFA4C642" ) ); if( verbose != 0 ) printf( " MPI test #2 (div_mpi): " ); if( mpi_cmp_mpi( &X, &U ) != 0 || mpi_cmp_mpi( &Y, &V ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); MPI_CHK( mpi_exp_mod( &X, &A, &E, &N, NULL ) ); MPI_CHK( mpi_read_string( &U, 16, "36E139AEA55215609D2816998ED020BB" \ "BD96C37890F65171D948E9BC7CBAA4D9" \ "325D24D6A3C12710F10A09FA08AB87" ) ); if( verbose != 0 ) printf( " MPI test #3 (exp_mod): " ); if( mpi_cmp_mpi( &X, &U ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); #if defined(POLARSSL_GENPRIME) MPI_CHK( mpi_inv_mod( &X, &A, &N ) ); MPI_CHK( mpi_read_string( &U, 16, "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \ "C3DBA76456363A10869622EAC2DD84EC" \ "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) ); if( verbose != 0 ) printf( " MPI test #4 (inv_mod): " ); if( mpi_cmp_mpi( &X, &U ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); #endif if( verbose != 0 ) printf( " MPI test #5 (simple gcd): " ); for ( i = 0; i < GCD_PAIR_COUNT; i++) { MPI_CHK( mpi_lset( &X, gcd_pairs[i][0] ) ); MPI_CHK( mpi_lset( &Y, gcd_pairs[i][1] ) ); MPI_CHK( mpi_gcd( &A, &X, &Y ) ); if( mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 ) { if( verbose != 0 ) printf( "failed at %d\n", i ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); cleanup: if( ret != 0 && verbose != 0 ) printf( "Unexpected error, return code = %08X\n", ret ); mpi_free( &A ); mpi_free( &E ); mpi_free( &N ); mpi_free( &X ); mpi_free( &Y ); mpi_free( &U ); mpi_free( &V ); if( verbose != 0 ) printf( "\n" ); return( ret ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/ssl_tls.c0000644000014601777760000017540712165464055023144 0ustar00jenkinsnogroup00000000000000/* * SSLv3/TLSv1 shared functions * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The SSL 3.0 specification was drafted by Netscape in 1996, * and became an IETF standard in 1999. * * http://wp.netscape.com/eng/ssl3/ * http://www.ietf.org/rfc/rfc2246.txt * http://www.ietf.org/rfc/rfc4346.txt */ #include "polarssl/config.h" #if defined(POLARSSL_SSL_TLS_C) #include "polarssl/aes.h" #include "polarssl/arc4.h" #include "polarssl/camellia.h" #include "polarssl/des.h" #include "polarssl/debug.h" #include "polarssl/ssl.h" #include #include #if defined _MSC_VER && !defined strcasecmp #define strcasecmp _stricmp #endif /* * Key material generation */ static int tls1_prf( unsigned char *secret, size_t slen, char *label, unsigned char *random, size_t rlen, unsigned char *dstbuf, size_t dlen ) { size_t nb, hs; size_t i, j, k; unsigned char *S1, *S2; unsigned char tmp[128]; unsigned char h_i[20]; if( sizeof( tmp ) < 20 + strlen( label ) + rlen ) return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); hs = ( slen + 1 ) / 2; S1 = secret; S2 = secret + slen - hs; nb = strlen( label ); memcpy( tmp + 20, label, nb ); memcpy( tmp + 20 + nb, random, rlen ); nb += rlen; /* * First compute P_md5(secret,label+random)[0..dlen] */ md5_hmac( S1, hs, tmp + 20, nb, 4 + tmp ); for( i = 0; i < dlen; i += 16 ) { md5_hmac( S1, hs, 4 + tmp, 16 + nb, h_i ); md5_hmac( S1, hs, 4 + tmp, 16, 4 + tmp ); k = ( i + 16 > dlen ) ? dlen % 16 : 16; for( j = 0; j < k; j++ ) dstbuf[i + j] = h_i[j]; } /* * XOR out with P_sha1(secret,label+random)[0..dlen] */ sha1_hmac( S2, hs, tmp + 20, nb, tmp ); for( i = 0; i < dlen; i += 20 ) { sha1_hmac( S2, hs, tmp, 20 + nb, h_i ); sha1_hmac( S2, hs, tmp, 20, tmp ); k = ( i + 20 > dlen ) ? dlen % 20 : 20; for( j = 0; j < k; j++ ) dstbuf[i + j] = (unsigned char)( dstbuf[i + j] ^ h_i[j] ); } memset( tmp, 0, sizeof( tmp ) ); memset( h_i, 0, sizeof( h_i ) ); return( 0 ); } int ssl_derive_keys( ssl_context *ssl ) { int i; md5_context md5; sha1_context sha1; unsigned char tmp[64]; unsigned char padding[16]; unsigned char sha1sum[20]; unsigned char keyblk[256]; unsigned char *key1; unsigned char *key2; SSL_DEBUG_MSG( 2, ( "=> derive keys" ) ); /* * SSLv3: * master = * MD5( premaster + SHA1( 'A' + premaster + randbytes ) ) + * MD5( premaster + SHA1( 'BB' + premaster + randbytes ) ) + * MD5( premaster + SHA1( 'CCC' + premaster + randbytes ) ) * * TLSv1: * master = PRF( premaster, "master secret", randbytes )[0..47] */ if( ssl->resume == 0 ) { size_t len = ssl->pmslen; SSL_DEBUG_BUF( 3, "premaster secret", ssl->premaster, len ); if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { for( i = 0; i < 3; i++ ) { memset( padding, 'A' + i, 1 + i ); sha1_starts( &sha1 ); sha1_update( &sha1, padding, 1 + i ); sha1_update( &sha1, ssl->premaster, len ); sha1_update( &sha1, ssl->randbytes, 64 ); sha1_finish( &sha1, sha1sum ); md5_starts( &md5 ); md5_update( &md5, ssl->premaster, len ); md5_update( &md5, sha1sum, 20 ); md5_finish( &md5, ssl->session->master + i * 16 ); } } else tls1_prf( ssl->premaster, len, "master secret", ssl->randbytes, 64, ssl->session->master, 48 ); memset( ssl->premaster, 0, sizeof( ssl->premaster ) ); } else SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) ); /* * Swap the client and server random values. */ memcpy( tmp, ssl->randbytes, 64 ); memcpy( ssl->randbytes, tmp + 32, 32 ); memcpy( ssl->randbytes + 32, tmp, 32 ); memset( tmp, 0, sizeof( tmp ) ); /* * SSLv3: * key block = * MD5( master + SHA1( 'A' + master + randbytes ) ) + * MD5( master + SHA1( 'BB' + master + randbytes ) ) + * MD5( master + SHA1( 'CCC' + master + randbytes ) ) + * MD5( master + SHA1( 'DDDD' + master + randbytes ) ) + * ... * * TLSv1: * key block = PRF( master, "key expansion", randbytes ) */ if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { for( i = 0; i < 16; i++ ) { memset( padding, 'A' + i, 1 + i ); sha1_starts( &sha1 ); sha1_update( &sha1, padding, 1 + i ); sha1_update( &sha1, ssl->session->master, 48 ); sha1_update( &sha1, ssl->randbytes, 64 ); sha1_finish( &sha1, sha1sum ); md5_starts( &md5 ); md5_update( &md5, ssl->session->master, 48 ); md5_update( &md5, sha1sum, 20 ); md5_finish( &md5, keyblk + i * 16 ); } memset( &md5, 0, sizeof( md5 ) ); memset( &sha1, 0, sizeof( sha1 ) ); memset( padding, 0, sizeof( padding ) ); memset( sha1sum, 0, sizeof( sha1sum ) ); } else tls1_prf( ssl->session->master, 48, "key expansion", ssl->randbytes, 64, keyblk, 256 ); SSL_DEBUG_MSG( 3, ( "ciphersuite = %s", ssl_get_ciphersuite( ssl ) ) ); SSL_DEBUG_BUF( 3, "master secret", ssl->session->master, 48 ); SSL_DEBUG_BUF( 4, "random bytes", ssl->randbytes, 64 ); SSL_DEBUG_BUF( 4, "key block", keyblk, 256 ); memset( ssl->randbytes, 0, sizeof( ssl->randbytes ) ); /* * Determine the appropriate key, IV and MAC length. */ switch( ssl->session->ciphersuite ) { #if defined(POLARSSL_ARC4_C) case SSL_RSA_RC4_128_MD5: ssl->keylen = 16; ssl->minlen = 16; ssl->ivlen = 0; ssl->maclen = 16; break; case SSL_RSA_RC4_128_SHA: ssl->keylen = 16; ssl->minlen = 20; ssl->ivlen = 0; ssl->maclen = 20; break; #endif #if defined(POLARSSL_DES_C) case SSL_RSA_DES_168_SHA: case SSL_EDH_RSA_DES_168_SHA: ssl->keylen = 24; ssl->minlen = 24; ssl->ivlen = 8; ssl->maclen = 20; break; #endif #if defined(POLARSSL_AES_C) case SSL_RSA_AES_128_SHA: case SSL_EDH_RSA_AES_128_SHA: ssl->keylen = 16; ssl->minlen = 32; ssl->ivlen = 16; ssl->maclen = 20; break; case SSL_RSA_AES_256_SHA: case SSL_EDH_RSA_AES_256_SHA: ssl->keylen = 32; ssl->minlen = 32; ssl->ivlen = 16; ssl->maclen = 20; break; #endif #if defined(POLARSSL_CAMELLIA_C) case SSL_RSA_CAMELLIA_128_SHA: case SSL_EDH_RSA_CAMELLIA_128_SHA: ssl->keylen = 16; ssl->minlen = 32; ssl->ivlen = 16; ssl->maclen = 20; break; case SSL_RSA_CAMELLIA_256_SHA: case SSL_EDH_RSA_CAMELLIA_256_SHA: ssl->keylen = 32; ssl->minlen = 32; ssl->ivlen = 16; ssl->maclen = 20; break; #endif default: SSL_DEBUG_MSG( 1, ( "ciphersuite %s is not available", ssl_get_ciphersuite( ssl ) ) ); return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); } SSL_DEBUG_MSG( 3, ( "keylen: %d, minlen: %d, ivlen: %d, maclen: %d", ssl->keylen, ssl->minlen, ssl->ivlen, ssl->maclen ) ); /* * Finally setup the cipher contexts, IVs and MAC secrets. */ if( ssl->endpoint == SSL_IS_CLIENT ) { key1 = keyblk + ssl->maclen * 2; key2 = keyblk + ssl->maclen * 2 + ssl->keylen; memcpy( ssl->mac_enc, keyblk, ssl->maclen ); memcpy( ssl->mac_dec, keyblk + ssl->maclen, ssl->maclen ); /* * This is not used in TLS v1.1. */ memcpy( ssl->iv_enc, key2 + ssl->keylen, ssl->ivlen ); memcpy( ssl->iv_dec, key2 + ssl->keylen + ssl->ivlen, ssl->ivlen ); } else { key1 = keyblk + ssl->maclen * 2 + ssl->keylen; key2 = keyblk + ssl->maclen * 2; memcpy( ssl->mac_dec, keyblk, ssl->maclen ); memcpy( ssl->mac_enc, keyblk + ssl->maclen, ssl->maclen ); /* * This is not used in TLS v1.1. */ memcpy( ssl->iv_dec, key1 + ssl->keylen, ssl->ivlen ); memcpy( ssl->iv_enc, key1 + ssl->keylen + ssl->ivlen, ssl->ivlen ); } switch( ssl->session->ciphersuite ) { #if defined(POLARSSL_ARC4_C) case SSL_RSA_RC4_128_MD5: case SSL_RSA_RC4_128_SHA: arc4_setup( (arc4_context *) ssl->ctx_enc, key1, ssl->keylen ); arc4_setup( (arc4_context *) ssl->ctx_dec, key2, ssl->keylen ); break; #endif #if defined(POLARSSL_DES_C) case SSL_RSA_DES_168_SHA: case SSL_EDH_RSA_DES_168_SHA: des3_set3key_enc( (des3_context *) ssl->ctx_enc, key1 ); des3_set3key_dec( (des3_context *) ssl->ctx_dec, key2 ); break; #endif #if defined(POLARSSL_AES_C) case SSL_RSA_AES_128_SHA: case SSL_EDH_RSA_AES_128_SHA: aes_setkey_enc( (aes_context *) ssl->ctx_enc, key1, 128 ); aes_setkey_dec( (aes_context *) ssl->ctx_dec, key2, 128 ); break; case SSL_RSA_AES_256_SHA: case SSL_EDH_RSA_AES_256_SHA: aes_setkey_enc( (aes_context *) ssl->ctx_enc, key1, 256 ); aes_setkey_dec( (aes_context *) ssl->ctx_dec, key2, 256 ); break; #endif #if defined(POLARSSL_CAMELLIA_C) case SSL_RSA_CAMELLIA_128_SHA: case SSL_EDH_RSA_CAMELLIA_128_SHA: camellia_setkey_enc( (camellia_context *) ssl->ctx_enc, key1, 128 ); camellia_setkey_dec( (camellia_context *) ssl->ctx_dec, key2, 128 ); break; case SSL_RSA_CAMELLIA_256_SHA: case SSL_EDH_RSA_CAMELLIA_256_SHA: camellia_setkey_enc( (camellia_context *) ssl->ctx_enc, key1, 256 ); camellia_setkey_dec( (camellia_context *) ssl->ctx_dec, key2, 256 ); break; #endif default: return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); } memset( keyblk, 0, sizeof( keyblk ) ); SSL_DEBUG_MSG( 2, ( "<= derive keys" ) ); return( 0 ); } void ssl_calc_verify( ssl_context *ssl, unsigned char hash[36] ) { md5_context md5; sha1_context sha1; unsigned char pad_1[48]; unsigned char pad_2[48]; SSL_DEBUG_MSG( 2, ( "=> calc verify" ) ); memcpy( &md5 , &ssl->fin_md5 , sizeof( md5_context ) ); memcpy( &sha1, &ssl->fin_sha1, sizeof( sha1_context ) ); if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { memset( pad_1, 0x36, 48 ); memset( pad_2, 0x5C, 48 ); md5_update( &md5, ssl->session->master, 48 ); md5_update( &md5, pad_1, 48 ); md5_finish( &md5, hash ); md5_starts( &md5 ); md5_update( &md5, ssl->session->master, 48 ); md5_update( &md5, pad_2, 48 ); md5_update( &md5, hash, 16 ); md5_finish( &md5, hash ); sha1_update( &sha1, ssl->session->master, 48 ); sha1_update( &sha1, pad_1, 40 ); sha1_finish( &sha1, hash + 16 ); sha1_starts( &sha1 ); sha1_update( &sha1, ssl->session->master, 48 ); sha1_update( &sha1, pad_2, 40 ); sha1_update( &sha1, hash + 16, 20 ); sha1_finish( &sha1, hash + 16 ); } else /* TLSv1 */ { md5_finish( &md5, hash ); sha1_finish( &sha1, hash + 16 ); } SSL_DEBUG_BUF( 3, "calculated verify result", hash, 36 ); SSL_DEBUG_MSG( 2, ( "<= calc verify" ) ); return; } /* * SSLv3.0 MAC functions */ static void ssl_mac_md5( unsigned char *secret, unsigned char *buf, size_t len, unsigned char *ctr, int type ) { unsigned char header[11]; unsigned char padding[48]; md5_context md5; memcpy( header, ctr, 8 ); header[ 8] = (unsigned char) type; header[ 9] = (unsigned char)( len >> 8 ); header[10] = (unsigned char)( len ); memset( padding, 0x36, 48 ); md5_starts( &md5 ); md5_update( &md5, secret, 16 ); md5_update( &md5, padding, 48 ); md5_update( &md5, header, 11 ); md5_update( &md5, buf, len ); md5_finish( &md5, buf + len ); memset( padding, 0x5C, 48 ); md5_starts( &md5 ); md5_update( &md5, secret, 16 ); md5_update( &md5, padding, 48 ); md5_update( &md5, buf + len, 16 ); md5_finish( &md5, buf + len ); } static void ssl_mac_sha1( unsigned char *secret, unsigned char *buf, size_t len, unsigned char *ctr, int type ) { unsigned char header[11]; unsigned char padding[40]; sha1_context sha1; memcpy( header, ctr, 8 ); header[ 8] = (unsigned char) type; header[ 9] = (unsigned char)( len >> 8 ); header[10] = (unsigned char)( len ); memset( padding, 0x36, 40 ); sha1_starts( &sha1 ); sha1_update( &sha1, secret, 20 ); sha1_update( &sha1, padding, 40 ); sha1_update( &sha1, header, 11 ); sha1_update( &sha1, buf, len ); sha1_finish( &sha1, buf + len ); memset( padding, 0x5C, 40 ); sha1_starts( &sha1 ); sha1_update( &sha1, secret, 20 ); sha1_update( &sha1, padding, 40 ); sha1_update( &sha1, buf + len, 20 ); sha1_finish( &sha1, buf + len ); } /* * Encryption/decryption functions */ static int ssl_encrypt_buf( ssl_context *ssl ) { size_t i, padlen; SSL_DEBUG_MSG( 2, ( "=> encrypt buf" ) ); /* * Add MAC then encrypt */ if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { if( ssl->maclen == 16 ) ssl_mac_md5( ssl->mac_enc, ssl->out_msg, ssl->out_msglen, ssl->out_ctr, ssl->out_msgtype ); if( ssl->maclen == 20 ) ssl_mac_sha1( ssl->mac_enc, ssl->out_msg, ssl->out_msglen, ssl->out_ctr, ssl->out_msgtype ); } else { if( ssl->maclen == 16 ) md5_hmac( ssl->mac_enc, 16, ssl->out_ctr, ssl->out_msglen + 13, ssl->out_msg + ssl->out_msglen ); if( ssl->maclen == 20 ) sha1_hmac( ssl->mac_enc, 20, ssl->out_ctr, ssl->out_msglen + 13, ssl->out_msg + ssl->out_msglen ); } SSL_DEBUG_BUF( 4, "computed mac", ssl->out_msg + ssl->out_msglen, ssl->maclen ); ssl->out_msglen += ssl->maclen; for( i = 8; i > 0; i-- ) if( ++ssl->out_ctr[i - 1] != 0 ) break; if( ssl->ivlen == 0 ) { #if defined(POLARSSL_ARC4_C) padlen = 0; SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " "including %d bytes of padding", ssl->out_msglen, 0 ) ); SSL_DEBUG_BUF( 4, "before encrypt: output payload", ssl->out_msg, ssl->out_msglen ); arc4_crypt( (arc4_context *) ssl->ctx_enc, ssl->out_msglen, ssl->out_msg, ssl->out_msg ); #else return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #endif } else { unsigned char *enc_msg; size_t enc_msglen; padlen = ssl->ivlen - ( ssl->out_msglen + 1 ) % ssl->ivlen; if( padlen == ssl->ivlen ) padlen = 0; for( i = 0; i <= padlen; i++ ) ssl->out_msg[ssl->out_msglen + i] = (unsigned char) padlen; ssl->out_msglen += padlen + 1; enc_msglen = ssl->out_msglen; enc_msg = ssl->out_msg; /* * Prepend per-record IV for block cipher in TLS v1.1 as per * Method 1 (6.2.3.2. in RFC4346) */ if( ssl->minor_ver == SSL_MINOR_VERSION_2 ) { /* * Generate IV */ int ret = ssl->f_rng( ssl->p_rng, ssl->iv_enc, ssl->ivlen ); if( ret != 0 ) return( ret ); /* * Shift message for ivlen bytes and prepend IV */ memmove( ssl->out_msg + ssl->ivlen, ssl->out_msg, ssl->out_msglen ); memcpy( ssl->out_msg, ssl->iv_enc, ssl->ivlen ); /* * Fix pointer positions and message length with added IV */ enc_msg = ssl->out_msg + ssl->ivlen; enc_msglen = ssl->out_msglen; ssl->out_msglen += ssl->ivlen; } SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " "including %d bytes of IV and %d bytes of padding", ssl->out_msglen, ssl->ivlen, padlen + 1 ) ); SSL_DEBUG_BUF( 4, "before encrypt: output payload", ssl->out_msg, ssl->out_msglen ); switch( ssl->ivlen ) { case 8: #if defined(POLARSSL_DES_C) des3_crypt_cbc( (des3_context *) ssl->ctx_enc, DES_ENCRYPT, enc_msglen, ssl->iv_enc, enc_msg, enc_msg ); break; #endif case 16: #if defined(POLARSSL_AES_C) if ( ssl->session->ciphersuite == SSL_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_RSA_AES_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_256_SHA) { aes_crypt_cbc( (aes_context *) ssl->ctx_enc, AES_ENCRYPT, enc_msglen, ssl->iv_enc, enc_msg, enc_msg); break; } #endif #if defined(POLARSSL_CAMELLIA_C) if ( ssl->session->ciphersuite == SSL_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_RSA_CAMELLIA_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_256_SHA) { camellia_crypt_cbc( (camellia_context *) ssl->ctx_enc, CAMELLIA_ENCRYPT, enc_msglen, ssl->iv_enc, enc_msg, enc_msg ); break; } #endif default: return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); } } SSL_DEBUG_MSG( 2, ( "<= encrypt buf" ) ); return( 0 ); } static int ssl_decrypt_buf( ssl_context *ssl ) { size_t i, padlen; unsigned char tmp[20]; SSL_DEBUG_MSG( 2, ( "=> decrypt buf" ) ); if( ssl->in_msglen < ssl->minlen ) { SSL_DEBUG_MSG( 1, ( "in_msglen (%d) < minlen (%d)", ssl->in_msglen, ssl->minlen ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } if( ssl->ivlen == 0 ) { #if defined(POLARSSL_ARC4_C) padlen = 0; arc4_crypt( (arc4_context *) ssl->ctx_dec, ssl->in_msglen, ssl->in_msg, ssl->in_msg ); #else return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #endif } else { unsigned char *dec_msg; unsigned char *dec_msg_result; size_t dec_msglen; /* * Decrypt and check the padding */ if( ssl->in_msglen % ssl->ivlen != 0 ) { SSL_DEBUG_MSG( 1, ( "msglen (%d) %% ivlen (%d) != 0", ssl->in_msglen, ssl->ivlen ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } dec_msglen = ssl->in_msglen; dec_msg = ssl->in_msg; dec_msg_result = ssl->in_msg; /* * Initialize for prepended IV for block cipher in TLS v1.1 */ if( ssl->minor_ver == SSL_MINOR_VERSION_2 ) { dec_msg += ssl->ivlen; dec_msglen -= ssl->ivlen; ssl->in_msglen -= ssl->ivlen; for( i = 0; i < ssl->ivlen; i++ ) ssl->iv_dec[i] = ssl->in_msg[i]; } switch( ssl->ivlen ) { #if defined(POLARSSL_DES_C) case 8: des3_crypt_cbc( (des3_context *) ssl->ctx_dec, DES_DECRYPT, dec_msglen, ssl->iv_dec, dec_msg, dec_msg_result ); break; #endif case 16: #if defined(POLARSSL_AES_C) if ( ssl->session->ciphersuite == SSL_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_RSA_AES_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_256_SHA) { aes_crypt_cbc( (aes_context *) ssl->ctx_dec, AES_DECRYPT, dec_msglen, ssl->iv_dec, dec_msg, dec_msg_result ); break; } #endif #if defined(POLARSSL_CAMELLIA_C) if ( ssl->session->ciphersuite == SSL_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_RSA_CAMELLIA_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_256_SHA) { camellia_crypt_cbc( (camellia_context *) ssl->ctx_dec, CAMELLIA_DECRYPT, dec_msglen, ssl->iv_dec, dec_msg, dec_msg_result ); break; } #endif default: return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); } padlen = 1 + ssl->in_msg[ssl->in_msglen - 1]; if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { if( padlen > ssl->ivlen ) { SSL_DEBUG_MSG( 1, ( "bad padding length: is %d, " "should be no more than %d", padlen, ssl->ivlen ) ); padlen = 0; } } else { /* * TLSv1: always check the padding */ for( i = 1; i <= padlen; i++ ) { if( ssl->in_msg[ssl->in_msglen - i] != padlen - 1 ) { SSL_DEBUG_MSG( 1, ( "bad padding byte: should be " "%02x, but is %02x", padlen - 1, ssl->in_msg[ssl->in_msglen - i] ) ); padlen = 0; } } } } SSL_DEBUG_BUF( 4, "raw buffer after decryption", ssl->in_msg, ssl->in_msglen ); /* * Always compute the MAC (RFC4346, CBCTIME). */ if( ssl->in_msglen <= ssl->maclen + padlen ) { SSL_DEBUG_MSG( 1, ( "msglen (%d) < maclen (%d) + padlen (%d)", ssl->in_msglen, ssl->maclen, padlen ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } ssl->in_msglen -= ( ssl->maclen + padlen ); ssl->in_hdr[3] = (unsigned char)( ssl->in_msglen >> 8 ); ssl->in_hdr[4] = (unsigned char)( ssl->in_msglen ); memcpy( tmp, ssl->in_msg + ssl->in_msglen, 20 ); if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { if( ssl->maclen == 16 ) ssl_mac_md5( ssl->mac_dec, ssl->in_msg, ssl->in_msglen, ssl->in_ctr, ssl->in_msgtype ); else ssl_mac_sha1( ssl->mac_dec, ssl->in_msg, ssl->in_msglen, ssl->in_ctr, ssl->in_msgtype ); } else { if( ssl->maclen == 16 ) md5_hmac( ssl->mac_dec, 16, ssl->in_ctr, ssl->in_msglen + 13, ssl->in_msg + ssl->in_msglen ); else sha1_hmac( ssl->mac_dec, 20, ssl->in_ctr, ssl->in_msglen + 13, ssl->in_msg + ssl->in_msglen ); } SSL_DEBUG_BUF( 4, "message mac", tmp, ssl->maclen ); SSL_DEBUG_BUF( 4, "computed mac", ssl->in_msg + ssl->in_msglen, ssl->maclen ); if( memcmp( tmp, ssl->in_msg + ssl->in_msglen, ssl->maclen ) != 0 ) { SSL_DEBUG_MSG( 1, ( "message mac does not match" ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } /* * Finally check the padding length; bad padding * will produce the same error as an invalid MAC. */ if( ssl->ivlen != 0 && padlen == 0 ) return( POLARSSL_ERR_SSL_INVALID_MAC ); if( ssl->in_msglen == 0 ) { ssl->nb_zero++; /* * Three or more empty messages may be a DoS attack * (excessive CPU consumption). */ if( ssl->nb_zero > 3 ) { SSL_DEBUG_MSG( 1, ( "received four consecutive empty " "messages, possible DoS attack" ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } } else ssl->nb_zero = 0; for( i = 8; i > 0; i-- ) if( ++ssl->in_ctr[i - 1] != 0 ) break; SSL_DEBUG_MSG( 2, ( "<= decrypt buf" ) ); return( 0 ); } /* * Fill the input message buffer */ int ssl_fetch_input( ssl_context *ssl, size_t nb_want ) { int ret; size_t len; SSL_DEBUG_MSG( 2, ( "=> fetch input" ) ); while( ssl->in_left < nb_want ) { len = nb_want - ssl->in_left; ret = ssl->f_recv( ssl->p_recv, ssl->in_hdr + ssl->in_left, len ); SSL_DEBUG_MSG( 2, ( "in_left: %d, nb_want: %d", ssl->in_left, nb_want ) ); SSL_DEBUG_RET( 2, "ssl->f_recv", ret ); if( ret == 0 ) return( POLARSSL_ERR_SSL_CONN_EOF ); if( ret < 0 ) return( ret ); ssl->in_left += ret; } SSL_DEBUG_MSG( 2, ( "<= fetch input" ) ); return( 0 ); } /* * Flush any data not yet written */ int ssl_flush_output( ssl_context *ssl ) { int ret; unsigned char *buf; SSL_DEBUG_MSG( 2, ( "=> flush output" ) ); while( ssl->out_left > 0 ) { SSL_DEBUG_MSG( 2, ( "message length: %d, out_left: %d", 5 + ssl->out_msglen, ssl->out_left ) ); buf = ssl->out_hdr + 5 + ssl->out_msglen - ssl->out_left; ret = ssl->f_send( ssl->p_send, buf, ssl->out_left ); SSL_DEBUG_RET( 2, "ssl->f_send", ret ); if( ret <= 0 ) return( ret ); ssl->out_left -= ret; } SSL_DEBUG_MSG( 2, ( "<= flush output" ) ); return( 0 ); } /* * Record layer functions */ int ssl_write_record( ssl_context *ssl ) { int ret; size_t len = ssl->out_msglen; SSL_DEBUG_MSG( 2, ( "=> write record" ) ); ssl->out_hdr[0] = (unsigned char) ssl->out_msgtype; ssl->out_hdr[1] = (unsigned char) ssl->major_ver; ssl->out_hdr[2] = (unsigned char) ssl->minor_ver; ssl->out_hdr[3] = (unsigned char)( len >> 8 ); ssl->out_hdr[4] = (unsigned char)( len ); if( ssl->out_msgtype == SSL_MSG_HANDSHAKE ) { ssl->out_msg[1] = (unsigned char)( ( len - 4 ) >> 16 ); ssl->out_msg[2] = (unsigned char)( ( len - 4 ) >> 8 ); ssl->out_msg[3] = (unsigned char)( ( len - 4 ) ); md5_update( &ssl->fin_md5 , ssl->out_msg, len ); sha1_update( &ssl->fin_sha1, ssl->out_msg, len ); } if( ssl->do_crypt != 0 ) { if( ( ret = ssl_encrypt_buf( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_encrypt_buf", ret ); return( ret ); } len = ssl->out_msglen; ssl->out_hdr[3] = (unsigned char)( len >> 8 ); ssl->out_hdr[4] = (unsigned char)( len ); } ssl->out_left = 5 + ssl->out_msglen; SSL_DEBUG_MSG( 3, ( "output record: msgtype = %d, " "version = [%d:%d], msglen = %d", ssl->out_hdr[0], ssl->out_hdr[1], ssl->out_hdr[2], ( ssl->out_hdr[3] << 8 ) | ssl->out_hdr[4] ) ); SSL_DEBUG_BUF( 4, "output record sent to network", ssl->out_hdr, 5 + ssl->out_msglen ); if( ( ret = ssl_flush_output( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_flush_output", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write record" ) ); return( 0 ); } int ssl_read_record( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> read record" ) ); if( ssl->in_hslen != 0 && ssl->in_hslen < ssl->in_msglen ) { /* * Get next Handshake message in the current record */ ssl->in_msglen -= ssl->in_hslen; memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen, ssl->in_msglen ); ssl->in_hslen = 4; ssl->in_hslen += ( ssl->in_msg[2] << 8 ) | ssl->in_msg[3]; SSL_DEBUG_MSG( 3, ( "handshake message: msglen =" " %d, type = %d, hslen = %d", ssl->in_msglen, ssl->in_msg[0], ssl->in_hslen ) ); if( ssl->in_msglen < 4 || ssl->in_msg[1] != 0 ) { SSL_DEBUG_MSG( 1, ( "bad handshake length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } if( ssl->in_msglen < ssl->in_hslen ) { SSL_DEBUG_MSG( 1, ( "bad handshake length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } md5_update( &ssl->fin_md5 , ssl->in_msg, ssl->in_hslen ); sha1_update( &ssl->fin_sha1, ssl->in_msg, ssl->in_hslen ); return( 0 ); } ssl->in_hslen = 0; /* * Read the record header and validate it */ if( ( ret = ssl_fetch_input( ssl, 5 ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); return( ret ); } ssl->in_msgtype = ssl->in_hdr[0]; ssl->in_msglen = ( ssl->in_hdr[3] << 8 ) | ssl->in_hdr[4]; SSL_DEBUG_MSG( 3, ( "input record: msgtype = %d, " "version = [%d:%d], msglen = %d", ssl->in_hdr[0], ssl->in_hdr[1], ssl->in_hdr[2], ( ssl->in_hdr[3] << 8 ) | ssl->in_hdr[4] ) ); if( ssl->in_hdr[1] != ssl->major_ver ) { SSL_DEBUG_MSG( 1, ( "major version mismatch" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } if( ssl->in_hdr[2] > ssl->max_minor_ver ) { SSL_DEBUG_MSG( 1, ( "minor version mismatch" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } /* * Make sure the message length is acceptable */ if( ssl->do_crypt == 0 ) { if( ssl->in_msglen < 1 || ssl->in_msglen > SSL_MAX_CONTENT_LEN ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } } else { if( ssl->in_msglen < ssl->minlen ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } if( ssl->minor_ver == SSL_MINOR_VERSION_0 && ssl->in_msglen > ssl->minlen + SSL_MAX_CONTENT_LEN ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } /* * TLS encrypted messages can have up to 256 bytes of padding */ if( ssl->minor_ver == SSL_MINOR_VERSION_1 && ssl->in_msglen > ssl->minlen + SSL_MAX_CONTENT_LEN + 256 ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } } /* * Read and optionally decrypt the message contents */ if( ( ret = ssl_fetch_input( ssl, 5 + ssl->in_msglen ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); return( ret ); } SSL_DEBUG_BUF( 4, "input record from network", ssl->in_hdr, 5 + ssl->in_msglen ); if( ssl->do_crypt != 0 ) { if( ( ret = ssl_decrypt_buf( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_decrypt_buf", ret ); return( ret ); } SSL_DEBUG_BUF( 4, "input payload after decrypt", ssl->in_msg, ssl->in_msglen ); if( ssl->in_msglen > SSL_MAX_CONTENT_LEN ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } } if( ssl->in_msgtype == SSL_MSG_HANDSHAKE ) { ssl->in_hslen = 4; ssl->in_hslen += ( ssl->in_msg[2] << 8 ) | ssl->in_msg[3]; SSL_DEBUG_MSG( 3, ( "handshake message: msglen =" " %d, type = %d, hslen = %d", ssl->in_msglen, ssl->in_msg[0], ssl->in_hslen ) ); /* * Additional checks to validate the handshake header */ if( ssl->in_msglen < 4 || ssl->in_msg[1] != 0 ) { SSL_DEBUG_MSG( 1, ( "bad handshake length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } if( ssl->in_msglen < ssl->in_hslen ) { SSL_DEBUG_MSG( 1, ( "bad handshake length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); } md5_update( &ssl->fin_md5 , ssl->in_msg, ssl->in_hslen ); sha1_update( &ssl->fin_sha1, ssl->in_msg, ssl->in_hslen ); } if( ssl->in_msgtype == SSL_MSG_ALERT ) { SSL_DEBUG_MSG( 2, ( "got an alert message, type: [%d:%d]", ssl->in_msg[0], ssl->in_msg[1] ) ); /* * Ignore non-fatal alerts, except close_notify */ if( ssl->in_msg[0] == SSL_ALERT_LEVEL_FATAL ) { SSL_DEBUG_MSG( 1, ( "is a fatal alert message" ) ); /** * Subtract from error code as ssl->in_msg[1] is 7-bit positive * error identifier. */ return( POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE - ssl->in_msg[1] ); } if( ssl->in_msg[0] == SSL_ALERT_LEVEL_WARNING && ssl->in_msg[1] == SSL_ALERT_MSG_CLOSE_NOTIFY ) { SSL_DEBUG_MSG( 2, ( "is a close notify message" ) ); return( POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ); } } ssl->in_left = 0; SSL_DEBUG_MSG( 2, ( "<= read record" ) ); return( 0 ); } /* * Handshake functions */ int ssl_write_certificate( ssl_context *ssl ) { int ret; size_t i, n; const x509_cert *crt; SSL_DEBUG_MSG( 2, ( "=> write certificate" ) ); if( ssl->endpoint == SSL_IS_CLIENT ) { if( ssl->client_auth == 0 ) { SSL_DEBUG_MSG( 2, ( "<= skip write certificate" ) ); ssl->state++; return( 0 ); } /* * If using SSLv3 and got no cert, send an Alert message * (otherwise an empty Certificate message will be sent). */ if( ssl->own_cert == NULL && ssl->minor_ver == SSL_MINOR_VERSION_0 ) { ssl->out_msglen = 2; ssl->out_msgtype = SSL_MSG_ALERT; ssl->out_msg[0] = SSL_ALERT_LEVEL_WARNING; ssl->out_msg[1] = SSL_ALERT_MSG_NO_CERT; SSL_DEBUG_MSG( 2, ( "got no certificate to send" ) ); goto write_msg; } } else /* SSL_IS_SERVER */ { if( ssl->own_cert == NULL ) { SSL_DEBUG_MSG( 1, ( "got no certificate to send" ) ); return( POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED ); } } SSL_DEBUG_CRT( 3, "own certificate", ssl->own_cert ); /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 6 length of all certs * 7 . 9 length of cert. 1 * 10 . n-1 peer certificate * n . n+2 length of cert. 2 * n+3 . ... upper level cert, etc. */ i = 7; crt = ssl->own_cert; while( crt != NULL ) { n = crt->raw.len; if( i + 3 + n > SSL_MAX_CONTENT_LEN ) { SSL_DEBUG_MSG( 1, ( "certificate too large, %d > %d", i + 3 + n, SSL_MAX_CONTENT_LEN ) ); return( POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE ); } ssl->out_msg[i ] = (unsigned char)( n >> 16 ); ssl->out_msg[i + 1] = (unsigned char)( n >> 8 ); ssl->out_msg[i + 2] = (unsigned char)( n ); i += 3; memcpy( ssl->out_msg + i, crt->raw.p, n ); i += n; crt = crt->next; } ssl->out_msg[4] = (unsigned char)( ( i - 7 ) >> 16 ); ssl->out_msg[5] = (unsigned char)( ( i - 7 ) >> 8 ); ssl->out_msg[6] = (unsigned char)( ( i - 7 ) ); ssl->out_msglen = i; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_CERTIFICATE; write_msg: ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write certificate" ) ); return( 0 ); } int ssl_parse_certificate( ssl_context *ssl ) { int ret; size_t i, n; SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); if( ssl->endpoint == SSL_IS_SERVER && ssl->authmode == SSL_VERIFY_NONE ) { ssl->verify_result = BADCERT_SKIP_VERIFY; SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); ssl->state++; return( 0 ); } if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } ssl->state++; /* * Check if the client sent an empty certificate */ if( ssl->endpoint == SSL_IS_SERVER && ssl->minor_ver == SSL_MINOR_VERSION_0 ) { if( ssl->in_msglen == 2 && ssl->in_msgtype == SSL_MSG_ALERT && ssl->in_msg[0] == SSL_ALERT_LEVEL_WARNING && ssl->in_msg[1] == SSL_ALERT_MSG_NO_CERT ) { SSL_DEBUG_MSG( 1, ( "SSLv3 client has no certificate" ) ); ssl->verify_result = BADCERT_MISSING; if( ssl->authmode == SSL_VERIFY_OPTIONAL ) return( 0 ); else return( POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE ); } } if( ssl->endpoint == SSL_IS_SERVER && ssl->minor_ver != SSL_MINOR_VERSION_0 ) { if( ssl->in_hslen == 7 && ssl->in_msgtype == SSL_MSG_HANDSHAKE && ssl->in_msg[0] == SSL_HS_CERTIFICATE && memcmp( ssl->in_msg + 4, "\0\0\0", 3 ) == 0 ) { SSL_DEBUG_MSG( 1, ( "TLSv1 client has no certificate" ) ); ssl->verify_result = BADCERT_MISSING; if( ssl->authmode == SSL_VERIFY_REQUIRED ) return( POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE ); else return( 0 ); } } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } if( ssl->in_msg[0] != SSL_HS_CERTIFICATE || ssl->in_hslen < 10 ) { SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE ); } /* * Same message structure as in ssl_write_certificate() */ n = ( ssl->in_msg[5] << 8 ) | ssl->in_msg[6]; if( ssl->in_msg[4] != 0 || ssl->in_hslen != 7 + n ) { SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE ); } if( ( ssl->peer_cert = (x509_cert *) malloc( sizeof( x509_cert ) ) ) == NULL ) { SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", sizeof( x509_cert ) ) ); return( POLARSSL_ERR_SSL_MALLOC_FAILED ); } memset( ssl->peer_cert, 0, sizeof( x509_cert ) ); i = 7; while( i < ssl->in_hslen ) { if( ssl->in_msg[i] != 0 ) { SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE ); } n = ( (unsigned int) ssl->in_msg[i + 1] << 8 ) | (unsigned int) ssl->in_msg[i + 2]; i += 3; if( n < 128 || i + n > ssl->in_hslen ) { SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE ); } ret = x509parse_crt( ssl->peer_cert, ssl->in_msg + i, n ); if( ret != 0 ) { SSL_DEBUG_RET( 1, " x509parse_crt", ret ); return( ret ); } i += n; } SSL_DEBUG_CRT( 3, "peer certificate", ssl->peer_cert ); if( ssl->authmode != SSL_VERIFY_NONE ) { if( ssl->ca_chain == NULL ) { SSL_DEBUG_MSG( 1, ( "got no CA chain" ) ); return( POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED ); } ret = x509parse_verify( ssl->peer_cert, ssl->ca_chain, ssl->ca_crl, ssl->peer_cn, &ssl->verify_result, ssl->f_vrfy, ssl->p_vrfy ); if( ret != 0 ) SSL_DEBUG_RET( 1, "x509_verify_cert", ret ); if( ssl->authmode != SSL_VERIFY_REQUIRED ) ret = 0; } SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); return( ret ); } int ssl_write_change_cipher_spec( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> write change cipher spec" ) ); ssl->out_msgtype = SSL_MSG_CHANGE_CIPHER_SPEC; ssl->out_msglen = 1; ssl->out_msg[0] = 1; ssl->do_crypt = 0; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write change cipher spec" ) ); return( 0 ); } int ssl_parse_change_cipher_spec( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> parse change cipher spec" ) ); ssl->do_crypt = 0; if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_CHANGE_CIPHER_SPEC ) { SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } if( ssl->in_msglen != 1 || ssl->in_msg[0] != 1 ) { SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC ); } ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse change cipher spec" ) ); return( 0 ); } static void ssl_calc_finished( ssl_context *ssl, unsigned char *buf, int from, md5_context *md5, sha1_context *sha1 ) { int len = 12; char *sender; unsigned char padbuf[48]; unsigned char md5sum[16]; unsigned char sha1sum[20]; SSL_DEBUG_MSG( 2, ( "=> calc finished" ) ); /* * SSLv3: * hash = * MD5( master + pad2 + * MD5( handshake + sender + master + pad1 ) ) * + SHA1( master + pad2 + * SHA1( handshake + sender + master + pad1 ) ) * * TLSv1: * hash = PRF( master, finished_label, * MD5( handshake ) + SHA1( handshake ) )[0..11] */ SSL_DEBUG_BUF( 4, "finished md5 state", (unsigned char *) md5->state, sizeof( md5->state ) ); SSL_DEBUG_BUF( 4, "finished sha1 state", (unsigned char *) sha1->state, sizeof( sha1->state ) ); if( ssl->minor_ver == SSL_MINOR_VERSION_0 ) { sender = ( from == SSL_IS_CLIENT ) ? (char *) "CLNT" : (char *) "SRVR"; memset( padbuf, 0x36, 48 ); md5_update( md5, (unsigned char *) sender, 4 ); md5_update( md5, ssl->session->master, 48 ); md5_update( md5, padbuf, 48 ); md5_finish( md5, md5sum ); sha1_update( sha1, (unsigned char *) sender, 4 ); sha1_update( sha1, ssl->session->master, 48 ); sha1_update( sha1, padbuf, 40 ); sha1_finish( sha1, sha1sum ); memset( padbuf, 0x5C, 48 ); md5_starts( md5 ); md5_update( md5, ssl->session->master, 48 ); md5_update( md5, padbuf, 48 ); md5_update( md5, md5sum, 16 ); md5_finish( md5, buf ); sha1_starts( sha1 ); sha1_update( sha1, ssl->session->master, 48 ); sha1_update( sha1, padbuf , 40 ); sha1_update( sha1, sha1sum, 20 ); sha1_finish( sha1, buf + 16 ); len += 24; } else { sender = ( from == SSL_IS_CLIENT ) ? (char *) "client finished" : (char *) "server finished"; md5_finish( md5, padbuf ); sha1_finish( sha1, padbuf + 16 ); tls1_prf( ssl->session->master, 48, sender, padbuf, 36, buf, len ); } SSL_DEBUG_BUF( 3, "calc finished result", buf, len ); memset( md5, 0, sizeof( md5_context ) ); memset( sha1, 0, sizeof( sha1_context ) ); memset( padbuf, 0, sizeof( padbuf ) ); memset( md5sum, 0, sizeof( md5sum ) ); memset( sha1sum, 0, sizeof( sha1sum ) ); SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); } int ssl_write_finished( ssl_context *ssl ) { int ret, hash_len; md5_context md5; sha1_context sha1; SSL_DEBUG_MSG( 2, ( "=> write finished" ) ); memcpy( &md5 , &ssl->fin_md5 , sizeof( md5_context ) ); memcpy( &sha1, &ssl->fin_sha1, sizeof( sha1_context ) ); ssl_calc_finished( ssl, ssl->out_msg + 4, ssl->endpoint, &md5, &sha1 ); hash_len = ( ssl->minor_ver == SSL_MINOR_VERSION_0 ) ? 36 : 12; ssl->out_msglen = 4 + hash_len; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_FINISHED; /* * In case of session resuming, invert the client and server * ChangeCipherSpec messages order. */ if( ssl->resume != 0 ) { if( ssl->endpoint == SSL_IS_CLIENT ) ssl->state = SSL_HANDSHAKE_OVER; else ssl->state = SSL_CLIENT_CHANGE_CIPHER_SPEC; } else ssl->state++; ssl->do_crypt = 1; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write finished" ) ); return( 0 ); } int ssl_parse_finished( ssl_context *ssl ) { int ret; unsigned int hash_len; unsigned char buf[36]; md5_context md5; sha1_context sha1; SSL_DEBUG_MSG( 2, ( "=> parse finished" ) ); memcpy( &md5 , &ssl->fin_md5 , sizeof( md5_context ) ); memcpy( &sha1, &ssl->fin_sha1, sizeof( sha1_context ) ); ssl->do_crypt = 1; if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } hash_len = ( ssl->minor_ver == SSL_MINOR_VERSION_0 ) ? 36 : 12; if( ssl->in_msg[0] != SSL_HS_FINISHED || ssl->in_hslen != 4 + hash_len ) { SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_FINISHED ); } ssl_calc_finished( ssl, buf, ssl->endpoint ^ 1, &md5, &sha1 ); if( memcmp( ssl->in_msg + 4, buf, hash_len ) != 0 ) { SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_FINISHED ); } if( ssl->resume != 0 ) { if( ssl->endpoint == SSL_IS_CLIENT ) ssl->state = SSL_CLIENT_CHANGE_CIPHER_SPEC; if( ssl->endpoint == SSL_IS_SERVER ) ssl->state = SSL_HANDSHAKE_OVER; } else ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse finished" ) ); return( 0 ); } /* * Initialize an SSL context */ int ssl_init( ssl_context *ssl ) { int len = SSL_BUFFER_LEN; memset( ssl, 0, sizeof( ssl_context ) ); ssl->in_ctr = (unsigned char *) malloc( len ); ssl->in_hdr = ssl->in_ctr + 8; ssl->in_msg = ssl->in_ctr + 13; if( ssl->in_ctr == NULL ) { SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", len ) ); return( POLARSSL_ERR_SSL_MALLOC_FAILED ); } ssl->out_ctr = (unsigned char *) malloc( len ); ssl->out_hdr = ssl->out_ctr + 8; ssl->out_msg = ssl->out_ctr + 13; if( ssl->out_ctr == NULL ) { SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", len ) ); free( ssl-> in_ctr ); return( POLARSSL_ERR_SSL_MALLOC_FAILED ); } memset( ssl-> in_ctr, 0, SSL_BUFFER_LEN ); memset( ssl->out_ctr, 0, SSL_BUFFER_LEN ); ssl->hostname = NULL; ssl->hostname_len = 0; md5_starts( &ssl->fin_md5 ); sha1_starts( &ssl->fin_sha1 ); return( 0 ); } /* * Reset an initialized and used SSL context for re-use while retaining * all application-set variables, function pointers and data. */ void ssl_session_reset( ssl_context *ssl ) { ssl->state = SSL_HELLO_REQUEST; ssl->in_offt = NULL; ssl->in_msgtype = 0; ssl->in_msglen = 0; ssl->in_left = 0; ssl->in_hslen = 0; ssl->nb_zero = 0; ssl->out_msgtype = 0; ssl->out_msglen = 0; ssl->out_left = 0; ssl->do_crypt = 0; ssl->pmslen = 0; ssl->keylen = 0; ssl->minlen = 0; ssl->ivlen = 0; ssl->maclen = 0; memset( ssl->out_ctr, 0, SSL_BUFFER_LEN ); memset( ssl->in_ctr, 0, SSL_BUFFER_LEN ); memset( ssl->randbytes, 0, 64 ); memset( ssl->premaster, 0, 256 ); memset( ssl->iv_enc, 0, 16 ); memset( ssl->iv_dec, 0, 16 ); memset( ssl->mac_enc, 0, 32 ); memset( ssl->mac_dec, 0, 32 ); memset( ssl->ctx_enc, 0, 128 ); memset( ssl->ctx_dec, 0, 128 ); md5_starts( &ssl->fin_md5 ); sha1_starts( &ssl->fin_sha1 ); } /* * SSL set accessors */ void ssl_set_endpoint( ssl_context *ssl, int endpoint ) { ssl->endpoint = endpoint; } void ssl_set_authmode( ssl_context *ssl, int authmode ) { ssl->authmode = authmode; } void ssl_set_verify( ssl_context *ssl, int (*f_vrfy)(void *, x509_cert *, int, int), void *p_vrfy ) { ssl->f_vrfy = f_vrfy; ssl->p_vrfy = p_vrfy; } void ssl_set_rng( ssl_context *ssl, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { ssl->f_rng = f_rng; ssl->p_rng = p_rng; } void ssl_set_dbg( ssl_context *ssl, void (*f_dbg)(void *, int, const char *), void *p_dbg ) { ssl->f_dbg = f_dbg; ssl->p_dbg = p_dbg; } void ssl_set_bio( ssl_context *ssl, int (*f_recv)(void *, unsigned char *, size_t), void *p_recv, int (*f_send)(void *, const unsigned char *, size_t), void *p_send ) { ssl->f_recv = f_recv; ssl->f_send = f_send; ssl->p_recv = p_recv; ssl->p_send = p_send; } void ssl_set_scb( ssl_context *ssl, int (*s_get)(ssl_context *), int (*s_set)(ssl_context *) ) { ssl->s_get = s_get; ssl->s_set = s_set; } void ssl_set_session( ssl_context *ssl, int resume, int timeout, ssl_session *session ) { ssl->resume = resume; ssl->timeout = timeout; ssl->session = session; } void ssl_set_ciphersuites( ssl_context *ssl, int *ciphersuites ) { ssl->ciphersuites = ciphersuites; } void ssl_set_ca_chain( ssl_context *ssl, x509_cert *ca_chain, x509_crl *ca_crl, const char *peer_cn ) { ssl->ca_chain = ca_chain; ssl->ca_crl = ca_crl; ssl->peer_cn = peer_cn; } void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert, rsa_context *rsa_key ) { ssl->own_cert = own_cert; ssl->rsa_key = rsa_key; } #if defined(POLARSSL_PKCS11_C) void ssl_set_own_cert_pkcs11( ssl_context *ssl, x509_cert *own_cert, pkcs11_context *pkcs11_key ) { ssl->own_cert = own_cert; ssl->pkcs11_key = pkcs11_key; } #endif int ssl_set_dh_param( ssl_context *ssl, const char *dhm_P, const char *dhm_G ) { int ret; if( ( ret = mpi_read_string( &ssl->dhm_ctx.P, 16, dhm_P ) ) != 0 ) { SSL_DEBUG_RET( 1, "mpi_read_string", ret ); return( ret ); } if( ( ret = mpi_read_string( &ssl->dhm_ctx.G, 16, dhm_G ) ) != 0 ) { SSL_DEBUG_RET( 1, "mpi_read_string", ret ); return( ret ); } return( 0 ); } int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx ) { int ret; if( ( ret = mpi_copy(&ssl->dhm_ctx.P, &dhm_ctx->P) ) != 0 ) { SSL_DEBUG_RET( 1, "mpi_copy", ret ); return( ret ); } if( ( ret = mpi_copy(&ssl->dhm_ctx.G, &dhm_ctx->G) ) != 0 ) { SSL_DEBUG_RET( 1, "mpi_copy", ret ); return( ret ); } return( 0 ); } int ssl_set_hostname( ssl_context *ssl, const char *hostname ) { if( hostname == NULL ) return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); ssl->hostname_len = strlen( hostname ); ssl->hostname = (unsigned char *) malloc( ssl->hostname_len + 1 ); if( ssl->hostname == NULL ) return( POLARSSL_ERR_SSL_MALLOC_FAILED ); memcpy( ssl->hostname, (unsigned char *) hostname, ssl->hostname_len ); ssl->hostname[ssl->hostname_len] = '\0'; return( 0 ); } void ssl_set_max_version( ssl_context *ssl, int major, int minor ) { ssl->max_major_ver = major; ssl->max_minor_ver = minor; } /* * SSL get accessors */ size_t ssl_get_bytes_avail( const ssl_context *ssl ) { return( ssl->in_offt == NULL ? 0 : ssl->in_msglen ); } int ssl_get_verify_result( const ssl_context *ssl ) { return( ssl->verify_result ); } const char *ssl_get_ciphersuite_name( const int ciphersuite_id ) { switch( ciphersuite_id ) { #if defined(POLARSSL_ARC4_C) case SSL_RSA_RC4_128_MD5: return( "SSL-RSA-RC4-128-MD5" ); case SSL_RSA_RC4_128_SHA: return( "SSL-RSA-RC4-128-SHA" ); #endif #if defined(POLARSSL_DES_C) case SSL_RSA_DES_168_SHA: return( "SSL-RSA-DES-168-SHA" ); case SSL_EDH_RSA_DES_168_SHA: return( "SSL-EDH-RSA-DES-168-SHA" ); #endif #if defined(POLARSSL_AES_C) case SSL_RSA_AES_128_SHA: return( "SSL-RSA-AES-128-SHA" ); case SSL_EDH_RSA_AES_128_SHA: return( "SSL-EDH-RSA-AES-128-SHA" ); case SSL_RSA_AES_256_SHA: return( "SSL-RSA-AES-256-SHA" ); case SSL_EDH_RSA_AES_256_SHA: return( "SSL-EDH-RSA-AES-256-SHA" ); #endif #if defined(POLARSSL_CAMELLIA_C) case SSL_RSA_CAMELLIA_128_SHA: return( "SSL-RSA-CAMELLIA-128-SHA" ); case SSL_EDH_RSA_CAMELLIA_128_SHA: return( "SSL-EDH-RSA-CAMELLIA-128-SHA" ); case SSL_RSA_CAMELLIA_256_SHA: return( "SSL-RSA-CAMELLIA-256-SHA" ); case SSL_EDH_RSA_CAMELLIA_256_SHA: return( "SSL-EDH-RSA-CAMELLIA-256-SHA" ); #endif default: break; } return( "unknown" ); } int ssl_get_ciphersuite_id( const char *ciphersuite_name ) { #if defined(POLARSSL_ARC4_C) if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-RC4-128-MD5")) return( SSL_RSA_RC4_128_MD5 ); if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-RC4-128-SHA")) return( SSL_RSA_RC4_128_SHA ); #endif #if defined(POLARSSL_DES_C) if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-DES-168-SHA")) return( SSL_RSA_DES_168_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-EDH-RSA-DES-168-SHA")) return( SSL_EDH_RSA_DES_168_SHA ); #endif #if defined(POLARSSL_AES_C) if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-AES-128-SHA")) return( SSL_RSA_AES_128_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-EDH-RSA-AES-128-SHA")) return( SSL_EDH_RSA_AES_128_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-AES-256-SHA")) return( SSL_RSA_AES_256_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-EDH-RSA-AES-256-SHA")) return( SSL_EDH_RSA_AES_256_SHA ); #endif #if defined(POLARSSL_CAMELLIA_C) if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-CAMELLIA-128-SHA")) return( SSL_RSA_CAMELLIA_128_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-EDH-RSA-CAMELLIA-128-SHA")) return( SSL_EDH_RSA_CAMELLIA_128_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-RSA-CAMELLIA-256-SHA")) return( SSL_RSA_CAMELLIA_256_SHA ); if (0 == strcasecmp(ciphersuite_name, "SSL-EDH-RSA-CAMELLIA-256-SHA")) return( SSL_EDH_RSA_CAMELLIA_256_SHA ); #endif return( 0 ); } const char *ssl_get_ciphersuite( const ssl_context *ssl ) { return ssl_get_ciphersuite_name( ssl->session->ciphersuite ); } const char *ssl_get_version( const ssl_context *ssl ) { switch( ssl->minor_ver ) { case SSL_MINOR_VERSION_0: return( "SSLv3.0" ); case SSL_MINOR_VERSION_1: return( "TLSv1.0" ); case SSL_MINOR_VERSION_2: return( "TLSv1.1" ); default: break; } return( "unknown" ); } int ssl_default_ciphersuites[] = { #if defined(POLARSSL_DHM_C) #if defined(POLARSSL_AES_C) SSL_EDH_RSA_AES_128_SHA, SSL_EDH_RSA_AES_256_SHA, #endif #if defined(POLARSSL_CAMELLIA_C) SSL_EDH_RSA_CAMELLIA_128_SHA, SSL_EDH_RSA_CAMELLIA_256_SHA, #endif #if defined(POLARSSL_DES_C) SSL_EDH_RSA_DES_168_SHA, #endif #endif #if defined(POLARSSL_AES_C) SSL_RSA_AES_256_SHA, #endif #if defined(POLARSSL_CAMELLIA_C) SSL_RSA_CAMELLIA_256_SHA, #endif #if defined(POLARSSL_AES_C) SSL_RSA_AES_128_SHA, #endif #if defined(POLARSSL_CAMELLIA_C) SSL_RSA_CAMELLIA_128_SHA, #endif #if defined(POLARSSL_DES_C) SSL_RSA_DES_168_SHA, #endif #if defined(POLARSSL_ARC4_C) SSL_RSA_RC4_128_SHA, SSL_RSA_RC4_128_MD5, #endif 0 }; /* * Perform the SSL handshake */ int ssl_handshake( ssl_context *ssl ) { int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE; SSL_DEBUG_MSG( 2, ( "=> handshake" ) ); #if defined(POLARSSL_SSL_CLI_C) if( ssl->endpoint == SSL_IS_CLIENT ) ret = ssl_handshake_client( ssl ); #endif #if defined(POLARSSL_SSL_SRV_C) if( ssl->endpoint == SSL_IS_SERVER ) ret = ssl_handshake_server( ssl ); #endif SSL_DEBUG_MSG( 2, ( "<= handshake" ) ); return( ret ); } /* * Receive application data decrypted from the SSL layer */ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ) { int ret; size_t n; SSL_DEBUG_MSG( 2, ( "=> read" ) ); if( ssl->state != SSL_HANDSHAKE_OVER ) { if( ( ret = ssl_handshake( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_handshake", ret ); return( ret ); } } if( ssl->in_offt == NULL ) { if( ( ret = ssl_read_record( ssl ) ) != 0 ) { if( ret == POLARSSL_ERR_SSL_CONN_EOF ) return( 0 ); SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msglen == 0 && ssl->in_msgtype == SSL_MSG_APPLICATION_DATA ) { /* * OpenSSL sends empty messages to randomize the IV */ if( ( ret = ssl_read_record( ssl ) ) != 0 ) { if( ret == POLARSSL_ERR_SSL_CONN_EOF ) return( 0 ); SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } } if( ssl->in_msgtype != SSL_MSG_APPLICATION_DATA ) { SSL_DEBUG_MSG( 1, ( "bad application data message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } ssl->in_offt = ssl->in_msg; } n = ( len < ssl->in_msglen ) ? len : ssl->in_msglen; memcpy( buf, ssl->in_offt, n ); ssl->in_msglen -= n; if( ssl->in_msglen == 0 ) /* all bytes consumed */ ssl->in_offt = NULL; else /* more data available */ ssl->in_offt += n; SSL_DEBUG_MSG( 2, ( "<= read" ) ); return( (int) n ); } /* * Send application data to be encrypted by the SSL layer */ int ssl_write( ssl_context *ssl, const unsigned char *buf, size_t len ) { int ret; size_t n; SSL_DEBUG_MSG( 2, ( "=> write" ) ); if( ssl->state != SSL_HANDSHAKE_OVER ) { if( ( ret = ssl_handshake( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_handshake", ret ); return( ret ); } } n = ( len < SSL_MAX_CONTENT_LEN ) ? len : SSL_MAX_CONTENT_LEN; if( ssl->out_left != 0 ) { if( ( ret = ssl_flush_output( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_flush_output", ret ); return( ret ); } } else { ssl->out_msglen = n; ssl->out_msgtype = SSL_MSG_APPLICATION_DATA; memcpy( ssl->out_msg, buf, n ); if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } } SSL_DEBUG_MSG( 2, ( "<= write" ) ); return( (int) n ); } /* * Notify the peer that the connection is being closed */ int ssl_close_notify( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> write close notify" ) ); if( ( ret = ssl_flush_output( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_flush_output", ret ); return( ret ); } if( ssl->state == SSL_HANDSHAKE_OVER ) { ssl->out_msgtype = SSL_MSG_ALERT; ssl->out_msglen = 2; ssl->out_msg[0] = SSL_ALERT_LEVEL_WARNING; ssl->out_msg[1] = SSL_ALERT_MSG_CLOSE_NOTIFY; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } } SSL_DEBUG_MSG( 2, ( "<= write close notify" ) ); return( ret ); } /* * Free an SSL context */ void ssl_free( ssl_context *ssl ) { SSL_DEBUG_MSG( 2, ( "=> free" ) ); if( ssl->peer_cert != NULL ) { x509_free( ssl->peer_cert ); memset( ssl->peer_cert, 0, sizeof( x509_cert ) ); free( ssl->peer_cert ); } if( ssl->out_ctr != NULL ) { memset( ssl->out_ctr, 0, SSL_BUFFER_LEN ); free( ssl->out_ctr ); } if( ssl->in_ctr != NULL ) { memset( ssl->in_ctr, 0, SSL_BUFFER_LEN ); free( ssl->in_ctr ); } #if defined(POLARSSL_DHM_C) dhm_free( &ssl->dhm_ctx ); #endif if ( ssl->hostname != NULL) { memset( ssl->hostname, 0, ssl->hostname_len ); free( ssl->hostname ); ssl->hostname_len = 0; } SSL_DEBUG_MSG( 2, ( "<= free" ) ); /* Actually free after last debug message */ memset( ssl, 0, sizeof( ssl_context ) ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/entropy.c0000644000014601777760000001255012165464055023146 0ustar00jenkinsnogroup00000000000000/* * Entropy accumulator implementation * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_ENTROPY_C) #include "polarssl/entropy.h" #include "polarssl/entropy_poll.h" #if defined(POLARSSL_HAVEGE_C) #include "polarssl/havege.h" #endif #define ENTROPY_MAX_LOOP 256 /**< Maximum amount to loop before error */ void entropy_init( entropy_context *ctx ) { memset( ctx, 0, sizeof(entropy_context) ); sha4_starts( &ctx->accumulator, 0 ); #if defined(POLARSSL_HAVEGE_C) havege_init( &ctx->havege_data ); #endif #if !defined(POLARSSL_NO_DEFAULT_ENTROPY_SOURCES) #if !defined(POLARSSL_NO_PLATFORM_ENTROPY) entropy_add_source( ctx, platform_entropy_poll, NULL, ENTROPY_MIN_PLATFORM ); #endif #if defined(POLARSSL_TIMING_C) entropy_add_source( ctx, hardclock_poll, NULL, ENTROPY_MIN_HARDCLOCK ); #endif #if defined(POLARSSL_HAVEGE_C) entropy_add_source( ctx, havege_poll, &ctx->havege_data, ENTROPY_MIN_HAVEGE ); #endif #endif /* POLARSSL_NO_DEFAULT_ENTROPY_SOURCES */ } int entropy_add_source( entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold ) { int index = ctx->source_count; if( index >= ENTROPY_MAX_SOURCES ) return( POLARSSL_ERR_ENTROPY_MAX_SOURCES ); ctx->source[index].f_source = f_source; ctx->source[index].p_source = p_source; ctx->source[index].threshold = threshold; ctx->source_count++; return( 0 ); } /* * Entropy accumulator update */ int entropy_update( entropy_context *ctx, unsigned char source_id, const unsigned char *data, size_t len ) { unsigned char header[2]; unsigned char tmp[ENTROPY_BLOCK_SIZE]; size_t use_len = len; const unsigned char *p = data; if( use_len > ENTROPY_BLOCK_SIZE ) { sha4( data, len, tmp, 0 ); p = tmp; use_len = ENTROPY_BLOCK_SIZE; } header[0] = source_id; header[1] = use_len & 0xFF; sha4_update( &ctx->accumulator, header, 2 ); sha4_update( &ctx->accumulator, p, use_len ); return( 0 ); } int entropy_update_manual( entropy_context *ctx, const unsigned char *data, size_t len ) { return entropy_update( ctx, ENTROPY_SOURCE_MANUAL, data, len ); } /* * Run through the different sources to add entropy to our accumulator */ int entropy_gather( entropy_context *ctx ) { int ret, i; unsigned char buf[ENTROPY_MAX_GATHER]; size_t olen; if( ctx->source_count == 0 ) return( POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED ); /* * Run through our entropy sources */ for( i = 0; i < ctx->source_count; i++ ) { olen = 0; if ( ( ret = ctx->source[i].f_source( ctx->source[i].p_source, buf, ENTROPY_MAX_GATHER, &olen ) ) != 0 ) { return( ret ); } /* * Add if we actually gathered something */ if( olen > 0 ) { entropy_update( ctx, (unsigned char) i, buf, olen ); ctx->source[i].size += olen; } } return( 0 ); } int entropy_func( void *data, unsigned char *output, size_t len ) { int ret, count = 0, i, reached; entropy_context *ctx = (entropy_context *) data; unsigned char buf[ENTROPY_BLOCK_SIZE]; if( len > ENTROPY_BLOCK_SIZE ) return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED ); /* * Always gather extra entropy before a call */ do { if( count++ > ENTROPY_MAX_LOOP ) return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED ); if( ( ret = entropy_gather( ctx ) ) != 0 ) return( ret ); reached = 0; for( i = 0; i < ctx->source_count; i++ ) if( ctx->source[i].size >= ctx->source[i].threshold ) reached++; } while( reached != ctx->source_count ); memset( buf, 0, ENTROPY_BLOCK_SIZE ); sha4_finish( &ctx->accumulator, buf ); /* * Perform second SHA-512 on entropy */ sha4( buf, ENTROPY_BLOCK_SIZE, buf, 0 ); /* * Reset accumulator and counters and recycle existing entropy */ memset( &ctx->accumulator, 0, sizeof( sha4_context ) ); sha4_starts( &ctx->accumulator, 0 ); sha4_update( &ctx->accumulator, buf, ENTROPY_BLOCK_SIZE ); for( i = 0; i < ctx->source_count; i++ ) ctx->source[i].size = 0; memcpy( output, buf, len ); return( 0 ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/net.c0000644000014601777760000002074712165464055022243 0ustar00jenkinsnogroup00000000000000/* * TCP networking functions * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_NET_C) #include "polarssl/net.h" #if defined(_WIN32) || defined(_WIN32_WCE) #include #include #if defined(_WIN32_WCE) #pragma comment( lib, "ws2.lib" ) #else #pragma comment( lib, "ws2_32.lib" ) #endif #define read(fd,buf,len) recv(fd,(char*)buf,(int) len,0) #define write(fd,buf,len) send(fd,(char*)buf,(int) len,0) #define close(fd) closesocket(fd) static int wsa_init_done = 0; #else #include #include #include #include #include #include #include #include #include #include #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #include #elif defined(__APPLE__) #include #elif defined (__SVR4) && defined (__sun) #include #else #include #endif #endif #include #include #include /* * htons() is not always available. * By default go for LITTLE_ENDIAN variant. Otherwise hope for _BYTE_ORDER and __BIG_ENDIAN * to help determine endianess. */ #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN #define POLARSSL_HTONS(n) (n) #else #define POLARSSL_HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) #endif unsigned short net_htons(unsigned short n); #define net_htons(n) POLARSSL_HTONS(n) /* * Initiate a TCP connection with host:port */ int net_connect( int *fd, const char *host, int port ) { struct sockaddr_in server_addr; struct hostent *server_host; #if defined(_WIN32) || defined(_WIN32_WCE) WSADATA wsaData; if( wsa_init_done == 0 ) { if( WSAStartup( MAKEWORD(2,0), &wsaData ) == SOCKET_ERROR ) return( POLARSSL_ERR_NET_SOCKET_FAILED ); wsa_init_done = 1; } #else signal( SIGPIPE, SIG_IGN ); #endif if( ( server_host = gethostbyname( host ) ) == NULL ) return( POLARSSL_ERR_NET_UNKNOWN_HOST ); if( ( *fd = socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 ) return( POLARSSL_ERR_NET_SOCKET_FAILED ); memcpy( (void *) &server_addr.sin_addr, (void *) server_host->h_addr, server_host->h_length ); server_addr.sin_family = AF_INET; server_addr.sin_port = net_htons( port ); if( connect( *fd, (struct sockaddr *) &server_addr, sizeof( server_addr ) ) < 0 ) { close( *fd ); return( POLARSSL_ERR_NET_CONNECT_FAILED ); } return( 0 ); } /* * Create a listening socket on bind_ip:port */ int net_bind( int *fd, const char *bind_ip, int port ) { int n, c[4]; struct sockaddr_in server_addr; #if defined(_WIN32) || defined(_WIN32_WCE) WSADATA wsaData; if( wsa_init_done == 0 ) { if( WSAStartup( MAKEWORD(2,0), &wsaData ) == SOCKET_ERROR ) return( POLARSSL_ERR_NET_SOCKET_FAILED ); wsa_init_done = 1; } #else signal( SIGPIPE, SIG_IGN ); #endif if( ( *fd = socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 ) return( POLARSSL_ERR_NET_SOCKET_FAILED ); n = 1; setsockopt( *fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &n, sizeof( n ) ); server_addr.sin_addr.s_addr = INADDR_ANY; server_addr.sin_family = AF_INET; server_addr.sin_port = net_htons( port ); if( bind_ip != NULL ) { memset( c, 0, sizeof( c ) ); sscanf( bind_ip, "%d.%d.%d.%d", &c[0], &c[1], &c[2], &c[3] ); for( n = 0; n < 4; n++ ) if( c[n] < 0 || c[n] > 255 ) break; if( n == 4 ) server_addr.sin_addr.s_addr = ( (unsigned long) c[0] << 24 ) | ( (unsigned long) c[1] << 16 ) | ( (unsigned long) c[2] << 8 ) | ( (unsigned long) c[3] ); } if( bind( *fd, (struct sockaddr *) &server_addr, sizeof( server_addr ) ) < 0 ) { close( *fd ); return( POLARSSL_ERR_NET_BIND_FAILED ); } if( listen( *fd, POLARSSL_NET_LISTEN_BACKLOG ) != 0 ) { close( *fd ); return( POLARSSL_ERR_NET_LISTEN_FAILED ); } return( 0 ); } /* * Check if the current operation is blocking */ static int net_is_blocking( void ) { #if defined(_WIN32) || defined(_WIN32_WCE) return( WSAGetLastError() == WSAEWOULDBLOCK ); #else switch( errno ) { #if defined EAGAIN case EAGAIN: #endif #if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif return( 1 ); } return( 0 ); #endif } /* * Accept a connection from a remote client */ int net_accept( int bind_fd, int *client_fd, void *client_ip ) { struct sockaddr_in client_addr; #if defined(__socklen_t_defined) || defined(_SOCKLEN_T) || \ defined(_SOCKLEN_T_DECLARED) socklen_t n = (socklen_t) sizeof( client_addr ); #else int n = (int) sizeof( client_addr ); #endif *client_fd = accept( bind_fd, (struct sockaddr *) &client_addr, &n ); if( *client_fd < 0 ) { if( net_is_blocking() != 0 ) return( POLARSSL_ERR_NET_WANT_READ ); return( POLARSSL_ERR_NET_ACCEPT_FAILED ); } if( client_ip != NULL ) memcpy( client_ip, &client_addr.sin_addr.s_addr, sizeof( client_addr.sin_addr.s_addr ) ); return( 0 ); } /* * Set the socket blocking or non-blocking */ int net_set_block( int fd ) { #if defined(_WIN32) || defined(_WIN32_WCE) u_long n = 0; return( ioctlsocket( fd, FIONBIO, &n ) ); #else return( fcntl( fd, F_SETFL, fcntl( fd, F_GETFL ) & ~O_NONBLOCK ) ); #endif } int net_set_nonblock( int fd ) { #if defined(_WIN32) || defined(_WIN32_WCE) u_long n = 1; return( ioctlsocket( fd, FIONBIO, &n ) ); #else return( fcntl( fd, F_SETFL, fcntl( fd, F_GETFL ) | O_NONBLOCK ) ); #endif } /* * Portable usleep helper */ void net_usleep( unsigned long usec ) { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = usec; select( 0, NULL, NULL, NULL, &tv ); } /* * Read at most 'len' characters */ int net_recv( void *ctx, unsigned char *buf, size_t len ) { int ret = read( *((int *) ctx), buf, len ); if( ret < 0 ) { if( net_is_blocking() != 0 ) return( POLARSSL_ERR_NET_WANT_READ ); #if defined(_WIN32) || defined(_WIN32_WCE) if( WSAGetLastError() == WSAECONNRESET ) return( POLARSSL_ERR_NET_CONN_RESET ); #else if( errno == EPIPE || errno == ECONNRESET ) return( POLARSSL_ERR_NET_CONN_RESET ); if( errno == EINTR ) return( POLARSSL_ERR_NET_WANT_READ ); #endif return( POLARSSL_ERR_NET_RECV_FAILED ); } return( ret ); } /* * Write at most 'len' characters */ int net_send( void *ctx, const unsigned char *buf, size_t len ) { int ret = write( *((int *) ctx), buf, len ); if( ret < 0 ) { if( net_is_blocking() != 0 ) return( POLARSSL_ERR_NET_WANT_WRITE ); #if defined(_WIN32) || defined(_WIN32_WCE) if( WSAGetLastError() == WSAECONNRESET ) return( POLARSSL_ERR_NET_CONN_RESET ); #else if( errno == EPIPE || errno == ECONNRESET ) return( POLARSSL_ERR_NET_CONN_RESET ); if( errno == EINTR ) return( POLARSSL_ERR_NET_WANT_WRITE ); #endif return( POLARSSL_ERR_NET_SEND_FAILED ); } return( ret ); } /* * Gracefully close the connection */ void net_close( int fd ) { shutdown( fd, 2 ); close( fd ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/dhm.c0000644000014601777760000001626312165464055022223 0ustar00jenkinsnogroup00000000000000/* * Diffie-Hellman-Merkle key exchange * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * Reference: * * http://www.cacr.math.uwaterloo.ca/hac/ (chapter 12) */ #include "polarssl/config.h" #if defined(POLARSSL_DHM_C) #include "polarssl/dhm.h" /* * helper to validate the mpi size and import it */ static int dhm_read_bignum( mpi *X, unsigned char **p, const unsigned char *end ) { int ret, n; if( end - *p < 2 ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); n = ( (*p)[0] << 8 ) | (*p)[1]; (*p) += 2; if( (int)( end - *p ) < n ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); if( ( ret = mpi_read_binary( X, *p, n ) ) != 0 ) return( POLARSSL_ERR_DHM_READ_PARAMS_FAILED + ret ); (*p) += n; return( 0 ); } /* * Verify sanity of parameter with regards to P * * Parameter should be: 2 <= public_param <= P - 2 * * For more information on the attack, see: * http://www.cl.cam.ac.uk/~rja14/Papers/psandqs.pdf * http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2643 */ static int dhm_check_range( const mpi *param, const mpi *P ) { mpi L, U; int ret = POLARSSL_ERR_DHM_BAD_INPUT_DATA; mpi_init( &L ); mpi_init( &U ); mpi_lset( &L, 2 ); mpi_sub_int( &U, P, 2 ); if( mpi_cmp_mpi( param, &L ) >= 0 && mpi_cmp_mpi( param, &U ) <= 0 ) { ret = 0; } mpi_free( &L ); mpi_free( &U ); return( ret ); } /* * Parse the ServerKeyExchange parameters */ int dhm_read_params( dhm_context *ctx, unsigned char **p, const unsigned char *end ) { int ret, n; memset( ctx, 0, sizeof( dhm_context ) ); if( ( ret = dhm_read_bignum( &ctx->P, p, end ) ) != 0 || ( ret = dhm_read_bignum( &ctx->G, p, end ) ) != 0 || ( ret = dhm_read_bignum( &ctx->GY, p, end ) ) != 0 ) return( ret ); if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) return( ret ); ctx->len = mpi_size( &ctx->P ); if( end - *p < 2 ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); n = ( (*p)[0] << 8 ) | (*p)[1]; (*p) += 2; if( end != *p + n ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); return( 0 ); } /* * Setup and write the ServerKeyExchange parameters */ int dhm_make_params( dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret, count = 0; size_t n1, n2, n3; unsigned char *p; /* * Generate X as large as possible ( < P ) */ do { mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) mpi_shift_r( &ctx->X, 1 ); if( count++ > 10 ) return( POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED ); } while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); /* * Calculate GX = G^X mod P */ MPI_CHK( mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, &ctx->P , &ctx->RP ) ); if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) return( ret ); /* * export P, G, GX */ #define DHM_MPI_EXPORT(X,n) \ MPI_CHK( mpi_write_binary( X, p + 2, n ) ); \ *p++ = (unsigned char)( n >> 8 ); \ *p++ = (unsigned char)( n ); p += n; n1 = mpi_size( &ctx->P ); n2 = mpi_size( &ctx->G ); n3 = mpi_size( &ctx->GX ); p = output; DHM_MPI_EXPORT( &ctx->P , n1 ); DHM_MPI_EXPORT( &ctx->G , n2 ); DHM_MPI_EXPORT( &ctx->GX, n3 ); *olen = p - output; ctx->len = n1; cleanup: if( ret != 0 ) return( POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED + ret ); return( 0 ); } /* * Import the peer's public value G^Y */ int dhm_read_public( dhm_context *ctx, const unsigned char *input, size_t ilen ) { int ret; if( ctx == NULL || ilen < 1 || ilen > ctx->len ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); if( ( ret = mpi_read_binary( &ctx->GY, input, ilen ) ) != 0 ) return( POLARSSL_ERR_DHM_READ_PUBLIC_FAILED + ret ); return( 0 ); } /* * Create own private value X and export G^X */ int dhm_make_public( dhm_context *ctx, int x_size, unsigned char *output, size_t olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret, count = 0; if( ctx == NULL || olen < 1 || olen > ctx->len ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); /* * generate X and calculate GX = G^X mod P */ do { mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) mpi_shift_r( &ctx->X, 1 ); if( count++ > 10 ) return( POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED ); } while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); MPI_CHK( mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, &ctx->P , &ctx->RP ) ); if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) return( ret ); MPI_CHK( mpi_write_binary( &ctx->GX, output, olen ) ); cleanup: if( ret != 0 ) return( POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED + ret ); return( 0 ); } /* * Derive and export the shared secret (G^Y)^X mod P */ int dhm_calc_secret( dhm_context *ctx, unsigned char *output, size_t *olen ) { int ret; if( ctx == NULL || *olen < ctx->len ) return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); MPI_CHK( mpi_exp_mod( &ctx->K, &ctx->GY, &ctx->X, &ctx->P, &ctx->RP ) ); if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) return( ret ); *olen = mpi_size( &ctx->K ); MPI_CHK( mpi_write_binary( &ctx->K, output, *olen ) ); cleanup: if( ret != 0 ) return( POLARSSL_ERR_DHM_CALC_SECRET_FAILED + ret ); return( 0 ); } /* * Free the components of a DHM key */ void dhm_free( dhm_context *ctx ) { mpi_free( &ctx->RP ); mpi_free( &ctx->K ); mpi_free( &ctx->GY ); mpi_free( &ctx->GX ); mpi_free( &ctx->X ); mpi_free( &ctx->G ); mpi_free( &ctx->P ); } #if defined(POLARSSL_SELF_TEST) /* * Checkup routine */ int dhm_self_test( int verbose ) { return( verbose++ ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/x509parse.c0000644000014601777760000024153412165464055023214 0ustar00jenkinsnogroup00000000000000/* * X.509 certificate and private key decoding * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The ITU-T X.509 standard defines a certificat format for PKI. * * http://www.ietf.org/rfc/rfc2459.txt * http://www.ietf.org/rfc/rfc3279.txt * * ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1v2.asc * * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_X509_PARSE_C) #include "polarssl/x509.h" #include "polarssl/asn1.h" #include "polarssl/pem.h" #include "polarssl/des.h" #include "polarssl/md2.h" #include "polarssl/md4.h" #include "polarssl/md5.h" #include "polarssl/sha1.h" #include "polarssl/sha2.h" #include "polarssl/sha4.h" #include "polarssl/dhm.h" #include #include #if defined(_WIN32) #include #else #include #endif #if defined(POLARSSL_FS_IO) #include #endif /* * Version ::= INTEGER { v1(0), v2(1), v3(2) } */ static int x509_get_version( unsigned char **p, const unsigned char *end, int *ver ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 0 ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) { *ver = 0; return( 0 ); } return( ret ); } end = *p + len; if( ( ret = asn1_get_int( p, end, ver ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_VERSION + ret ); if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_VERSION + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * Version ::= INTEGER { v1(0), v2(1) } */ static int x509_crl_get_version( unsigned char **p, const unsigned char *end, int *ver ) { int ret; if( ( ret = asn1_get_int( p, end, ver ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) { *ver = 0; return( 0 ); } return( POLARSSL_ERR_X509_CERT_INVALID_VERSION + ret ); } return( 0 ); } /* * CertificateSerialNumber ::= INTEGER */ static int x509_get_serial( unsigned char **p, const unsigned char *end, x509_buf *serial ) { int ret; if( ( end - *p ) < 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_SERIAL + POLARSSL_ERR_ASN1_OUT_OF_DATA ); if( **p != ( ASN1_CONTEXT_SPECIFIC | ASN1_PRIMITIVE | 2 ) && **p != ASN1_INTEGER ) return( POLARSSL_ERR_X509_CERT_INVALID_SERIAL + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ); serial->tag = *(*p)++; if( ( ret = asn1_get_len( p, end, &serial->len ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_SERIAL + ret ); serial->p = *p; *p += serial->len; return( 0 ); } /* * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL } */ static int x509_get_alg( unsigned char **p, const unsigned char *end, x509_buf *alg ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_ALG + ret ); end = *p + len; alg->tag = **p; if( ( ret = asn1_get_tag( p, end, &alg->len, ASN1_OID ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_ALG + ret ); alg->p = *p; *p += alg->len; if( *p == end ) return( 0 ); /* * assume the algorithm parameters must be NULL */ if( ( ret = asn1_get_tag( p, end, &len, ASN1_NULL ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_ALG + ret ); if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_ALG + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * AttributeTypeAndValue ::= SEQUENCE { * type AttributeType, * value AttributeValue } * * AttributeType ::= OBJECT IDENTIFIER * * AttributeValue ::= ANY DEFINED BY AttributeType */ static int x509_get_attr_type_value( unsigned char **p, const unsigned char *end, x509_name *cur ) { int ret; size_t len; x509_buf *oid; x509_buf *val; if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + ret ); oid = &cur->oid; oid->tag = **p; if( ( ret = asn1_get_tag( p, end, &oid->len, ASN1_OID ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + ret ); oid->p = *p; *p += oid->len; if( ( end - *p ) < 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + POLARSSL_ERR_ASN1_OUT_OF_DATA ); if( **p != ASN1_BMP_STRING && **p != ASN1_UTF8_STRING && **p != ASN1_T61_STRING && **p != ASN1_PRINTABLE_STRING && **p != ASN1_IA5_STRING && **p != ASN1_UNIVERSAL_STRING ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ); val = &cur->val; val->tag = *(*p)++; if( ( ret = asn1_get_len( p, end, &val->len ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + ret ); val->p = *p; *p += val->len; cur->next = NULL; return( 0 ); } /* * RelativeDistinguishedName ::= * SET OF AttributeTypeAndValue * * AttributeTypeAndValue ::= SEQUENCE { * type AttributeType, * value AttributeValue } * * AttributeType ::= OBJECT IDENTIFIER * * AttributeValue ::= ANY DEFINED BY AttributeType */ static int x509_get_name( unsigned char **p, const unsigned char *end, x509_name *cur ) { int ret; size_t len; const unsigned char *end2; x509_name *use; if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SET ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_NAME + ret ); end2 = end; end = *p + len; use = cur; do { if( ( ret = x509_get_attr_type_value( p, end, use ) ) != 0 ) return( ret ); if( *p != end ) { use->next = (x509_name *) malloc( sizeof( x509_name ) ); if( use->next == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); memset( use->next, 0, sizeof( x509_name ) ); use = use->next; } } while( *p != end ); /* * recurse until end of SEQUENCE is reached */ if( *p == end2 ) return( 0 ); cur->next = (x509_name *) malloc( sizeof( x509_name ) ); if( cur->next == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); return( x509_get_name( p, end2, cur->next ) ); } /* * Time ::= CHOICE { * utcTime UTCTime, * generalTime GeneralizedTime } */ static int x509_get_time( unsigned char **p, const unsigned char *end, x509_time *time ) { int ret; size_t len; char date[64]; unsigned char tag; if( ( end - *p ) < 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE + POLARSSL_ERR_ASN1_OUT_OF_DATA ); tag = **p; if ( tag == ASN1_UTC_TIME ) { (*p)++; ret = asn1_get_len( p, end, &len ); if( ret != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE + ret ); memset( date, 0, sizeof( date ) ); memcpy( date, *p, ( len < sizeof( date ) - 1 ) ? len : sizeof( date ) - 1 ); if( sscanf( date, "%2d%2d%2d%2d%2d%2d", &time->year, &time->mon, &time->day, &time->hour, &time->min, &time->sec ) < 5 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE ); time->year += 100 * ( time->year < 50 ); time->year += 1900; *p += len; return( 0 ); } else if ( tag == ASN1_GENERALIZED_TIME ) { (*p)++; ret = asn1_get_len( p, end, &len ); if( ret != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE + ret ); memset( date, 0, sizeof( date ) ); memcpy( date, *p, ( len < sizeof( date ) - 1 ) ? len : sizeof( date ) - 1 ); if( sscanf( date, "%4d%2d%2d%2d%2d%2d", &time->year, &time->mon, &time->day, &time->hour, &time->min, &time->sec ) < 5 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE ); *p += len; return( 0 ); } else return( POLARSSL_ERR_X509_CERT_INVALID_DATE + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ); } /* * Validity ::= SEQUENCE { * notBefore Time, * notAfter Time } */ static int x509_get_dates( unsigned char **p, const unsigned char *end, x509_time *from, x509_time *to ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE + ret ); end = *p + len; if( ( ret = x509_get_time( p, end, from ) ) != 0 ) return( ret ); if( ( ret = x509_get_time( p, end, to ) ) != 0 ) return( ret ); if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_DATE + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * SubjectPublicKeyInfo ::= SEQUENCE { * algorithm AlgorithmIdentifier, * subjectPublicKey BIT STRING } */ static int x509_get_pubkey( unsigned char **p, const unsigned char *end, x509_buf *pk_alg_oid, mpi *N, mpi *E ) { int ret, can_handle; size_t len; unsigned char *end2; if( ( ret = x509_get_alg( p, end, pk_alg_oid ) ) != 0 ) return( ret ); /* * only RSA public keys handled at this time */ can_handle = 0; if( pk_alg_oid->len == 9 && memcmp( pk_alg_oid->p, OID_PKCS1_RSA, 9 ) == 0 ) can_handle = 1; if( pk_alg_oid->len == 9 && memcmp( pk_alg_oid->p, OID_PKCS1, 8 ) == 0 ) { if( pk_alg_oid->p[8] >= 2 && pk_alg_oid->p[8] <= 5 ) can_handle = 1; if ( pk_alg_oid->p[8] >= 11 && pk_alg_oid->p[8] <= 14 ) can_handle = 1; } if( pk_alg_oid->len == 5 && memcmp( pk_alg_oid->p, OID_RSA_SHA_OBS, 5 ) == 0 ) can_handle = 1; if( can_handle == 0 ) return( POLARSSL_ERR_X509_UNKNOWN_PK_ALG ); if( ( ret = asn1_get_tag( p, end, &len, ASN1_BIT_STRING ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + ret ); if( ( end - *p ) < 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + POLARSSL_ERR_ASN1_OUT_OF_DATA ); end2 = *p + len; if( *(*p)++ != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY ); /* * RSAPublicKey ::= SEQUENCE { * modulus INTEGER, -- n * publicExponent INTEGER -- e * } */ if( ( ret = asn1_get_tag( p, end2, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + ret ); if( *p + len != end2 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); if( ( ret = asn1_get_mpi( p, end2, N ) ) != 0 || ( ret = asn1_get_mpi( p, end2, E ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + ret ); if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_PUBKEY + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } static int x509_get_sig( unsigned char **p, const unsigned char *end, x509_buf *sig ) { int ret; size_t len; sig->tag = **p; if( ( ret = asn1_get_tag( p, end, &len, ASN1_BIT_STRING ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE + ret ); if( --len < 1 || *(*p)++ != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE ); sig->len = len; sig->p = *p; *p += len; return( 0 ); } /* * X.509 v2/v3 unique identifier (not parsed) */ static int x509_get_uid( unsigned char **p, const unsigned char *end, x509_buf *uid, int n ) { int ret; if( *p == end ) return( 0 ); uid->tag = **p; if( ( ret = asn1_get_tag( p, end, &uid->len, ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | n ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) return( 0 ); return( ret ); } uid->p = *p; *p += uid->len; return( 0 ); } /* * X.509 Extensions (No parsing of extensions, pointer should * be either manually updated or extensions should be parsed! */ static int x509_get_ext( unsigned char **p, const unsigned char *end, x509_buf *ext, int tag ) { int ret; size_t len; if( *p == end ) return( 0 ); ext->tag = **p; if( ( ret = asn1_get_tag( p, end, &ext->len, ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | tag ) ) != 0 ) return( ret ); ext->p = *p; end = *p + ext->len; /* * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension * * Extension ::= SEQUENCE { * extnID OBJECT IDENTIFIER, * critical BOOLEAN DEFAULT FALSE, * extnValue OCTET STRING } */ if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( end != *p + len ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * X.509 CRL v2 extensions (no extensions parsed yet.) */ static int x509_get_crl_ext( unsigned char **p, const unsigned char *end, x509_buf *ext ) { int ret; size_t len = 0; /* Get explicit tag */ if( ( ret = x509_get_ext( p, end, ext, 0) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) return( 0 ); return( ret ); } while( *p < end ) { if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); *p += len; } if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * X.509 CRL v2 entry extensions (no extensions parsed yet.) */ static int x509_get_crl_entry_ext( unsigned char **p, const unsigned char *end, x509_buf *ext ) { int ret; size_t len = 0; /* OPTIONAL */ if (end <= *p) return( 0 ); ext->tag = **p; ext->p = *p; /* * Get CRL-entry extension sequence header * crlEntryExtensions Extensions OPTIONAL -- if present, MUST be v2 */ if( ( ret = asn1_get_tag( p, end, &ext->len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) { ext->p = NULL; return( 0 ); } return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); } end = *p + ext->len; if( end != *p + ext->len ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); while( *p < end ) { if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); *p += len; } if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } static int x509_get_basic_constraints( unsigned char **p, const unsigned char *end, int *ca_istrue, int *max_pathlen ) { int ret; size_t len; /* * BasicConstraints ::= SEQUENCE { * cA BOOLEAN DEFAULT FALSE, * pathLenConstraint INTEGER (0..MAX) OPTIONAL } */ *ca_istrue = 0; /* DEFAULT FALSE */ *max_pathlen = 0; /* endless */ if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( *p == end ) return 0; if( ( ret = asn1_get_bool( p, end, ca_istrue ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) ret = asn1_get_int( p, end, ca_istrue ); if( ret != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( *ca_istrue != 0 ) *ca_istrue = 1; } if( *p == end ) return 0; if( ( ret = asn1_get_int( p, end, max_pathlen ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); (*max_pathlen)++; return 0; } static int x509_get_ns_cert_type( unsigned char **p, const unsigned char *end, unsigned char *ns_cert_type) { int ret; x509_bitstring bs = { 0, 0, NULL }; if( ( ret = asn1_get_bitstring( p, end, &bs ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( bs.len != 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_INVALID_LENGTH ); /* Get actual bitstring */ *ns_cert_type = *bs.p; return 0; } static int x509_get_key_usage( unsigned char **p, const unsigned char *end, unsigned char *key_usage) { int ret; x509_bitstring bs = { 0, 0, NULL }; if( ( ret = asn1_get_bitstring( p, end, &bs ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); if( bs.len > 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_INVALID_LENGTH ); /* Get actual bitstring */ *key_usage = *bs.p; return 0; } /* * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId * * KeyPurposeId ::= OBJECT IDENTIFIER */ static int x509_get_ext_key_usage( unsigned char **p, const unsigned char *end, x509_sequence *ext_key_usage) { int ret; if( ( ret = asn1_get_sequence_of( p, end, ext_key_usage, ASN1_OID ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); /* Sequence length must be >= 1 */ if( ext_key_usage->buf.p == NULL ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_INVALID_LENGTH ); return 0; } /* * X.509 v3 extensions * * TODO: Perform all of the basic constraints tests required by the RFC * TODO: Set values for undetected extensions to a sane default? * */ static int x509_get_crt_ext( unsigned char **p, const unsigned char *end, x509_cert *crt ) { int ret; size_t len; unsigned char *end_ext_data, *end_ext_octet; if( ( ret = x509_get_ext( p, end, &crt->v3_ext, 3 ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) return( 0 ); return( ret ); } while( *p < end ) { /* * Extension ::= SEQUENCE { * extnID OBJECT IDENTIFIER, * critical BOOLEAN DEFAULT FALSE, * extnValue OCTET STRING } */ x509_buf extn_oid = {0, 0, NULL}; int is_critical = 0; /* DEFAULT FALSE */ if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); end_ext_data = *p + len; /* Get extension ID */ extn_oid.tag = **p; if( ( ret = asn1_get_tag( p, end, &extn_oid.len, ASN1_OID ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); extn_oid.p = *p; *p += extn_oid.len; if( ( end - *p ) < 1 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_OUT_OF_DATA ); /* Get optional critical */ if( ( ret = asn1_get_bool( p, end_ext_data, &is_critical ) ) != 0 && ( ret != POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); /* Data should be octet string type */ if( ( ret = asn1_get_tag( p, end_ext_data, &len, ASN1_OCTET_STRING ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + ret ); end_ext_octet = *p + len; if( end_ext_octet != end_ext_data ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); /* * Detect supported extensions */ if( ( OID_SIZE( OID_BASIC_CONSTRAINTS ) == extn_oid.len ) && memcmp( extn_oid.p, OID_BASIC_CONSTRAINTS, extn_oid.len ) == 0 ) { /* Parse basic constraints */ if( ( ret = x509_get_basic_constraints( p, end_ext_octet, &crt->ca_istrue, &crt->max_pathlen ) ) != 0 ) return ( ret ); crt->ext_types |= EXT_BASIC_CONSTRAINTS; } else if( ( OID_SIZE( OID_NS_CERT_TYPE ) == extn_oid.len ) && memcmp( extn_oid.p, OID_NS_CERT_TYPE, extn_oid.len ) == 0 ) { /* Parse netscape certificate type */ if( ( ret = x509_get_ns_cert_type( p, end_ext_octet, &crt->ns_cert_type ) ) != 0 ) return ( ret ); crt->ext_types |= EXT_NS_CERT_TYPE; } else if( ( OID_SIZE( OID_KEY_USAGE ) == extn_oid.len ) && memcmp( extn_oid.p, OID_KEY_USAGE, extn_oid.len ) == 0 ) { /* Parse key usage */ if( ( ret = x509_get_key_usage( p, end_ext_octet, &crt->key_usage ) ) != 0 ) return ( ret ); crt->ext_types |= EXT_KEY_USAGE; } else if( ( OID_SIZE( OID_EXTENDED_KEY_USAGE ) == extn_oid.len ) && memcmp( extn_oid.p, OID_EXTENDED_KEY_USAGE, extn_oid.len ) == 0 ) { /* Parse extended key usage */ if( ( ret = x509_get_ext_key_usage( p, end_ext_octet, &crt->ext_key_usage ) ) != 0 ) return ( ret ); crt->ext_types |= EXT_EXTENDED_KEY_USAGE; } else { /* No parser found, skip extension */ *p = end_ext_octet; #if !defined(POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION) if( is_critical ) { /* Data is marked as critical: fail */ return ( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ); } #endif } } if( *p != end ) return( POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } /* * X.509 CRL Entries */ static int x509_get_entries( unsigned char **p, const unsigned char *end, x509_crl_entry *entry ) { int ret; size_t entry_len; x509_crl_entry *cur_entry = entry; if( *p == end ) return( 0 ); if( ( ret = asn1_get_tag( p, end, &entry_len, ASN1_SEQUENCE | ASN1_CONSTRUCTED ) ) != 0 ) { if( ret == POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) return( 0 ); return( ret ); } end = *p + entry_len; while( *p < end ) { size_t len2; const unsigned char *end2; if( ( ret = asn1_get_tag( p, end, &len2, ASN1_SEQUENCE | ASN1_CONSTRUCTED ) ) != 0 ) { return( ret ); } cur_entry->raw.tag = **p; cur_entry->raw.p = *p; cur_entry->raw.len = len2; end2 = *p + len2; if( ( ret = x509_get_serial( p, end2, &cur_entry->serial ) ) != 0 ) return( ret ); if( ( ret = x509_get_time( p, end2, &cur_entry->revocation_date ) ) != 0 ) return( ret ); if( ( ret = x509_get_crl_entry_ext( p, end2, &cur_entry->entry_ext ) ) != 0 ) return( ret ); if ( *p < end ) { cur_entry->next = malloc( sizeof( x509_crl_entry ) ); if( cur_entry->next == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); cur_entry = cur_entry->next; memset( cur_entry, 0, sizeof( x509_crl_entry ) ); } } return( 0 ); } static int x509_get_sig_alg( const x509_buf *sig_oid, int *sig_alg ) { if( sig_oid->len == 9 && memcmp( sig_oid->p, OID_PKCS1, 8 ) == 0 ) { if( sig_oid->p[8] >= 2 && sig_oid->p[8] <= 5 ) { *sig_alg = sig_oid->p[8]; return( 0 ); } if ( sig_oid->p[8] >= 11 && sig_oid->p[8] <= 14 ) { *sig_alg = sig_oid->p[8]; return( 0 ); } return( POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG ); } if( sig_oid->len == 5 && memcmp( sig_oid->p, OID_RSA_SHA_OBS, 5 ) == 0 ) { *sig_alg = SIG_RSA_SHA1; return( 0 ); } return( POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG ); } /* * Parse and fill a single X.509 certificate in DER format */ int x509parse_crt_der( x509_cert *crt, const unsigned char *buf, size_t buflen ) { int ret; size_t len; unsigned char *p, *end; /* * Check for valid input */ if( crt == NULL || buf == NULL ) return( POLARSSL_ERR_X509_INVALID_INPUT ); p = (unsigned char *) malloc( len = buflen ); if( p == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); memcpy( p, buf, buflen ); buflen = 0; crt->raw.p = p; crt->raw.len = len; end = p + len; /* * Certificate ::= SEQUENCE { * tbsCertificate TBSCertificate, * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT ); } if( len != (size_t) ( end - p ) ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } /* * TBSCertificate ::= SEQUENCE { */ crt->tbs.p = p; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } end = p + len; crt->tbs.len = end - crt->tbs.p; /* * Version ::= INTEGER { v1(0), v2(1), v3(2) } * * CertificateSerialNumber ::= INTEGER * * signature AlgorithmIdentifier */ if( ( ret = x509_get_version( &p, end, &crt->version ) ) != 0 || ( ret = x509_get_serial( &p, end, &crt->serial ) ) != 0 || ( ret = x509_get_alg( &p, end, &crt->sig_oid1 ) ) != 0 ) { x509_free( crt ); return( ret ); } crt->version++; if( crt->version > 3 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION ); } if( ( ret = x509_get_sig_alg( &crt->sig_oid1, &crt->sig_alg ) ) != 0 ) { x509_free( crt ); return( ret ); } /* * issuer Name */ crt->issuer_raw.p = p; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } if( ( ret = x509_get_name( &p, p + len, &crt->issuer ) ) != 0 ) { x509_free( crt ); return( ret ); } crt->issuer_raw.len = p - crt->issuer_raw.p; /* * Validity ::= SEQUENCE { * notBefore Time, * notAfter Time } * */ if( ( ret = x509_get_dates( &p, end, &crt->valid_from, &crt->valid_to ) ) != 0 ) { x509_free( crt ); return( ret ); } /* * subject Name */ crt->subject_raw.p = p; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } if( ( ret = x509_get_name( &p, p + len, &crt->subject ) ) != 0 ) { x509_free( crt ); return( ret ); } crt->subject_raw.len = p - crt->subject_raw.p; /* * SubjectPublicKeyInfo ::= SEQUENCE * algorithm AlgorithmIdentifier, * subjectPublicKey BIT STRING } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } if( ( ret = x509_get_pubkey( &p, p + len, &crt->pk_oid, &crt->rsa.N, &crt->rsa.E ) ) != 0 ) { x509_free( crt ); return( ret ); } if( ( ret = rsa_check_pubkey( &crt->rsa ) ) != 0 ) { x509_free( crt ); return( ret ); } crt->rsa.len = mpi_size( &crt->rsa.N ); /* * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, * -- If present, version shall be v2 or v3 * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, * -- If present, version shall be v2 or v3 * extensions [3] EXPLICIT Extensions OPTIONAL * -- If present, version shall be v3 */ if( crt->version == 2 || crt->version == 3 ) { ret = x509_get_uid( &p, end, &crt->issuer_id, 1 ); if( ret != 0 ) { x509_free( crt ); return( ret ); } } if( crt->version == 2 || crt->version == 3 ) { ret = x509_get_uid( &p, end, &crt->subject_id, 2 ); if( ret != 0 ) { x509_free( crt ); return( ret ); } } if( crt->version == 3 ) { ret = x509_get_crt_ext( &p, end, crt); if( ret != 0 ) { x509_free( crt ); return( ret ); } } if( p != end ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } end = crt->raw.p + crt->raw.len; /* * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING */ if( ( ret = x509_get_alg( &p, end, &crt->sig_oid2 ) ) != 0 ) { x509_free( crt ); return( ret ); } if( memcmp( crt->sig_oid1.p, crt->sig_oid2.p, crt->sig_oid1.len ) != 0 ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_SIG_MISMATCH ); } if( ( ret = x509_get_sig( &p, end, &crt->sig ) ) != 0 ) { x509_free( crt ); return( ret ); } if( p != end ) { x509_free( crt ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } return( 0 ); } /* * Parse one or more PEM certificates from a buffer and add them to the chained list */ int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ) { int ret, success = 0, first_error = 0, total_failed = 0; x509_cert *crt, *prev = NULL; int buf_format = X509_FORMAT_DER; crt = chain; /* * Check for valid input */ if( crt == NULL || buf == NULL ) return( POLARSSL_ERR_X509_INVALID_INPUT ); while( crt->version != 0 && crt->next != NULL ) { prev = crt; crt = crt->next; } /* * Add new certificate on the end of the chain if needed. */ if ( crt->version != 0 && crt->next == NULL) { crt->next = (x509_cert *) malloc( sizeof( x509_cert ) ); if( crt->next == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); prev = crt; crt = crt->next; memset( crt, 0, sizeof( x509_cert ) ); } /* * Determine buffer content. Buffer contains either one DER certificate or * one or more PEM certificates. */ #if defined(POLARSSL_PEM_C) if( strstr( (char *) buf, "-----BEGIN CERTIFICATE-----" ) != NULL ) buf_format = X509_FORMAT_PEM; #endif if( buf_format == X509_FORMAT_DER ) return x509parse_crt_der( crt, buf, buflen ); #if defined(POLARSSL_PEM_C) if( buf_format == X509_FORMAT_PEM ) { pem_context pem; while( buflen > 0 ) { size_t use_len; pem_init( &pem ); ret = pem_read_buffer( &pem, "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----", buf, NULL, 0, &use_len ); if( ret == 0 ) { /* * Was PEM encoded */ buflen -= use_len; buf += use_len; } else if( ret != POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { pem_free( &pem ); if( first_error == 0 ) first_error = ret; continue; } else break; ret = x509parse_crt_der( crt, pem.buf, pem.buflen ); pem_free( &pem ); if( ret != 0 ) { /* * quit parsing on a memory error */ if( ret == POLARSSL_ERR_X509_MALLOC_FAILED ) { if( prev ) prev->next = NULL; if( crt != chain ) free( crt ); return( ret ); } if( first_error == 0 ) first_error = ret; total_failed++; memset( crt, 0, sizeof( x509_cert ) ); continue; } success = 1; /* * Add new certificate to the list */ crt->next = (x509_cert *) malloc( sizeof( x509_cert ) ); if( crt->next == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); prev = crt; crt = crt->next; memset( crt, 0, sizeof( x509_cert ) ); } } #endif if( crt->version == 0 ) { if( prev ) prev->next = NULL; if( crt != chain ) free( crt ); } if( success ) return( total_failed ); else if( first_error ) return( first_error ); else return( POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT ); } /* * Parse one or more CRLs and add them to the chained list */ int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen ) { int ret; size_t len; unsigned char *p, *end; x509_crl *crl; #if defined(POLARSSL_PEM_C) size_t use_len; pem_context pem; #endif crl = chain; /* * Check for valid input */ if( crl == NULL || buf == NULL ) return( POLARSSL_ERR_X509_INVALID_INPUT ); while( crl->version != 0 && crl->next != NULL ) crl = crl->next; /* * Add new CRL on the end of the chain if needed. */ if ( crl->version != 0 && crl->next == NULL) { crl->next = (x509_crl *) malloc( sizeof( x509_crl ) ); if( crl->next == NULL ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_MALLOC_FAILED ); } crl = crl->next; memset( crl, 0, sizeof( x509_crl ) ); } #if defined(POLARSSL_PEM_C) pem_init( &pem ); ret = pem_read_buffer( &pem, "-----BEGIN X509 CRL-----", "-----END X509 CRL-----", buf, NULL, 0, &use_len ); if( ret == 0 ) { /* * Was PEM encoded */ buflen -= use_len; buf += use_len; /* * Steal PEM buffer */ p = pem.buf; pem.buf = NULL; len = pem.buflen; pem_free( &pem ); } else if( ret != POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { pem_free( &pem ); return( ret ); } else { /* * nope, copy the raw DER data */ p = (unsigned char *) malloc( len = buflen ); if( p == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); memcpy( p, buf, buflen ); buflen = 0; } #else p = (unsigned char *) malloc( len = buflen ); if( p == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); memcpy( p, buf, buflen ); buflen = 0; #endif crl->raw.p = p; crl->raw.len = len; end = p + len; /* * CertificateList ::= SEQUENCE { * tbsCertList TBSCertList, * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT ); } if( len != (size_t) ( end - p ) ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } /* * TBSCertList ::= SEQUENCE { */ crl->tbs.p = p; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } end = p + len; crl->tbs.len = end - crl->tbs.p; /* * Version ::= INTEGER OPTIONAL { v1(0), v2(1) } * -- if present, MUST be v2 * * signature AlgorithmIdentifier */ if( ( ret = x509_crl_get_version( &p, end, &crl->version ) ) != 0 || ( ret = x509_get_alg( &p, end, &crl->sig_oid1 ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } crl->version++; if( crl->version > 2 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION ); } if( ( ret = x509_get_sig_alg( &crl->sig_oid1, &crl->sig_alg ) ) != 0 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG ); } /* * issuer Name */ crl->issuer_raw.p = p; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } if( ( ret = x509_get_name( &p, p + len, &crl->issuer ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } crl->issuer_raw.len = p - crl->issuer_raw.p; /* * thisUpdate Time * nextUpdate Time OPTIONAL */ if( ( ret = x509_get_time( &p, end, &crl->this_update ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } if( ( ret = x509_get_time( &p, end, &crl->next_update ) ) != 0 ) { if ( ret != ( POLARSSL_ERR_X509_CERT_INVALID_DATE + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) && ret != ( POLARSSL_ERR_X509_CERT_INVALID_DATE + POLARSSL_ERR_ASN1_OUT_OF_DATA ) ) { x509_crl_free( crl ); return( ret ); } } /* * revokedCertificates SEQUENCE OF SEQUENCE { * userCertificate CertificateSerialNumber, * revocationDate Time, * crlEntryExtensions Extensions OPTIONAL * -- if present, MUST be v2 * } OPTIONAL */ if( ( ret = x509_get_entries( &p, end, &crl->entry ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } /* * crlExtensions EXPLICIT Extensions OPTIONAL * -- if present, MUST be v2 */ if( crl->version == 2 ) { ret = x509_get_crl_ext( &p, end, &crl->crl_ext ); if( ret != 0 ) { x509_crl_free( crl ); return( ret ); } } if( p != end ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } end = crl->raw.p + crl->raw.len; /* * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING */ if( ( ret = x509_get_alg( &p, end, &crl->sig_oid2 ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } if( memcmp( crl->sig_oid1.p, crl->sig_oid2.p, crl->sig_oid1.len ) != 0 ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_SIG_MISMATCH ); } if( ( ret = x509_get_sig( &p, end, &crl->sig ) ) != 0 ) { x509_crl_free( crl ); return( ret ); } if( p != end ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } if( buflen > 0 ) { crl->next = (x509_crl *) malloc( sizeof( x509_crl ) ); if( crl->next == NULL ) { x509_crl_free( crl ); return( POLARSSL_ERR_X509_MALLOC_FAILED ); } crl = crl->next; memset( crl, 0, sizeof( x509_crl ) ); return( x509parse_crl( crl, buf, buflen ) ); } return( 0 ); } #if defined(POLARSSL_FS_IO) /* * Load all data from a file into a given buffer. */ int load_file( const char *path, unsigned char **buf, size_t *n ) { FILE *f; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_X509_FILE_IO_ERROR ); fseek( f, 0, SEEK_END ); *n = (size_t) ftell( f ); fseek( f, 0, SEEK_SET ); if( ( *buf = (unsigned char *) malloc( *n + 1 ) ) == NULL ) return( POLARSSL_ERR_X509_MALLOC_FAILED ); if( fread( *buf, 1, *n, f ) != *n ) { fclose( f ); free( *buf ); return( POLARSSL_ERR_X509_FILE_IO_ERROR ); } fclose( f ); (*buf)[*n] = '\0'; return( 0 ); } /* * Load one or more certificates and add them to the chained list */ int x509parse_crtfile( x509_cert *chain, const char *path ) { int ret; size_t n; unsigned char *buf; if ( (ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = x509parse_crt( chain, buf, n ); memset( buf, 0, n + 1 ); free( buf ); return( ret ); } /* * Load one or more CRLs and add them to the chained list */ int x509parse_crlfile( x509_crl *chain, const char *path ) { int ret; size_t n; unsigned char *buf; if ( (ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = x509parse_crl( chain, buf, n ); memset( buf, 0, n + 1 ); free( buf ); return( ret ); } /* * Load and parse a private RSA key */ int x509parse_keyfile( rsa_context *rsa, const char *path, const char *pwd ) { int ret; size_t n; unsigned char *buf; if ( (ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); if( pwd == NULL ) ret = x509parse_key( rsa, buf, n, NULL, 0 ); else ret = x509parse_key( rsa, buf, n, (unsigned char *) pwd, strlen( pwd ) ); memset( buf, 0, n + 1 ); free( buf ); return( ret ); } /* * Load and parse a public RSA key */ int x509parse_public_keyfile( rsa_context *rsa, const char *path ) { int ret; size_t n; unsigned char *buf; if ( (ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = x509parse_public_key( rsa, buf, n ); memset( buf, 0, n + 1 ); free( buf ); return( ret ); } #endif /* POLARSSL_FS_IO */ /* * Parse a private RSA key */ int x509parse_key( rsa_context *rsa, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen ) { int ret; size_t len; unsigned char *p, *end; unsigned char *p_alt; x509_buf pk_alg_oid; #if defined(POLARSSL_PEM_C) pem_context pem; pem_init( &pem ); ret = pem_read_buffer( &pem, "-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", key, pwd, pwdlen, &len ); if( ret == POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { ret = pem_read_buffer( &pem, "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----", key, pwd, pwdlen, &len ); } if( ret == 0 ) { /* * Was PEM encoded */ keylen = pem.buflen; } else if( ret != POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { pem_free( &pem ); return( ret ); } p = ( ret == 0 ) ? pem.buf : (unsigned char *) key; #else ((void) pwd); ((void) pwdlen); p = (unsigned char *) key; #endif end = p + keylen; /* * Note: Depending on the type of private key file one can expect either a * PrivatKeyInfo object (PKCS#8) or a RSAPrivateKey (PKCS#1) directly. * * PrivateKeyInfo ::= SEQUENCE { * version Version, * algorithm AlgorithmIdentifier, * PrivateKey BIT STRING * } * * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * * RSAPrivateKey ::= SEQUENCE { * version Version, * modulus INTEGER, -- n * publicExponent INTEGER, -- e * privateExponent INTEGER, -- d * prime1 INTEGER, -- p * prime2 INTEGER, -- q * exponent1 INTEGER, -- d mod (p-1) * exponent2 INTEGER, -- d mod (q-1) * coefficient INTEGER, -- (inverse of q) mod p * otherPrimeInfos OtherPrimeInfos OPTIONAL * } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } end = p + len; if( ( ret = asn1_get_int( &p, end, &rsa->ver ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } if( rsa->ver != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_VERSION + ret ); } p_alt = p; if( ( ret = x509_get_alg( &p_alt, end, &pk_alg_oid ) ) != 0 ) { // Assume that we have the PKCS#1 format if wrong // tag was encountered // if( ret != POLARSSL_ERR_X509_CERT_INVALID_ALG + POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT ); } } else { int can_handle; /* * only RSA keys handled at this time */ can_handle = 0; if( pk_alg_oid.len == 9 && memcmp( pk_alg_oid.p, OID_PKCS1_RSA, 9 ) == 0 ) can_handle = 1; if( pk_alg_oid.len == 9 && memcmp( pk_alg_oid.p, OID_PKCS1, 8 ) == 0 ) { if( pk_alg_oid.p[8] >= 2 && pk_alg_oid.p[8] <= 5 ) can_handle = 1; if ( pk_alg_oid.p[8] >= 11 && pk_alg_oid.p[8] <= 14 ) can_handle = 1; } if( pk_alg_oid.len == 5 && memcmp( pk_alg_oid.p, OID_RSA_SHA_OBS, 5 ) == 0 ) can_handle = 1; if( can_handle == 0 ) return( POLARSSL_ERR_X509_UNKNOWN_PK_ALG ); /* * Parse the PKCS#8 format */ p = p_alt; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_OCTET_STRING ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } if( ( end - p ) < 1 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + POLARSSL_ERR_ASN1_OUT_OF_DATA ); } end = p + len; if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } end = p + len; if( ( ret = asn1_get_int( &p, end, &rsa->ver ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } if( rsa->ver != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_VERSION + ret ); } } if( ( ret = asn1_get_mpi( &p, end, &rsa->N ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->E ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->D ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->P ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->Q ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->DP ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->DQ ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &rsa->QP ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } rsa->len = mpi_size( &rsa->N ); if( p != end ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } if( ( ret = rsa_check_privkey( rsa ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( ret ); } #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif return( 0 ); } /* * Parse a public RSA key */ int x509parse_public_key( rsa_context *rsa, const unsigned char *key, size_t keylen ) { int ret; size_t len; unsigned char *p, *end; x509_buf alg_oid; #if defined(POLARSSL_PEM_C) pem_context pem; pem_init( &pem ); ret = pem_read_buffer( &pem, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----", key, NULL, 0, &len ); if( ret == 0 ) { /* * Was PEM encoded */ keylen = pem.buflen; } else if( ret != POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { pem_free( &pem ); return( ret ); } p = ( ret == 0 ) ? pem.buf : (unsigned char *) key; #else p = (unsigned char *) key; #endif end = p + keylen; /* * PublicKeyInfo ::= SEQUENCE { * algorithm AlgorithmIdentifier, * PublicKey BIT STRING * } * * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * * RSAPublicKey ::= SEQUENCE { * modulus INTEGER, -- n * publicExponent INTEGER -- e * } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_CERT_INVALID_FORMAT + ret ); } if( ( ret = x509_get_pubkey( &p, end, &alg_oid, &rsa->N, &rsa->E ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } if( ( ret = rsa_check_pubkey( rsa ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif rsa_free( rsa ); return( ret ); } rsa->len = mpi_size( &rsa->N ); #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif return( 0 ); } #if defined(POLARSSL_DHM_C) /* * Parse DHM parameters */ int x509parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen ) { int ret; size_t len; unsigned char *p, *end; #if defined(POLARSSL_PEM_C) pem_context pem; pem_init( &pem ); ret = pem_read_buffer( &pem, "-----BEGIN DH PARAMETERS-----", "-----END DH PARAMETERS-----", dhmin, NULL, 0, &dhminlen ); if( ret == 0 ) { /* * Was PEM encoded */ dhminlen = pem.buflen; } else if( ret != POLARSSL_ERR_PEM_NO_HEADER_PRESENT ) { pem_free( &pem ); return( ret ); } p = ( ret == 0 ) ? pem.buf : (unsigned char *) dhmin; #else p = (unsigned char *) dhmin; #endif end = p + dhminlen; memset( dhm, 0, sizeof( dhm_context ) ); /* * DHParams ::= SEQUENCE { * prime INTEGER, -- P * generator INTEGER, -- g * } */ if( ( ret = asn1_get_tag( &p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } end = p + len; if( ( ret = asn1_get_mpi( &p, end, &dhm->P ) ) != 0 || ( ret = asn1_get_mpi( &p, end, &dhm->G ) ) != 0 ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif dhm_free( dhm ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + ret ); } if( p != end ) { #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif dhm_free( dhm ); return( POLARSSL_ERR_X509_KEY_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); } #if defined(POLARSSL_PEM_C) pem_free( &pem ); #endif return( 0 ); } #if defined(POLARSSL_FS_IO) /* * Load and parse a private RSA key */ int x509parse_dhmfile( dhm_context *dhm, const char *path ) { int ret; size_t n; unsigned char *buf; if ( ( ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = x509parse_dhm( dhm, buf, n ); memset( buf, 0, n + 1 ); free( buf ); return( ret ); } #endif /* POLARSSL_FS_IO */ #endif /* POLARSSL_DHM_C */ #if defined _MSC_VER && !defined snprintf #include #if !defined vsnprintf #define vsnprintf _vsnprintf #endif // vsnprintf /* * Windows _snprintf and _vsnprintf are not compatible to linux versions. * Result value is not size of buffer needed, but -1 if no fit is possible. * * This fuction tries to 'fix' this by at least suggesting enlarging the * size by 20. */ int compat_snprintf(char *str, size_t size, const char *format, ...) { va_list ap; int res = -1; va_start( ap, format ); res = vsnprintf( str, size, format, ap ); va_end( ap ); // No quick fix possible if ( res < 0 ) return( (int) size + 20 ); return res; } #define snprintf compat_snprintf #endif #define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2 #define SAFE_SNPRINTF() \ { \ if( ret == -1 ) \ return( -1 ); \ \ if ( (unsigned int) ret > n ) { \ p[n - 1] = '\0'; \ return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\ } \ \ n -= (unsigned int) ret; \ p += (unsigned int) ret; \ } /* * Store the name in printable form into buf; no more * than size characters will be written */ int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn ) { int ret; size_t i, n; unsigned char c; const x509_name *name; char s[128], *p; memset( s, 0, sizeof( s ) ); name = dn; p = buf; n = size; while( name != NULL ) { if( name != dn ) { ret = snprintf( p, n, ", " ); SAFE_SNPRINTF(); } if( memcmp( name->oid.p, OID_X520, 2 ) == 0 ) { switch( name->oid.p[2] ) { case X520_COMMON_NAME: ret = snprintf( p, n, "CN=" ); break; case X520_COUNTRY: ret = snprintf( p, n, "C=" ); break; case X520_LOCALITY: ret = snprintf( p, n, "L=" ); break; case X520_STATE: ret = snprintf( p, n, "ST=" ); break; case X520_ORGANIZATION: ret = snprintf( p, n, "O=" ); break; case X520_ORG_UNIT: ret = snprintf( p, n, "OU=" ); break; default: ret = snprintf( p, n, "0x%02X=", name->oid.p[2] ); break; } SAFE_SNPRINTF(); } else if( memcmp( name->oid.p, OID_PKCS9, 8 ) == 0 ) { switch( name->oid.p[8] ) { case PKCS9_EMAIL: ret = snprintf( p, n, "emailAddress=" ); break; default: ret = snprintf( p, n, "0x%02X=", name->oid.p[8] ); break; } SAFE_SNPRINTF(); } else { ret = snprintf( p, n, "\?\?=" ); SAFE_SNPRINTF(); } for( i = 0; i < name->val.len; i++ ) { if( i >= sizeof( s ) - 1 ) break; c = name->val.p[i]; if( c < 32 || c == 127 || ( c > 128 && c < 160 ) ) s[i] = '?'; else s[i] = c; } s[i] = '\0'; ret = snprintf( p, n, "%s", s ); SAFE_SNPRINTF(); name = name->next; } return( (int) ( size - n ) ); } /* * Store the serial in printable form into buf; no more * than size characters will be written */ int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial ) { int ret; size_t i, n, nr; char *p; p = buf; n = size; nr = ( serial->len <= 32 ) ? serial->len : 28; for( i = 0; i < nr; i++ ) { if( i == 0 && nr > 1 && serial->p[i] == 0x0 ) continue; ret = snprintf( p, n, "%02X%s", serial->p[i], ( i < nr - 1 ) ? ":" : "" ); SAFE_SNPRINTF(); } if( nr != serial->len ) { ret = snprintf( p, n, "...." ); SAFE_SNPRINTF(); } return( (int) ( size - n ) ); } /* * Return an informational string about the certificate. */ int x509parse_cert_info( char *buf, size_t size, const char *prefix, const x509_cert *crt ) { int ret; size_t n; char *p; p = buf; n = size; ret = snprintf( p, n, "%scert. version : %d\n", prefix, crt->version ); SAFE_SNPRINTF(); ret = snprintf( p, n, "%sserial number : ", prefix ); SAFE_SNPRINTF(); ret = x509parse_serial_gets( p, n, &crt->serial); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sissuer name : ", prefix ); SAFE_SNPRINTF(); ret = x509parse_dn_gets( p, n, &crt->issuer ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%ssubject name : ", prefix ); SAFE_SNPRINTF(); ret = x509parse_dn_gets( p, n, &crt->subject ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sissued on : " \ "%04d-%02d-%02d %02d:%02d:%02d", prefix, crt->valid_from.year, crt->valid_from.mon, crt->valid_from.day, crt->valid_from.hour, crt->valid_from.min, crt->valid_from.sec ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sexpires on : " \ "%04d-%02d-%02d %02d:%02d:%02d", prefix, crt->valid_to.year, crt->valid_to.mon, crt->valid_to.day, crt->valid_to.hour, crt->valid_to.min, crt->valid_to.sec ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%ssigned using : RSA+", prefix ); SAFE_SNPRINTF(); switch( crt->sig_alg ) { case SIG_RSA_MD2 : ret = snprintf( p, n, "MD2" ); break; case SIG_RSA_MD4 : ret = snprintf( p, n, "MD4" ); break; case SIG_RSA_MD5 : ret = snprintf( p, n, "MD5" ); break; case SIG_RSA_SHA1 : ret = snprintf( p, n, "SHA1" ); break; case SIG_RSA_SHA224 : ret = snprintf( p, n, "SHA224" ); break; case SIG_RSA_SHA256 : ret = snprintf( p, n, "SHA256" ); break; case SIG_RSA_SHA384 : ret = snprintf( p, n, "SHA384" ); break; case SIG_RSA_SHA512 : ret = snprintf( p, n, "SHA512" ); break; default: ret = snprintf( p, n, "???" ); break; } SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sRSA key size : %d bits\n", prefix, (int) crt->rsa.N.n * (int) sizeof( unsigned long ) * 8 ); SAFE_SNPRINTF(); return( (int) ( size - n ) ); } /* Compare a given OID string with an OID x509_buf * */ #define OID_CMP(oid_str, oid_buf) \ ( ( OID_SIZE(oid_str) == (oid_buf)->len ) && \ memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) == 0) /* * Return an informational string describing the given OID */ const char *x509_oid_get_description( x509_buf *oid ) { if ( oid == NULL ) return ( NULL ); else if( OID_CMP( OID_SERVER_AUTH, oid ) ) return( STRING_SERVER_AUTH ); else if( OID_CMP( OID_CLIENT_AUTH, oid ) ) return( STRING_CLIENT_AUTH ); else if( OID_CMP( OID_CODE_SIGNING, oid ) ) return( STRING_CODE_SIGNING ); else if( OID_CMP( OID_EMAIL_PROTECTION, oid ) ) return( STRING_EMAIL_PROTECTION ); else if( OID_CMP( OID_TIME_STAMPING, oid ) ) return( STRING_TIME_STAMPING ); else if( OID_CMP( OID_OCSP_SIGNING, oid ) ) return( STRING_OCSP_SIGNING ); return( NULL ); } /* Return the x.y.z.... style numeric string for the given OID */ int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid ) { int ret; size_t i, n; unsigned int value; char *p; p = buf; n = size; /* First byte contains first two dots */ if( oid->len > 0 ) { ret = snprintf( p, n, "%d.%d", oid->p[0]/40, oid->p[0]%40 ); SAFE_SNPRINTF(); } /* TODO: value can overflow in value. */ value = 0; for( i = 1; i < oid->len; i++ ) { value <<= 7; value += oid->p[i] & 0x7F; if( !( oid->p[i] & 0x80 ) ) { /* Last byte */ ret = snprintf( p, n, ".%d", value ); SAFE_SNPRINTF(); value = 0; } } return( (int) ( size - n ) ); } /* * Return an informational string about the CRL. */ int x509parse_crl_info( char *buf, size_t size, const char *prefix, const x509_crl *crl ) { int ret; size_t n; char *p; const x509_crl_entry *entry; p = buf; n = size; ret = snprintf( p, n, "%sCRL version : %d", prefix, crl->version ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sissuer name : ", prefix ); SAFE_SNPRINTF(); ret = x509parse_dn_gets( p, n, &crl->issuer ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%sthis update : " \ "%04d-%02d-%02d %02d:%02d:%02d", prefix, crl->this_update.year, crl->this_update.mon, crl->this_update.day, crl->this_update.hour, crl->this_update.min, crl->this_update.sec ); SAFE_SNPRINTF(); ret = snprintf( p, n, "\n%snext update : " \ "%04d-%02d-%02d %02d:%02d:%02d", prefix, crl->next_update.year, crl->next_update.mon, crl->next_update.day, crl->next_update.hour, crl->next_update.min, crl->next_update.sec ); SAFE_SNPRINTF(); entry = &crl->entry; ret = snprintf( p, n, "\n%sRevoked certificates:", prefix ); SAFE_SNPRINTF(); while( entry != NULL && entry->raw.len != 0 ) { ret = snprintf( p, n, "\n%sserial number: ", prefix ); SAFE_SNPRINTF(); ret = x509parse_serial_gets( p, n, &entry->serial); SAFE_SNPRINTF(); ret = snprintf( p, n, " revocation date: " \ "%04d-%02d-%02d %02d:%02d:%02d", entry->revocation_date.year, entry->revocation_date.mon, entry->revocation_date.day, entry->revocation_date.hour, entry->revocation_date.min, entry->revocation_date.sec ); SAFE_SNPRINTF(); entry = entry->next; } ret = snprintf( p, n, "\n%ssigned using : RSA+", prefix ); SAFE_SNPRINTF(); switch( crl->sig_alg ) { case SIG_RSA_MD2 : ret = snprintf( p, n, "MD2" ); break; case SIG_RSA_MD4 : ret = snprintf( p, n, "MD4" ); break; case SIG_RSA_MD5 : ret = snprintf( p, n, "MD5" ); break; case SIG_RSA_SHA1 : ret = snprintf( p, n, "SHA1" ); break; case SIG_RSA_SHA224 : ret = snprintf( p, n, "SHA224" ); break; case SIG_RSA_SHA256 : ret = snprintf( p, n, "SHA256" ); break; case SIG_RSA_SHA384 : ret = snprintf( p, n, "SHA384" ); break; case SIG_RSA_SHA512 : ret = snprintf( p, n, "SHA512" ); break; default: ret = snprintf( p, n, "???" ); break; } SAFE_SNPRINTF(); ret = snprintf( p, n, "\n" ); SAFE_SNPRINTF(); return( (int) ( size - n ) ); } /* * Return 0 if the x509_time is still valid, or 1 otherwise. */ int x509parse_time_expired( const x509_time *to ) { int year, mon, day; int hour, min, sec; #if defined(_WIN32) SYSTEMTIME st; GetLocalTime(&st); year = st.wYear; mon = st.wMonth; day = st.wDay; hour = st.wHour; min = st.wMinute; sec = st.wSecond; #else struct tm *lt; time_t tt; tt = time( NULL ); lt = localtime( &tt ); year = lt->tm_year + 1900; mon = lt->tm_mon + 1; day = lt->tm_mday; hour = lt->tm_hour; min = lt->tm_min; sec = lt->tm_sec; #endif if( year > to->year ) return( 1 ); if( year == to->year && mon > to->mon ) return( 1 ); if( year == to->year && mon == to->mon && day > to->day ) return( 1 ); if( year == to->year && mon == to->mon && day == to->day && hour > to->hour ) return( 1 ); if( year == to->year && mon == to->mon && day == to->day && hour == to->hour && min > to->min ) return( 1 ); if( year == to->year && mon == to->mon && day == to->day && hour == to->hour && min == to->min && sec > to->sec ) return( 1 ); return( 0 ); } /* * Return 1 if the certificate is revoked, or 0 otherwise. */ int x509parse_revoked( const x509_cert *crt, const x509_crl *crl ) { const x509_crl_entry *cur = &crl->entry; while( cur != NULL && cur->serial.len != 0 ) { if( crt->serial.len == cur->serial.len && memcmp( crt->serial.p, cur->serial.p, crt->serial.len ) == 0 ) { if( x509parse_time_expired( &cur->revocation_date ) ) return( 1 ); } cur = cur->next; } return( 0 ); } /* * Wrapper for x509 hashes. * * \param out Buffer to receive the hash (Should be at least 64 bytes) */ static void x509_hash( const unsigned char *in, size_t len, int alg, unsigned char *out ) { switch( alg ) { #if defined(POLARSSL_MD2_C) case SIG_RSA_MD2 : md2( in, len, out ); break; #endif #if defined(POLARSSL_MD4_C) case SIG_RSA_MD4 : md4( in, len, out ); break; #endif #if defined(POLARSSL_MD5_C) case SIG_RSA_MD5 : md5( in, len, out ); break; #endif #if defined(POLARSSL_SHA1_C) case SIG_RSA_SHA1 : sha1( in, len, out ); break; #endif #if defined(POLARSSL_SHA2_C) case SIG_RSA_SHA224 : sha2( in, len, out, 1 ); break; case SIG_RSA_SHA256 : sha2( in, len, out, 0 ); break; #endif #if defined(POLARSSL_SHA4_C) case SIG_RSA_SHA384 : sha4( in, len, out, 1 ); break; case SIG_RSA_SHA512 : sha4( in, len, out, 0 ); break; #endif default: memset( out, '\xFF', 64 ); break; } } /* * Check that the given certificate is valid accoring to the CRL. */ static int x509parse_verifycrl(x509_cert *crt, x509_cert *ca, x509_crl *crl_list) { int flags = 0; int hash_id; unsigned char hash[64]; /* * TODO: What happens if no CRL is present? * Suggestion: Revocation state should be unknown if no CRL is present. * For backwards compatibility this is not yet implemented. */ while( ca != NULL && crl_list != NULL && crl_list->version != 0 ) { if( crl_list->issuer_raw.len != ca->subject_raw.len || memcmp( crl_list->issuer_raw.p, ca->subject_raw.p, crl_list->issuer_raw.len ) != 0 ) { crl_list = crl_list->next; continue; } /* * Check if CRL is correctly signed by the trusted CA */ hash_id = crl_list->sig_alg; x509_hash( crl_list->tbs.p, crl_list->tbs.len, hash_id, hash ); if( !rsa_pkcs1_verify( &ca->rsa, RSA_PUBLIC, hash_id, 0, hash, crl_list->sig.p ) == 0 ) { /* * CRL is not trusted */ flags |= BADCRL_NOT_TRUSTED; break; } /* * Check for validity of CRL (Do not drop out) */ if( x509parse_time_expired( &crl_list->next_update ) ) flags |= BADCRL_EXPIRED; /* * Check if certificate is revoked */ if( x509parse_revoked(crt, crl_list) ) { flags |= BADCERT_REVOKED; break; } crl_list = crl_list->next; } return flags; } /* * Verify the certificate validity */ int x509parse_verify( x509_cert *crt, x509_cert *trust_ca, x509_crl *ca_crl, const char *cn, int *flags, int (*f_vrfy)(void *, x509_cert *, int, int), void *p_vrfy ) { size_t cn_len; int hash_id; int pathlen; x509_cert *parent; x509_name *name; unsigned char hash[64]; *flags = 0; if( x509parse_time_expired( &crt->valid_to ) ) *flags = BADCERT_EXPIRED; if( cn != NULL ) { name = &crt->subject; cn_len = strlen( cn ); while( name != NULL ) { if( memcmp( name->oid.p, OID_CN, 3 ) == 0 && memcmp( name->val.p, cn, cn_len ) == 0 && name->val.len == cn_len ) break; name = name->next; } if( name == NULL ) *flags |= BADCERT_CN_MISMATCH; } /* * Iterate upwards in the given cert chain, * ignoring any upper cert with CA != TRUE. */ parent = crt->next; pathlen = 1; while( parent != NULL && parent->version != 0 ) { if( parent->ca_istrue == 0 || crt->issuer_raw.len != parent->subject_raw.len || memcmp( crt->issuer_raw.p, parent->subject_raw.p, crt->issuer_raw.len ) != 0 ) { parent = parent->next; continue; } hash_id = crt->sig_alg; x509_hash( crt->tbs.p, crt->tbs.len, hash_id, hash ); if( rsa_pkcs1_verify( &parent->rsa, RSA_PUBLIC, hash_id, 0, hash, crt->sig.p ) != 0 ) *flags |= BADCERT_NOT_TRUSTED; /* Check trusted CA's CRL for the given crt */ *flags |= x509parse_verifycrl(crt, parent, ca_crl); /* crt is verified to be a child of the parent cur, call verify callback */ if( NULL != f_vrfy ) { if( f_vrfy( p_vrfy, crt, pathlen - 1, ( *flags == 0 ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_VERIFY_FAILED ); else *flags = 0; } else if( *flags != 0 ) return( POLARSSL_ERR_X509_CERT_VERIFY_FAILED ); pathlen++; crt = parent; parent = crt->next; } /* * Attempt to validate topmost cert with our CA chain. */ *flags |= BADCERT_NOT_TRUSTED; while( trust_ca != NULL && trust_ca->version != 0 ) { if( crt->issuer_raw.len != trust_ca->subject_raw.len || memcmp( crt->issuer_raw.p, trust_ca->subject_raw.p, crt->issuer_raw.len ) != 0 ) { trust_ca = trust_ca->next; continue; } if( trust_ca->max_pathlen > 0 && trust_ca->max_pathlen < pathlen ) break; hash_id = crt->sig_alg; x509_hash( crt->tbs.p, crt->tbs.len, hash_id, hash ); if( rsa_pkcs1_verify( &trust_ca->rsa, RSA_PUBLIC, hash_id, 0, hash, crt->sig.p ) == 0 ) { /* * cert. is signed by a trusted CA */ *flags &= ~BADCERT_NOT_TRUSTED; break; } trust_ca = trust_ca->next; } /* Check trusted CA's CRL for the given crt */ *flags |= x509parse_verifycrl( crt, trust_ca, ca_crl ); /* Verification succeeded, call callback on top cert */ if( NULL != f_vrfy ) { if( f_vrfy(p_vrfy, crt, pathlen-1, ( *flags == 0 ) ) != 0 ) return( POLARSSL_ERR_X509_CERT_VERIFY_FAILED ); else *flags = 0; } else if( *flags != 0 ) return( POLARSSL_ERR_X509_CERT_VERIFY_FAILED ); return( 0 ); } /* * Unallocate all certificate data */ void x509_free( x509_cert *crt ) { x509_cert *cert_cur = crt; x509_cert *cert_prv; x509_name *name_cur; x509_name *name_prv; x509_sequence *seq_cur; x509_sequence *seq_prv; if( crt == NULL ) return; do { rsa_free( &cert_cur->rsa ); name_cur = cert_cur->issuer.next; while( name_cur != NULL ) { name_prv = name_cur; name_cur = name_cur->next; memset( name_prv, 0, sizeof( x509_name ) ); free( name_prv ); } name_cur = cert_cur->subject.next; while( name_cur != NULL ) { name_prv = name_cur; name_cur = name_cur->next; memset( name_prv, 0, sizeof( x509_name ) ); free( name_prv ); } seq_cur = cert_cur->ext_key_usage.next; while( seq_cur != NULL ) { seq_prv = seq_cur; seq_cur = seq_cur->next; memset( seq_prv, 0, sizeof( x509_sequence ) ); free( seq_prv ); } if( cert_cur->raw.p != NULL ) { memset( cert_cur->raw.p, 0, cert_cur->raw.len ); free( cert_cur->raw.p ); } cert_cur = cert_cur->next; } while( cert_cur != NULL ); cert_cur = crt; do { cert_prv = cert_cur; cert_cur = cert_cur->next; memset( cert_prv, 0, sizeof( x509_cert ) ); if( cert_prv != crt ) free( cert_prv ); } while( cert_cur != NULL ); } /* * Unallocate all CRL data */ void x509_crl_free( x509_crl *crl ) { x509_crl *crl_cur = crl; x509_crl *crl_prv; x509_name *name_cur; x509_name *name_prv; x509_crl_entry *entry_cur; x509_crl_entry *entry_prv; if( crl == NULL ) return; do { name_cur = crl_cur->issuer.next; while( name_cur != NULL ) { name_prv = name_cur; name_cur = name_cur->next; memset( name_prv, 0, sizeof( x509_name ) ); free( name_prv ); } entry_cur = crl_cur->entry.next; while( entry_cur != NULL ) { entry_prv = entry_cur; entry_cur = entry_cur->next; memset( entry_prv, 0, sizeof( x509_crl_entry ) ); free( entry_prv ); } if( crl_cur->raw.p != NULL ) { memset( crl_cur->raw.p, 0, crl_cur->raw.len ); free( crl_cur->raw.p ); } crl_cur = crl_cur->next; } while( crl_cur != NULL ); crl_cur = crl; do { crl_prv = crl_cur; crl_cur = crl_cur->next; memset( crl_prv, 0, sizeof( x509_crl ) ); if( crl_prv != crl ) free( crl_prv ); } while( crl_cur != NULL ); } #if defined(POLARSSL_SELF_TEST) #include "polarssl/certs.h" /* * Checkup routine */ int x509_self_test( int verbose ) { #if defined(POLARSSL_CERTS_C) && defined(POLARSSL_MD5_C) int ret; int flags; size_t i, j; x509_cert cacert; x509_cert clicert; rsa_context rsa; #if defined(POLARSSL_DHM_C) dhm_context dhm; #endif if( verbose != 0 ) printf( " X.509 certificate load: " ); memset( &clicert, 0, sizeof( x509_cert ) ); ret = x509parse_crt( &clicert, (unsigned char *) test_cli_crt, strlen( test_cli_crt ) ); if( ret != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } memset( &cacert, 0, sizeof( x509_cert ) ); ret = x509parse_crt( &cacert, (unsigned char *) test_ca_crt, strlen( test_ca_crt ) ); if( ret != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n X.509 private key load: " ); i = strlen( test_ca_key ); j = strlen( test_ca_pwd ); rsa_init( &rsa, RSA_PKCS_V15, 0 ); if( ( ret = x509parse_key( &rsa, (unsigned char *) test_ca_key, i, (unsigned char *) test_ca_pwd, j ) ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n X.509 signature verify: "); ret = x509parse_verify( &clicert, &cacert, NULL, "PolarSSL Client 2", &flags, NULL, NULL ); if( ret != 0 ) { printf("%02x", flags); if( verbose != 0 ) printf( "failed\n" ); return( ret ); } #if defined(POLARSSL_DHM_C) if( verbose != 0 ) printf( "passed\n X.509 DHM parameter load: " ); i = strlen( test_dhm_params ); j = strlen( test_ca_pwd ); if( ( ret = x509parse_dhm( &dhm, (unsigned char *) test_dhm_params, i ) ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n\n" ); #endif x509_free( &cacert ); x509_free( &clicert ); rsa_free( &rsa ); #if defined(POLARSSL_DHM_C) dhm_free( &dhm ); #endif return( 0 ); #else ((void) verbose); return( POLARSSL_ERR_X509_FEATURE_UNAVAILABLE ); #endif } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/pkcs11.c0000644000014601777760000001456412165464055022557 0ustar00jenkinsnogroup00000000000000/** * \file pkcs11.c * * \brief Wrapper for PKCS#11 library libpkcs11-helper * * \author Adriaan de Jong * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/pkcs11.h" #if defined(POLARSSL_PKCS11_C) #include int pkcs11_x509_cert_init( x509_cert *cert, pkcs11h_certificate_t pkcs11_cert ) { int ret = 1; unsigned char *cert_blob = NULL; size_t cert_blob_size = 0; if( cert == NULL ) { ret = 2; goto cleanup; } if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, NULL, &cert_blob_size ) != CKR_OK ) { ret = 3; goto cleanup; } cert_blob = malloc( cert_blob_size ); if( NULL == cert_blob ) { ret = 4; goto cleanup; } if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, cert_blob, &cert_blob_size ) != CKR_OK ) { ret = 5; goto cleanup; } if( 0 != x509parse_crt(cert, cert_blob, cert_blob_size ) ) { ret = 6; goto cleanup; } ret = 0; cleanup: if( NULL != cert_blob ) free( cert_blob ); return ret; } int pkcs11_priv_key_init( pkcs11_context *priv_key, pkcs11h_certificate_t pkcs11_cert ) { int ret = 1; x509_cert cert; memset( &cert, 0, sizeof( cert ) ); if( priv_key == NULL ) goto cleanup; if( 0 != pkcs11_x509_cert_init( &cert, pkcs11_cert ) ) goto cleanup; priv_key->len = cert.rsa.len; priv_key->pkcs11h_cert = pkcs11_cert; ret = 0; cleanup: x509_free( &cert ); return ret; } void pkcs11_priv_key_free( pkcs11_context *priv_key ) { if( NULL != priv_key ) pkcs11h_certificate_freeCertificate( priv_key->pkcs11h_cert ); } int pkcs11_decrypt( pkcs11_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, unsigned int output_max_len ) { size_t input_len, output_len; if( NULL == ctx ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); if( RSA_PUBLIC == mode ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); output_len = input_len = ctx->len; if( input_len < 16 || input_len > output_max_len ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); /* Determine size of output buffer */ if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, input_len, NULL, &output_len ) != CKR_OK ) { return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } if( output_len > output_max_len ) return( POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE ); if( pkcs11h_certificate_decryptAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, input, input_len, output, &output_len ) != CKR_OK ) { return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } *olen = output_len; return( 0 ); } int pkcs11_sign( pkcs11_context *ctx, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ) { size_t olen, asn_len; unsigned char *p = sig; if( NULL == ctx ) return POLARSSL_ERR_RSA_BAD_INPUT_DATA; if( RSA_PUBLIC == mode ) return POLARSSL_ERR_RSA_BAD_INPUT_DATA; olen = ctx->len; switch( hash_id ) { case SIG_RSA_RAW: asn_len = 0; memcpy( p, hash, hashlen ); break; case SIG_RSA_MD2: asn_len = OID_SIZE(ASN1_HASH_MDX); memcpy( p, ASN1_HASH_MDX, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[13] = 2; break; case SIG_RSA_MD4: asn_len = OID_SIZE(ASN1_HASH_MDX); memcpy( p, ASN1_HASH_MDX, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[13] = 4; break; case SIG_RSA_MD5: asn_len = OID_SIZE(ASN1_HASH_MDX); memcpy( p, ASN1_HASH_MDX, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[13] = 5; break; case SIG_RSA_SHA1: asn_len = OID_SIZE(ASN1_HASH_SHA1); memcpy( p, ASN1_HASH_SHA1, asn_len ); memcpy( p + 15, hash, hashlen ); break; case SIG_RSA_SHA224: asn_len = OID_SIZE(ASN1_HASH_SHA2X); memcpy( p, ASN1_HASH_SHA2X, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[1] += hashlen; p[14] = 4; p[18] += hashlen; break; case SIG_RSA_SHA256: asn_len = OID_SIZE(ASN1_HASH_SHA2X); memcpy( p, ASN1_HASH_SHA2X, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[1] += hashlen; p[14] = 1; p[18] += hashlen; break; case SIG_RSA_SHA384: asn_len = OID_SIZE(ASN1_HASH_SHA2X); memcpy( p, ASN1_HASH_SHA2X, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[1] += hashlen; p[14] = 2; p[18] += hashlen; break; case SIG_RSA_SHA512: asn_len = OID_SIZE(ASN1_HASH_SHA2X); memcpy( p, ASN1_HASH_SHA2X, asn_len ); memcpy( p + asn_len, hash, hashlen ); p[1] += hashlen; p[14] = 3; p[18] += hashlen; break; default: return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } if( pkcs11h_certificate_signAny( ctx->pkcs11h_cert, CKM_RSA_PKCS, sig, asn_len + hashlen, sig, &olen ) != CKR_OK ) { return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } return( 0 ); } #endif /* defined(POLARSSL_PKCS11_C) */ pdns-3.3/pdns/ext/polarssl-1.1.2/library/ssl_srv.c0000644000014601777760000007231312165464055023144 0ustar00jenkinsnogroup00000000000000/* * SSLv3/TLSv1 server-side functions * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_SSL_SRV_C) #include "polarssl/debug.h" #include "polarssl/ssl.h" #if defined(POLARSSL_PKCS11_C) #include "polarssl/pkcs11.h" #endif /* defined(POLARSSL_PKCS11_C) */ #include #include #include static int ssl_parse_client_hello( ssl_context *ssl ) { int ret; unsigned int i, j; size_t n; unsigned int ciph_len, sess_len; unsigned int chal_len, comp_len; unsigned char *buf, *p; SSL_DEBUG_MSG( 2, ( "=> parse client hello" ) ); if( ( ret = ssl_fetch_input( ssl, 5 ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); return( ret ); } buf = ssl->in_hdr; if( ( buf[0] & 0x80 ) != 0 ) { SSL_DEBUG_BUF( 4, "record header", buf, 5 ); SSL_DEBUG_MSG( 3, ( "client hello v2, message type: %d", buf[2] ) ); SSL_DEBUG_MSG( 3, ( "client hello v2, message len.: %d", ( ( buf[0] & 0x7F ) << 8 ) | buf[1] ) ); SSL_DEBUG_MSG( 3, ( "client hello v2, max. version: [%d:%d]", buf[3], buf[4] ) ); /* * SSLv2 Client Hello * * Record layer: * 0 . 1 message length * * SSL layer: * 2 . 2 message type * 3 . 4 protocol version */ if( buf[2] != SSL_HS_CLIENT_HELLO || buf[3] != SSL_MAJOR_VERSION_3 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } n = ( ( buf[0] << 8 ) | buf[1] ) & 0x7FFF; if( n < 17 || n > 512 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } ssl->max_major_ver = buf[3]; ssl->max_minor_ver = buf[4]; ssl->major_ver = SSL_MAJOR_VERSION_3; ssl->minor_ver = ( buf[4] <= SSL_MINOR_VERSION_2 ) ? buf[4] : SSL_MINOR_VERSION_2; if( ( ret = ssl_fetch_input( ssl, 2 + n ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); return( ret ); } md5_update( &ssl->fin_md5 , buf + 2, n ); sha1_update( &ssl->fin_sha1, buf + 2, n ); buf = ssl->in_msg; n = ssl->in_left - 5; /* * 0 . 1 ciphersuitelist length * 2 . 3 session id length * 4 . 5 challenge length * 6 . .. ciphersuitelist * .. . .. session id * .. . .. challenge */ SSL_DEBUG_BUF( 4, "record contents", buf, n ); ciph_len = ( buf[0] << 8 ) | buf[1]; sess_len = ( buf[2] << 8 ) | buf[3]; chal_len = ( buf[4] << 8 ) | buf[5]; SSL_DEBUG_MSG( 3, ( "ciph_len: %d, sess_len: %d, chal_len: %d", ciph_len, sess_len, chal_len ) ); /* * Make sure each parameter length is valid */ if( ciph_len < 3 || ( ciph_len % 3 ) != 0 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } if( sess_len > 32 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } if( chal_len < 8 || chal_len > 32 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } if( n != 6 + ciph_len + sess_len + chal_len ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", buf + 6, ciph_len ); SSL_DEBUG_BUF( 3, "client hello, session id", buf + 6 + ciph_len, sess_len ); SSL_DEBUG_BUF( 3, "client hello, challenge", buf + 6 + ciph_len + sess_len, chal_len ); p = buf + 6 + ciph_len; ssl->session->length = sess_len; memset( ssl->session->id, 0, sizeof( ssl->session->id ) ); memcpy( ssl->session->id, p, ssl->session->length ); p += sess_len; memset( ssl->randbytes, 0, 64 ); memcpy( ssl->randbytes + 32 - chal_len, p, chal_len ); for( i = 0; ssl->ciphersuites[i] != 0; i++ ) { for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 ) { if( p[0] == 0 && p[1] == 0 && p[2] == ssl->ciphersuites[i] ) goto have_ciphersuite; } } } else { SSL_DEBUG_BUF( 4, "record header", buf, 5 ); SSL_DEBUG_MSG( 3, ( "client hello v3, message type: %d", buf[0] ) ); SSL_DEBUG_MSG( 3, ( "client hello v3, message len.: %d", ( buf[3] << 8 ) | buf[4] ) ); SSL_DEBUG_MSG( 3, ( "client hello v3, protocol ver: [%d:%d]", buf[1], buf[2] ) ); /* * SSLv3 Client Hello * * Record layer: * 0 . 0 message type * 1 . 2 protocol version * 3 . 4 message length */ if( buf[0] != SSL_MSG_HANDSHAKE || buf[1] != SSL_MAJOR_VERSION_3 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } n = ( buf[3] << 8 ) | buf[4]; if( n < 45 || n > 512 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } if( ( ret = ssl_fetch_input( ssl, 5 + n ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); return( ret ); } buf = ssl->in_msg; n = ssl->in_left - 5; md5_update( &ssl->fin_md5 , buf, n ); sha1_update( &ssl->fin_sha1, buf, n ); /* * SSL layer: * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 5 protocol version * 6 . 9 UNIX time() * 10 . 37 random bytes * 38 . 38 session id length * 39 . 38+x session id * 39+x . 40+x ciphersuitelist length * 41+x . .. ciphersuitelist * .. . .. compression alg. * .. . .. extensions */ SSL_DEBUG_BUF( 4, "record contents", buf, n ); SSL_DEBUG_MSG( 3, ( "client hello v3, handshake type: %d", buf[0] ) ); SSL_DEBUG_MSG( 3, ( "client hello v3, handshake len.: %d", ( buf[1] << 16 ) | ( buf[2] << 8 ) | buf[3] ) ); SSL_DEBUG_MSG( 3, ( "client hello v3, max. version: [%d:%d]", buf[4], buf[5] ) ); /* * Check the handshake type and protocol version */ if( buf[0] != SSL_HS_CLIENT_HELLO || buf[4] != SSL_MAJOR_VERSION_3 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } ssl->major_ver = SSL_MAJOR_VERSION_3; ssl->minor_ver = ( buf[5] <= SSL_MINOR_VERSION_2 ) ? buf[5] : SSL_MINOR_VERSION_2; ssl->max_major_ver = buf[4]; ssl->max_minor_ver = buf[5]; memcpy( ssl->randbytes, buf + 6, 32 ); /* * Check the handshake message length */ if( buf[1] != 0 || n != (unsigned int) 4 + ( ( buf[2] << 8 ) | buf[3] ) ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } /* * Check the session length */ sess_len = buf[38]; if( sess_len > 32 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } ssl->session->length = sess_len; memset( ssl->session->id, 0, sizeof( ssl->session->id ) ); memcpy( ssl->session->id, buf + 39 , ssl->session->length ); /* * Check the ciphersuitelist length */ ciph_len = ( buf[39 + sess_len] << 8 ) | ( buf[40 + sess_len] ); if( ciph_len < 2 || ciph_len > 256 || ( ciph_len % 2 ) != 0 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } /* * Check the compression algorithms length */ comp_len = buf[41 + sess_len + ciph_len]; if( comp_len < 1 || comp_len > 16 ) { SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO ); } SSL_DEBUG_BUF( 3, "client hello, random bytes", buf + 6, 32 ); SSL_DEBUG_BUF( 3, "client hello, session id", buf + 38, sess_len ); SSL_DEBUG_BUF( 3, "client hello, ciphersuitelist", buf + 41 + sess_len, ciph_len ); SSL_DEBUG_BUF( 3, "client hello, compression", buf + 42 + sess_len + ciph_len, comp_len ); /* * Search for a matching ciphersuite */ for( i = 0; ssl->ciphersuites[i] != 0; i++ ) { for( j = 0, p = buf + 41 + sess_len; j < ciph_len; j += 2, p += 2 ) { if( p[0] == 0 && p[1] == ssl->ciphersuites[i] ) goto have_ciphersuite; } } } SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) ); return( POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN ); have_ciphersuite: ssl->session->ciphersuite = ssl->ciphersuites[i]; ssl->in_left = 0; ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) ); return( 0 ); } static int ssl_write_server_hello( ssl_context *ssl ) { time_t t; int ret, n; unsigned char *buf, *p; SSL_DEBUG_MSG( 2, ( "=> write server hello" ) ); /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 5 protocol version * 6 . 9 UNIX time() * 10 . 37 random bytes */ buf = ssl->out_msg; p = buf + 4; *p++ = (unsigned char) ssl->major_ver; *p++ = (unsigned char) ssl->minor_ver; SSL_DEBUG_MSG( 3, ( "server hello, chosen version: [%d:%d]", buf[4], buf[5] ) ); t = time( NULL ); *p++ = (unsigned char)( t >> 24 ); *p++ = (unsigned char)( t >> 16 ); *p++ = (unsigned char)( t >> 8 ); *p++ = (unsigned char)( t ); SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) ); if( ( ret = ssl->f_rng( ssl->p_rng, p, 28 ) ) != 0 ) return( ret ); p += 28; memcpy( ssl->randbytes + 32, buf + 6, 32 ); SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 6, 32 ); /* * 38 . 38 session id length * 39 . 38+n session id * 39+n . 40+n chosen ciphersuite * 41+n . 41+n chosen compression alg. */ ssl->session->length = n = 32; *p++ = (unsigned char) ssl->session->length; if( ssl->s_get == NULL || ssl->s_get( ssl ) != 0 ) { /* * Not found, create a new session id */ ssl->resume = 0; ssl->state++; if( ssl->session == NULL ) { SSL_DEBUG_MSG( 1, ( "No session struct set" ) ); return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); } if( ( ret = ssl->f_rng( ssl->p_rng, ssl->session->id, n ) ) != 0 ) return( ret ); } else { /* * Found a matching session, resume it */ ssl->resume = 1; ssl->state = SSL_SERVER_CHANGE_CIPHER_SPEC; if( ( ret = ssl_derive_keys( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_derive_keys", ret ); return( ret ); } } memcpy( p, ssl->session->id, ssl->session->length ); p += ssl->session->length; SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); SSL_DEBUG_MSG( 3, ( "%s session has been resumed", ssl->resume ? "a" : "no" ) ); *p++ = (unsigned char)( ssl->session->ciphersuite >> 8 ); *p++ = (unsigned char)( ssl->session->ciphersuite ); *p++ = SSL_COMPRESS_NULL; SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %d", ssl->session->ciphersuite ) ); SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", 0 ) ); ssl->out_msglen = p - buf; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_SERVER_HELLO; ret = ssl_write_record( ssl ); SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); return( ret ); } static int ssl_write_certificate_request( ssl_context *ssl ) { int ret; size_t n; unsigned char *buf, *p; const x509_cert *crt; SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) ); ssl->state++; if( ssl->authmode == SSL_VERIFY_NONE ) { SSL_DEBUG_MSG( 2, ( "<= skip write certificate request" ) ); return( 0 ); } /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 4 cert type count * 5 .. n-1 cert types * n .. n+1 length of all DNs * n+2 .. n+3 length of DN 1 * n+4 .. ... Distinguished Name #1 * ... .. ... length of DN 2, etc. */ buf = ssl->out_msg; p = buf + 4; /* * At the moment, only RSA certificates are supported */ *p++ = 1; *p++ = 1; p += 2; crt = ssl->ca_chain; while( crt != NULL ) { if( p - buf > 4096 ) break; n = crt->subject_raw.len; *p++ = (unsigned char)( n >> 8 ); *p++ = (unsigned char)( n ); memcpy( p, crt->subject_raw.p, n ); SSL_DEBUG_BUF( 3, "requested DN", p, n ); p += n; crt = crt->next; } ssl->out_msglen = n = p - buf; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_CERTIFICATE_REQUEST; ssl->out_msg[6] = (unsigned char)( ( n - 8 ) >> 8 ); ssl->out_msg[7] = (unsigned char)( ( n - 8 ) ); ret = ssl_write_record( ssl ); SSL_DEBUG_MSG( 2, ( "<= write certificate request" ) ); return( ret ); } static int ssl_write_server_key_exchange( ssl_context *ssl ) { #if defined(POLARSSL_DHM_C) int ret; size_t n, rsa_key_len = 0; unsigned char hash[36]; md5_context md5; sha1_context sha1; #endif SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); if( ssl->session->ciphersuite != SSL_EDH_RSA_DES_168_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_AES_128_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_AES_256_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_CAMELLIA_128_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_CAMELLIA_256_SHA) { SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); ssl->state++; return( 0 ); } #if !defined(POLARSSL_DHM_C) SSL_DEBUG_MSG( 1, ( "support for dhm is not available" ) ); return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #else if( ssl->rsa_key == NULL ) { #if defined(POLARSSL_PKCS11_C) if( ssl->pkcs11_key == NULL ) { #endif /* defined(POLARSSL_PKCS11_C) */ SSL_DEBUG_MSG( 1, ( "got no private key" ) ); return( POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED ); #if defined(POLARSSL_PKCS11_C) } #endif /* defined(POLARSSL_PKCS11_C) */ } /* * Ephemeral DH parameters: * * struct { * opaque dh_p<1..2^16-1>; * opaque dh_g<1..2^16-1>; * opaque dh_Ys<1..2^16-1>; * } ServerDHParams; */ if( ( ret = dhm_make_params( &ssl->dhm_ctx, 256, ssl->out_msg + 4, &n, ssl->f_rng, ssl->p_rng ) ) != 0 ) { SSL_DEBUG_RET( 1, "dhm_make_params", ret ); return( ret ); } SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->dhm_ctx.X ); SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->dhm_ctx.P ); SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->dhm_ctx.G ); SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->dhm_ctx.GX ); /* * digitally-signed struct { * opaque md5_hash[16]; * opaque sha_hash[20]; * }; * * md5_hash * MD5(ClientHello.random + ServerHello.random * + ServerParams); * sha_hash * SHA(ClientHello.random + ServerHello.random * + ServerParams); */ md5_starts( &md5 ); md5_update( &md5, ssl->randbytes, 64 ); md5_update( &md5, ssl->out_msg + 4, n ); md5_finish( &md5, hash ); sha1_starts( &sha1 ); sha1_update( &sha1, ssl->randbytes, 64 ); sha1_update( &sha1, ssl->out_msg + 4, n ); sha1_finish( &sha1, hash + 16 ); SSL_DEBUG_BUF( 3, "parameters hash", hash, 36 ); if ( ssl->rsa_key ) rsa_key_len = ssl->rsa_key->len; #if defined(POLARSSL_PKCS11_C) else rsa_key_len = ssl->pkcs11_key->len; #endif /* defined(POLARSSL_PKCS11_C) */ ssl->out_msg[4 + n] = (unsigned char)( rsa_key_len >> 8 ); ssl->out_msg[5 + n] = (unsigned char)( rsa_key_len ); if ( ssl->rsa_key ) { ret = rsa_pkcs1_sign( ssl->rsa_key, ssl->f_rng, ssl->p_rng, RSA_PRIVATE, SIG_RSA_RAW, 36, hash, ssl->out_msg + 6 + n ); } #if defined(POLARSSL_PKCS11_C) else { ret = pkcs11_sign( ssl->pkcs11_key, RSA_PRIVATE, SIG_RSA_RAW, 36, hash, ssl->out_msg + 6 + n ); } #endif /* defined(POLARSSL_PKCS11_C) */ if( ret != 0 ) { SSL_DEBUG_RET( 1, "pkcs1_sign", ret ); return( ret ); } SSL_DEBUG_BUF( 3, "my RSA sig", ssl->out_msg + 6 + n, rsa_key_len ); ssl->out_msglen = 6 + n + rsa_key_len; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_SERVER_KEY_EXCHANGE; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write server key exchange" ) ); return( 0 ); #endif } static int ssl_write_server_hello_done( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> write server hello done" ) ); ssl->out_msglen = 4; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_SERVER_HELLO_DONE; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write server hello done" ) ); return( 0 ); } static int ssl_parse_client_key_exchange( ssl_context *ssl ) { int ret; size_t i, n = 0; SSL_DEBUG_MSG( 2, ( "=> parse client key exchange" ) ); if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } if( ssl->in_msg[0] != SSL_HS_CLIENT_KEY_EXCHANGE ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } if( ssl->session->ciphersuite == SSL_EDH_RSA_DES_168_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_256_SHA) { #if !defined(POLARSSL_DHM_C) SSL_DEBUG_MSG( 1, ( "support for dhm is not available" ) ); return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #else /* * Receive G^Y mod P, premaster = (G^Y)^X mod P */ n = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5]; if( n < 1 || n > ssl->dhm_ctx.len || n + 6 != ssl->in_hslen ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } if( ( ret = dhm_read_public( &ssl->dhm_ctx, ssl->in_msg + 6, n ) ) != 0 ) { SSL_DEBUG_RET( 1, "dhm_read_public", ret ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP ); } SSL_DEBUG_MPI( 3, "DHM: GY", &ssl->dhm_ctx.GY ); ssl->pmslen = ssl->dhm_ctx.len; if( ( ret = dhm_calc_secret( &ssl->dhm_ctx, ssl->premaster, &ssl->pmslen ) ) != 0 ) { SSL_DEBUG_RET( 1, "dhm_calc_secret", ret ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS ); } SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->dhm_ctx.K ); #endif } else { if( ssl->rsa_key == NULL ) { #if defined(POLARSSL_PKCS11_C) if( ssl->pkcs11_key == NULL ) { #endif SSL_DEBUG_MSG( 1, ( "got no private key" ) ); return( POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED ); #if defined(POLARSSL_PKCS11_C) } #endif } /* * Decrypt the premaster using own private RSA key */ i = 4; if( ssl->rsa_key ) n = ssl->rsa_key->len; #if defined(POLARSSL_PKCS11_C) else n = ssl->pkcs11_key->len; #endif ssl->pmslen = 48; if( ssl->minor_ver != SSL_MINOR_VERSION_0 ) { i += 2; if( ssl->in_msg[4] != ( ( n >> 8 ) & 0xFF ) || ssl->in_msg[5] != ( ( n ) & 0xFF ) ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } } if( ssl->in_hslen != i + n ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } if( ssl->rsa_key ) { ret = rsa_pkcs1_decrypt( ssl->rsa_key, RSA_PRIVATE, &ssl->pmslen, ssl->in_msg + i, ssl->premaster, sizeof(ssl->premaster) ); } #if defined(POLARSSL_PKCS11_C) else { ret = pkcs11_decrypt( ssl->pkcs11_key, RSA_PRIVATE, &ssl->pmslen, ssl->in_msg + i, ssl->premaster, sizeof(ssl->premaster) ); } #endif /* defined(POLARSSL_PKCS11_C) */ if( ret != 0 || ssl->pmslen != 48 || ssl->premaster[0] != ssl->max_major_ver || ssl->premaster[1] != ssl->max_minor_ver ) { SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); /* * Protection against Bleichenbacher's attack: * invalid PKCS#1 v1.5 padding must not cause * the connection to end immediately; instead, * send a bad_record_mac later in the handshake. */ ssl->pmslen = 48; ret = ssl->f_rng( ssl->p_rng, ssl->premaster, ssl->pmslen ); if( ret != 0 ) return( ret ); } } if( ( ret = ssl_derive_keys( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_derive_keys", ret ); return( ret ); } if( ssl->s_set != NULL ) ssl->s_set( ssl ); ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse client key exchange" ) ); return( 0 ); } static int ssl_parse_certificate_verify( ssl_context *ssl ) { int ret; size_t n1, n2; unsigned char hash[36]; SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); if( ssl->peer_cert == NULL ) { SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); ssl->state++; return( 0 ); } ssl_calc_verify( ssl, hash ); if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } ssl->state++; if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); } if( ssl->in_msg[0] != SSL_HS_CERTIFICATE_VERIFY ) { SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); } n1 = ssl->peer_cert->rsa.len; n2 = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5]; if( n1 + 6 != ssl->in_hslen || n1 != n2 ) { SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY ); } ret = rsa_pkcs1_verify( &ssl->peer_cert->rsa, RSA_PUBLIC, SIG_RSA_RAW, 36, hash, ssl->in_msg + 6 ); if( ret != 0 ) { SSL_DEBUG_RET( 1, "rsa_pkcs1_verify", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); return( 0 ); } /* * SSL handshake -- server side */ int ssl_handshake_server( ssl_context *ssl ) { int ret = 0; SSL_DEBUG_MSG( 2, ( "=> handshake server" ) ); while( ssl->state != SSL_HANDSHAKE_OVER ) { SSL_DEBUG_MSG( 2, ( "server state: %d", ssl->state ) ); if( ( ret = ssl_flush_output( ssl ) ) != 0 ) break; switch( ssl->state ) { case SSL_HELLO_REQUEST: ssl->state = SSL_CLIENT_HELLO; break; /* * <== ClientHello */ case SSL_CLIENT_HELLO: ret = ssl_parse_client_hello( ssl ); break; /* * ==> ServerHello * Certificate * ( ServerKeyExchange ) * ( CertificateRequest ) * ServerHelloDone */ case SSL_SERVER_HELLO: ret = ssl_write_server_hello( ssl ); break; case SSL_SERVER_CERTIFICATE: ret = ssl_write_certificate( ssl ); break; case SSL_SERVER_KEY_EXCHANGE: ret = ssl_write_server_key_exchange( ssl ); break; case SSL_CERTIFICATE_REQUEST: ret = ssl_write_certificate_request( ssl ); break; case SSL_SERVER_HELLO_DONE: ret = ssl_write_server_hello_done( ssl ); break; /* * <== ( Certificate/Alert ) * ClientKeyExchange * ( CertificateVerify ) * ChangeCipherSpec * Finished */ case SSL_CLIENT_CERTIFICATE: ret = ssl_parse_certificate( ssl ); break; case SSL_CLIENT_KEY_EXCHANGE: ret = ssl_parse_client_key_exchange( ssl ); break; case SSL_CERTIFICATE_VERIFY: ret = ssl_parse_certificate_verify( ssl ); break; case SSL_CLIENT_CHANGE_CIPHER_SPEC: ret = ssl_parse_change_cipher_spec( ssl ); break; case SSL_CLIENT_FINISHED: ret = ssl_parse_finished( ssl ); break; /* * ==> ChangeCipherSpec * Finished */ case SSL_SERVER_CHANGE_CIPHER_SPEC: ret = ssl_write_change_cipher_spec( ssl ); break; case SSL_SERVER_FINISHED: ret = ssl_write_finished( ssl ); break; case SSL_FLUSH_BUFFERS: SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); ssl->state = SSL_HANDSHAKE_OVER; break; default: SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); } if( ret != 0 ) break; } SSL_DEBUG_MSG( 2, ( "<= handshake server" ) ); return( ret ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/ssl_cli.c0000644000014601777760000005546012165464055023105 0ustar00jenkinsnogroup00000000000000/* * SSLv3/TLSv1 client-side functions * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_SSL_CLI_C) #include "polarssl/debug.h" #include "polarssl/ssl.h" #if defined(POLARSSL_PKCS11_C) #include "polarssl/pkcs11.h" #endif /* defined(POLARSSL_PKCS11_C) */ #include #include #include static int ssl_write_client_hello( ssl_context *ssl ) { int ret; size_t i, n; unsigned char *buf; unsigned char *p; time_t t; SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); ssl->major_ver = SSL_MAJOR_VERSION_3; ssl->minor_ver = SSL_MINOR_VERSION_0; if( ssl->max_major_ver == 0 && ssl->max_minor_ver == 0 ) { ssl->max_major_ver = SSL_MAJOR_VERSION_3; ssl->max_minor_ver = SSL_MINOR_VERSION_2; } /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 5 highest version supported * 6 . 9 current UNIX time * 10 . 37 random bytes */ buf = ssl->out_msg; p = buf + 4; *p++ = (unsigned char) ssl->max_major_ver; *p++ = (unsigned char) ssl->max_minor_ver; SSL_DEBUG_MSG( 3, ( "client hello, max version: [%d:%d]", buf[4], buf[5] ) ); t = time( NULL ); *p++ = (unsigned char)( t >> 24 ); *p++ = (unsigned char)( t >> 16 ); *p++ = (unsigned char)( t >> 8 ); *p++ = (unsigned char)( t ); SSL_DEBUG_MSG( 3, ( "client hello, current time: %lu", t ) ); if( ( ret = ssl->f_rng( ssl->p_rng, p, 28 ) ) != 0 ) return( ret ); p += 28; memcpy( ssl->randbytes, buf + 6, 32 ); SSL_DEBUG_BUF( 3, "client hello, random bytes", buf + 6, 32 ); /* * 38 . 38 session id length * 39 . 39+n session id * 40+n . 41+n ciphersuitelist length * 42+n . .. ciphersuitelist * .. . .. compression alg. (0) * .. . .. extensions (unused) */ n = ssl->session->length; if( n < 16 || n > 32 || ssl->resume == 0 || ( ssl->timeout != 0 && t - ssl->session->start > ssl->timeout ) ) n = 0; *p++ = (unsigned char) n; for( i = 0; i < n; i++ ) *p++ = ssl->session->id[i]; SSL_DEBUG_MSG( 3, ( "client hello, session id len.: %d", n ) ); SSL_DEBUG_BUF( 3, "client hello, session id", buf + 39, n ); for( n = 0; ssl->ciphersuites[n] != 0; n++ ); *p++ = (unsigned char)( n >> 7 ); *p++ = (unsigned char)( n << 1 ); SSL_DEBUG_MSG( 3, ( "client hello, got %d ciphersuites", n ) ); for( i = 0; i < n; i++ ) { SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %2d", ssl->ciphersuites[i] ) ); *p++ = (unsigned char)( ssl->ciphersuites[i] >> 8 ); *p++ = (unsigned char)( ssl->ciphersuites[i] ); } SSL_DEBUG_MSG( 3, ( "client hello, compress len.: %d", 1 ) ); SSL_DEBUG_MSG( 3, ( "client hello, compress alg.: %d", 0 ) ); *p++ = 1; *p++ = SSL_COMPRESS_NULL; if ( ssl->hostname != NULL ) { SSL_DEBUG_MSG( 3, ( "client hello, server name extension: %s", ssl->hostname ) ); *p++ = (unsigned char)( ( (ssl->hostname_len + 9) >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( (ssl->hostname_len + 9) ) & 0xFF ); *p++ = (unsigned char)( ( TLS_EXT_SERVERNAME >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( TLS_EXT_SERVERNAME ) & 0xFF ); *p++ = (unsigned char)( ( (ssl->hostname_len + 5) >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( (ssl->hostname_len + 5) ) & 0xFF ); *p++ = (unsigned char)( ( (ssl->hostname_len + 3) >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( (ssl->hostname_len + 3) ) & 0xFF ); *p++ = (unsigned char)( ( TLS_EXT_SERVERNAME_HOSTNAME ) & 0xFF ); *p++ = (unsigned char)( ( ssl->hostname_len >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( ssl->hostname_len ) & 0xFF ); memcpy( p, ssl->hostname, ssl->hostname_len ); p += ssl->hostname_len; } ssl->out_msglen = p - buf; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_CLIENT_HELLO; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); return( 0 ); } static int ssl_parse_server_hello( ssl_context *ssl ) { #if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C) time_t t; #endif int ret, i; size_t n; int ext_len; unsigned char *buf; SSL_DEBUG_MSG( 2, ( "=> parse server hello" ) ); /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 5 protocol version * 6 . 9 UNIX time() * 10 . 37 random bytes */ buf = ssl->in_msg; if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } SSL_DEBUG_MSG( 3, ( "server hello, chosen version: [%d:%d]", buf[4], buf[5] ) ); if( ssl->in_hslen < 42 || buf[0] != SSL_HS_SERVER_HELLO || buf[4] != SSL_MAJOR_VERSION_3 ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO ); } if( buf[5] > ssl->max_minor_ver ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO ); } ssl->minor_ver = buf[5]; #if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C) t = ( (time_t) buf[6] << 24 ) | ( (time_t) buf[7] << 16 ) | ( (time_t) buf[8] << 8 ) | ( (time_t) buf[9] ); #endif memcpy( ssl->randbytes + 32, buf + 6, 32 ); n = buf[38]; SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) ); SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 6, 32 ); /* * 38 . 38 session id length * 39 . 38+n session id * 39+n . 40+n chosen ciphersuite * 41+n . 41+n chosen compression alg. * 42+n . 43+n extensions length * 44+n . 44+n+m extensions */ if( n > 32 || ssl->in_hslen > 42 + n ) { ext_len = ( ( buf[42 + n] << 8 ) | ( buf[43 + n] ) ) + 2; } else { ext_len = 0; } if( n > 32 || ssl->in_hslen != 42 + n + ext_len ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO ); } i = ( buf[39 + n] << 8 ) | buf[40 + n]; SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); /* * Check if the session can be resumed */ if( ssl->resume == 0 || n == 0 || ssl->session->ciphersuite != i || ssl->session->length != n || memcmp( ssl->session->id, buf + 39, n ) != 0 ) { ssl->state++; ssl->resume = 0; ssl->session->start = time( NULL ); ssl->session->ciphersuite = i; ssl->session->length = n; memcpy( ssl->session->id, buf + 39, n ); } else { ssl->state = SSL_SERVER_CHANGE_CIPHER_SPEC; if( ( ret = ssl_derive_keys( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_derive_keys", ret ); return( ret ); } } SSL_DEBUG_MSG( 3, ( "%s session has been resumed", ssl->resume ? "a" : "no" ) ); SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %d", i ) ); SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", buf[41 + n] ) ); i = 0; while( 1 ) { if( ssl->ciphersuites[i] == 0 ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO ); } if( ssl->ciphersuites[i++] == ssl->session->ciphersuite ) break; } if( buf[41 + n] != SSL_COMPRESS_NULL ) { SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO ); } /* TODO: Process extensions */ SSL_DEBUG_MSG( 2, ( "<= parse server hello" ) ); return( 0 ); } static int ssl_parse_server_key_exchange( ssl_context *ssl ) { #if defined(POLARSSL_DHM_C) int ret; size_t n; unsigned char *p, *end; unsigned char hash[36]; md5_context md5; sha1_context sha1; #endif SSL_DEBUG_MSG( 2, ( "=> parse server key exchange" ) ); if( ssl->session->ciphersuite != SSL_EDH_RSA_DES_168_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_AES_128_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_AES_256_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_CAMELLIA_128_SHA && ssl->session->ciphersuite != SSL_EDH_RSA_CAMELLIA_256_SHA) { SSL_DEBUG_MSG( 2, ( "<= skip parse server key exchange" ) ); ssl->state++; return( 0 ); } #if !defined(POLARSSL_DHM_C) SSL_DEBUG_MSG( 1, ( "support for dhm in not available" ) ); return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #else if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } if( ssl->in_msg[0] != SSL_HS_SERVER_KEY_EXCHANGE ) { SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } /* * Ephemeral DH parameters: * * struct { * opaque dh_p<1..2^16-1>; * opaque dh_g<1..2^16-1>; * opaque dh_Ys<1..2^16-1>; * } ServerDHParams; */ p = ssl->in_msg + 4; end = ssl->in_msg + ssl->in_hslen; if( ( ret = dhm_read_params( &ssl->dhm_ctx, &p, end ) ) != 0 ) { SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } if( (unsigned int)( end - p ) != ssl->peer_cert->rsa.len ) { SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } if( ssl->dhm_ctx.len < 64 || ssl->dhm_ctx.len > 512 ) { SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->dhm_ctx.P ); SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->dhm_ctx.G ); SSL_DEBUG_MPI( 3, "DHM: GY", &ssl->dhm_ctx.GY ); /* * digitally-signed struct { * opaque md5_hash[16]; * opaque sha_hash[20]; * }; * * md5_hash * MD5(ClientHello.random + ServerHello.random * + ServerParams); * sha_hash * SHA(ClientHello.random + ServerHello.random * + ServerParams); */ n = ssl->in_hslen - ( end - p ) - 6; md5_starts( &md5 ); md5_update( &md5, ssl->randbytes, 64 ); md5_update( &md5, ssl->in_msg + 4, n ); md5_finish( &md5, hash ); sha1_starts( &sha1 ); sha1_update( &sha1, ssl->randbytes, 64 ); sha1_update( &sha1, ssl->in_msg + 4, n ); sha1_finish( &sha1, hash + 16 ); SSL_DEBUG_BUF( 3, "parameters hash", hash, 36 ); if( ( ret = rsa_pkcs1_verify( &ssl->peer_cert->rsa, RSA_PUBLIC, SIG_RSA_RAW, 36, hash, p ) ) != 0 ) { SSL_DEBUG_RET( 1, "rsa_pkcs1_verify", ret ); return( ret ); } ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse server key exchange" ) ); return( 0 ); #endif } static int ssl_parse_certificate_request( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) ); /* * 0 . 0 handshake type * 1 . 3 handshake length * 4 . 5 SSL version * 6 . 6 cert type count * 7 .. n-1 cert types * n .. n+1 length of all DNs * n+2 .. n+3 length of DN 1 * n+4 .. ... Distinguished Name #1 * ... .. ... length of DN 2, etc. */ if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } ssl->client_auth = 0; ssl->state++; if( ssl->in_msg[0] == SSL_HS_CERTIFICATE_REQUEST ) ssl->client_auth++; SSL_DEBUG_MSG( 3, ( "got %s certificate request", ssl->client_auth ? "a" : "no" ) ); SSL_DEBUG_MSG( 2, ( "<= parse certificate request" ) ); return( 0 ); } static int ssl_parse_server_hello_done( ssl_context *ssl ) { int ret; SSL_DEBUG_MSG( 2, ( "=> parse server hello done" ) ); if( ssl->client_auth != 0 ) { if( ( ret = ssl_read_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_read_record", ret ); return( ret ); } if( ssl->in_msgtype != SSL_MSG_HANDSHAKE ) { SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) ); return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE ); } } if( ssl->in_hslen != 4 || ssl->in_msg[0] != SSL_HS_SERVER_HELLO_DONE ) { SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) ); return( POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE ); } ssl->state++; SSL_DEBUG_MSG( 2, ( "<= parse server hello done" ) ); return( 0 ); } static int ssl_write_client_key_exchange( ssl_context *ssl ) { int ret; size_t i, n; SSL_DEBUG_MSG( 2, ( "=> write client key exchange" ) ); if( ssl->session->ciphersuite == SSL_EDH_RSA_DES_168_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_AES_256_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_128_SHA || ssl->session->ciphersuite == SSL_EDH_RSA_CAMELLIA_256_SHA) { #if !defined(POLARSSL_DHM_C) SSL_DEBUG_MSG( 1, ( "support for dhm in not available" ) ); return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE ); #else /* * DHM key exchange -- send G^X mod P */ n = ssl->dhm_ctx.len; ssl->out_msg[4] = (unsigned char)( n >> 8 ); ssl->out_msg[5] = (unsigned char)( n ); i = 6; ret = dhm_make_public( &ssl->dhm_ctx, 256, &ssl->out_msg[i], n, ssl->f_rng, ssl->p_rng ); if( ret != 0 ) { SSL_DEBUG_RET( 1, "dhm_make_public", ret ); return( ret ); } SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->dhm_ctx.X ); SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->dhm_ctx.GX ); ssl->pmslen = ssl->dhm_ctx.len; if( ( ret = dhm_calc_secret( &ssl->dhm_ctx, ssl->premaster, &ssl->pmslen ) ) != 0 ) { SSL_DEBUG_RET( 1, "dhm_calc_secret", ret ); return( ret ); } SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->dhm_ctx.K ); #endif } else { /* * RSA key exchange -- send rsa_public(pkcs1 v1.5(premaster)) */ ssl->premaster[0] = (unsigned char) ssl->max_major_ver; ssl->premaster[1] = (unsigned char) ssl->max_minor_ver; ssl->pmslen = 48; ret = ssl->f_rng( ssl->p_rng, ssl->premaster + 2, ssl->pmslen - 2 ); if( ret != 0 ) return( ret ); i = 4; n = ssl->peer_cert->rsa.len; if( ssl->minor_ver != SSL_MINOR_VERSION_0 ) { i += 2; ssl->out_msg[4] = (unsigned char)( n >> 8 ); ssl->out_msg[5] = (unsigned char)( n ); } ret = rsa_pkcs1_encrypt( &ssl->peer_cert->rsa, ssl->f_rng, ssl->p_rng, RSA_PUBLIC, ssl->pmslen, ssl->premaster, ssl->out_msg + i ); if( ret != 0 ) { SSL_DEBUG_RET( 1, "rsa_pkcs1_encrypt", ret ); return( ret ); } } if( ( ret = ssl_derive_keys( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_derive_keys", ret ); return( ret ); } ssl->out_msglen = i + n; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_CLIENT_KEY_EXCHANGE; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write client key exchange" ) ); return( 0 ); } static int ssl_write_certificate_verify( ssl_context *ssl ) { int ret = 0; size_t n = 0; unsigned char hash[36]; SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) ); if( ssl->client_auth == 0 || ssl->own_cert == NULL ) { SSL_DEBUG_MSG( 2, ( "<= skip write certificate verify" ) ); ssl->state++; return( 0 ); } if( ssl->rsa_key == NULL ) { #if defined(POLARSSL_PKCS11_C) if( ssl->pkcs11_key == NULL ) { #endif /* defined(POLARSSL_PKCS11_C) */ SSL_DEBUG_MSG( 1, ( "got no private key" ) ); return( POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED ); #if defined(POLARSSL_PKCS11_C) } #endif /* defined(POLARSSL_PKCS11_C) */ } /* * Make an RSA signature of the handshake digests */ ssl_calc_verify( ssl, hash ); if ( ssl->rsa_key ) n = ssl->rsa_key->len; #if defined(POLARSSL_PKCS11_C) else n = ssl->pkcs11_key->len; #endif /* defined(POLARSSL_PKCS11_C) */ ssl->out_msg[4] = (unsigned char)( n >> 8 ); ssl->out_msg[5] = (unsigned char)( n ); if( ssl->rsa_key ) { ret = rsa_pkcs1_sign( ssl->rsa_key, ssl->f_rng, ssl->p_rng, RSA_PRIVATE, SIG_RSA_RAW, 36, hash, ssl->out_msg + 6 ); } else { #if defined(POLARSSL_PKCS11_C) ret = pkcs11_sign( ssl->pkcs11_key, RSA_PRIVATE, SIG_RSA_RAW, 36, hash, ssl->out_msg + 6 ); #endif /* defined(POLARSSL_PKCS11_C) */ } if (ret != 0) { SSL_DEBUG_RET( 1, "pkcs1_sign", ret ); return( ret ); } ssl->out_msglen = 6 + n; ssl->out_msgtype = SSL_MSG_HANDSHAKE; ssl->out_msg[0] = SSL_HS_CERTIFICATE_VERIFY; ssl->state++; if( ( ret = ssl_write_record( ssl ) ) != 0 ) { SSL_DEBUG_RET( 1, "ssl_write_record", ret ); return( ret ); } SSL_DEBUG_MSG( 2, ( "<= write certificate verify" ) ); return( 0 ); } /* * SSL handshake -- client side */ int ssl_handshake_client( ssl_context *ssl ) { int ret = 0; SSL_DEBUG_MSG( 2, ( "=> handshake client" ) ); while( ssl->state != SSL_HANDSHAKE_OVER ) { SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); if( ( ret = ssl_flush_output( ssl ) ) != 0 ) break; switch( ssl->state ) { case SSL_HELLO_REQUEST: ssl->state = SSL_CLIENT_HELLO; break; /* * ==> ClientHello */ case SSL_CLIENT_HELLO: ret = ssl_write_client_hello( ssl ); break; /* * <== ServerHello * Certificate * ( ServerKeyExchange ) * ( CertificateRequest ) * ServerHelloDone */ case SSL_SERVER_HELLO: ret = ssl_parse_server_hello( ssl ); break; case SSL_SERVER_CERTIFICATE: ret = ssl_parse_certificate( ssl ); break; case SSL_SERVER_KEY_EXCHANGE: ret = ssl_parse_server_key_exchange( ssl ); break; case SSL_CERTIFICATE_REQUEST: ret = ssl_parse_certificate_request( ssl ); break; case SSL_SERVER_HELLO_DONE: ret = ssl_parse_server_hello_done( ssl ); break; /* * ==> ( Certificate/Alert ) * ClientKeyExchange * ( CertificateVerify ) * ChangeCipherSpec * Finished */ case SSL_CLIENT_CERTIFICATE: ret = ssl_write_certificate( ssl ); break; case SSL_CLIENT_KEY_EXCHANGE: ret = ssl_write_client_key_exchange( ssl ); break; case SSL_CERTIFICATE_VERIFY: ret = ssl_write_certificate_verify( ssl ); break; case SSL_CLIENT_CHANGE_CIPHER_SPEC: ret = ssl_write_change_cipher_spec( ssl ); break; case SSL_CLIENT_FINISHED: ret = ssl_write_finished( ssl ); break; /* * <== ChangeCipherSpec * Finished */ case SSL_SERVER_CHANGE_CIPHER_SPEC: ret = ssl_parse_change_cipher_spec( ssl ); break; case SSL_SERVER_FINISHED: ret = ssl_parse_finished( ssl ); break; case SSL_FLUSH_BUFFERS: SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); ssl->state = SSL_HANDSHAKE_OVER; break; default: SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); } if( ret != 0 ) break; } SSL_DEBUG_MSG( 2, ( "<= handshake client" ) ); return( ret ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/md.c0000644000014601777760000001604312165464055022047 0ustar00jenkinsnogroup00000000000000/** * \file md.c * * \brief Generic message digest wrapper for PolarSSL * * \author Adriaan de Jong * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_MD_C) #include "polarssl/md.h" #include "polarssl/md_wrap.h" #include #if defined _MSC_VER && !defined strcasecmp #define strcasecmp _stricmp #endif static const int supported_digests[] = { #if defined(POLARSSL_MD2_C) POLARSSL_MD_MD2, #endif #if defined(POLARSSL_MD4_C) POLARSSL_MD_MD4, #endif #if defined(POLARSSL_MD5_C) POLARSSL_MD_MD5, #endif #if defined(POLARSSL_SHA1_C) POLARSSL_MD_SHA1, #endif #if defined(POLARSSL_SHA2_C) POLARSSL_MD_SHA224, POLARSSL_MD_SHA256, #endif #if defined(POLARSSL_SHA4_C) POLARSSL_MD_SHA384, POLARSSL_MD_SHA512, #endif 0 }; const int *md_list( void ) { return supported_digests; } const md_info_t *md_info_from_string( const char *md_name ) { if( NULL == md_name ) return NULL; /* Get the appropriate digest information */ #if defined(POLARSSL_MD2_C) if( !strcasecmp( "MD2", md_name ) ) return md_info_from_type( POLARSSL_MD_MD2 ); #endif #if defined(POLARSSL_MD4_C) if( !strcasecmp( "MD4", md_name ) ) return md_info_from_type( POLARSSL_MD_MD4 ); #endif #if defined(POLARSSL_MD5_C) if( !strcasecmp( "MD5", md_name ) ) return md_info_from_type( POLARSSL_MD_MD5 ); #endif #if defined(POLARSSL_SHA1_C) if( !strcasecmp( "SHA1", md_name ) || !strcasecmp( "SHA", md_name ) ) return md_info_from_type( POLARSSL_MD_SHA1 ); #endif #if defined(POLARSSL_SHA2_C) if( !strcasecmp( "SHA224", md_name ) ) return md_info_from_type( POLARSSL_MD_SHA224 ); if( !strcasecmp( "SHA256", md_name ) ) return md_info_from_type( POLARSSL_MD_SHA256 ); #endif #if defined(POLARSSL_SHA4_C) if( !strcasecmp( "SHA384", md_name ) ) return md_info_from_type( POLARSSL_MD_SHA384 ); if( !strcasecmp( "SHA512", md_name ) ) return md_info_from_type( POLARSSL_MD_SHA512 ); #endif return NULL; } const md_info_t *md_info_from_type( md_type_t md_type ) { switch( md_type ) { #if defined(POLARSSL_MD2_C) case POLARSSL_MD_MD2: return &md2_info; #endif #if defined(POLARSSL_MD4_C) case POLARSSL_MD_MD4: return &md4_info; #endif #if defined(POLARSSL_MD5_C) case POLARSSL_MD_MD5: return &md5_info; #endif #if defined(POLARSSL_SHA1_C) case POLARSSL_MD_SHA1: return &sha1_info; #endif #if defined(POLARSSL_SHA2_C) case POLARSSL_MD_SHA224: return &sha224_info; case POLARSSL_MD_SHA256: return &sha256_info; #endif #if defined(POLARSSL_SHA4_C) case POLARSSL_MD_SHA384: return &sha384_info; case POLARSSL_MD_SHA512: return &sha512_info; #endif default: return NULL; } } int md_init_ctx( md_context_t *ctx, const md_info_t *md_info ) { if( md_info == NULL || ctx == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; memset( ctx, 0, sizeof( md_context_t ) ); if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL ) return POLARSSL_ERR_MD_ALLOC_FAILED; ctx->md_info = md_info; md_info->starts_func( ctx->md_ctx ); return 0; } int md_free_ctx( md_context_t *ctx ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->ctx_free_func( ctx->md_ctx ); ctx->md_ctx = NULL; return 0; } int md_starts( md_context_t *ctx ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->starts_func( ctx->md_ctx ); return 0; } int md_update( md_context_t *ctx, const unsigned char *input, size_t ilen ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->update_func( ctx->md_ctx, input, ilen ); return 0; } int md_finish( md_context_t *ctx, unsigned char *output ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->finish_func( ctx->md_ctx, output ); return 0; } int md( const md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output ) { if ( md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; md_info->digest_func( input, ilen, output ); return 0; } int md_file( const md_info_t *md_info, const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) int ret; #endif if( md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; #if defined(POLARSSL_FS_IO) ret = md_info->file_func( path, output ); if( ret != 0 ) return( POLARSSL_ERR_MD_FILE_IO_ERROR + ret ); return( ret ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->hmac_starts_func( ctx->md_ctx, key, keylen); return 0; } int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->hmac_update_func( ctx->md_ctx, input, ilen ); return 0; } int md_hmac_finish( md_context_t *ctx, unsigned char *output) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->hmac_finish_func( ctx->md_ctx, output); return 0; } int md_hmac_reset( md_context_t *ctx ) { if( ctx == NULL || ctx->md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; ctx->md_info->hmac_reset_func( ctx->md_ctx); return 0; } int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ) { if( md_info == NULL ) return POLARSSL_ERR_MD_BAD_INPUT_DATA; md_info->hmac_func( key, keylen, input, ilen, output ); return 0; } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/des.c0000644000014601777760000007201612165464055022224 0ustar00jenkinsnogroup00000000000000/* * FIPS-46-3 compliant Triple-DES implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * DES, on which TDES is based, was originally designed by Horst Feistel * at IBM in 1974, and was adopted as a standard by NIST (formerly NBS). * * http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_DES_C) #include "polarssl/des.h" /* * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE #define GET_ULONG_BE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ | ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (unsigned long) (b)[(i) + 3] ); \ } #endif #ifndef PUT_ULONG_BE #define PUT_ULONG_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ } #endif /* * Expanded DES S-boxes */ static const unsigned long SB1[64] = { 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400, 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404, 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404, 0x00010404, 0x01000000, 0x00010000, 0x01010404, 0x00000004, 0x01010000, 0x01010400, 0x01000000, 0x01000000, 0x00000400, 0x01010004, 0x00010000, 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404, 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404, 0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000, 0x00010004, 0x00010400, 0x00000000, 0x01010004 }; static const unsigned long SB2[64] = { 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020, 0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000, 0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020, 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000, 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000, 0x80100000, 0x00008020, 0x00000000, 0x00108020, 0x80100020, 0x00100000, 0x80008020, 0x80100000, 0x80108000, 0x00008000, 0x80100000, 0x80008000, 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000, 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020, 0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020, 0x80000000, 0x80100020, 0x80108020, 0x00108000 }; static const unsigned long SB3[64] = { 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000, 0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000, 0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008, 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208, 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208, 0x00000200, 0x08000000, 0x08020200, 0x08000000, 0x00020008, 0x00000208, 0x00020000, 0x08020200, 0x08000200, 0x00000000, 0x00000200, 0x00020008, 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008, 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208, 0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000, 0x00020208, 0x00000008, 0x08020008, 0x00020200 }; static const unsigned long SB4[64] = { 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081, 0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080, 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080, 0x00802081, 0x00000081, 0x00800080, 0x00800001, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00000000, 0x00802000, 0x00002080, 0x00800080, 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001, 0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002000, 0x00802080 }; static const unsigned long SB5[64] = { 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100, 0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100, 0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000, 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100, 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000, 0x42000000, 0x00080100, 0x00080000, 0x42000100, 0x00000100, 0x02000000, 0x40000000, 0x02080000, 0x42000100, 0x40080100, 0x02000100, 0x40000000, 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000, 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000, 0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000, 0x00000000, 0x40080000, 0x02080100, 0x40000100 }; static const unsigned long SB6[64] = { 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010, 0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010, 0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010, 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010, 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000, 0x20404000, 0x20000000, 0x20004000, 0x00000010, 0x20400010, 0x00404000, 0x20404010, 0x00400000, 0x00004010, 0x20000010, 0x00400000, 0x20004000, 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000, 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000, 0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000, 0x20404000, 0x20000000, 0x00400010, 0x20004010 }; static const unsigned long SB7[64] = { 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802, 0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002, 0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802, 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002, 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002, 0x04000000, 0x00200800, 0x04000000, 0x00200800, 0x00200000, 0x04000802, 0x04000802, 0x04200002, 0x04200002, 0x00000002, 0x00200002, 0x04000000, 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800, 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000, 0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800, 0x04000002, 0x04000800, 0x00000800, 0x00200002 }; static const unsigned long SB8[64] = { 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040, 0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000, 0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040, 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000, 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000, 0x00041040, 0x00040000, 0x00041040, 0x00040000, 0x10041000, 0x00001000, 0x00000040, 0x10040040, 0x00001000, 0x00041040, 0x10001000, 0x00000040, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040, 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040, 0x00001040, 0x00040040, 0x10000000, 0x10041000 }; /* * PC1: left and right halves bit-swap */ static const unsigned long LHs[16] = { 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001, 0x00010100, 0x00010101, 0x01000000, 0x01000001, 0x01000100, 0x01000101, 0x01010000, 0x01010001, 0x01010100, 0x01010101 }; static const unsigned long RHs[16] = { 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101, 0x01010101, }; /* * Initial Permutation macro */ #define DES_IP(X,Y) \ { \ T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ Y = ((Y << 1) | (Y >> 31)) & 0xFFFFFFFF; \ T = (X ^ Y) & 0xAAAAAAAA; Y ^= T; X ^= T; \ X = ((X << 1) | (X >> 31)) & 0xFFFFFFFF; \ } /* * Final Permutation macro */ #define DES_FP(X,Y) \ { \ X = ((X << 31) | (X >> 1)) & 0xFFFFFFFF; \ T = (X ^ Y) & 0xAAAAAAAA; X ^= T; Y ^= T; \ Y = ((Y << 31) | (Y >> 1)) & 0xFFFFFFFF; \ T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ } /* * DES round macro */ #define DES_ROUND(X,Y) \ { \ T = *SK++ ^ X; \ Y ^= SB8[ (T ) & 0x3F ] ^ \ SB6[ (T >> 8) & 0x3F ] ^ \ SB4[ (T >> 16) & 0x3F ] ^ \ SB2[ (T >> 24) & 0x3F ]; \ \ T = *SK++ ^ ((X << 28) | (X >> 4)); \ Y ^= SB7[ (T ) & 0x3F ] ^ \ SB5[ (T >> 8) & 0x3F ] ^ \ SB3[ (T >> 16) & 0x3F ] ^ \ SB1[ (T >> 24) & 0x3F ]; \ } #define SWAP(a,b) { unsigned long t = a; a = b; b = t; t = 0; } static const unsigned char odd_parity_table[128] = { 1, 2, 4, 7, 8, 11, 13, 14, 16, 19, 21, 22, 25, 26, 28, 31, 32, 35, 37, 38, 41, 42, 44, 47, 49, 50, 52, 55, 56, 59, 61, 62, 64, 67, 69, 70, 73, 74, 76, 79, 81, 82, 84, 87, 88, 91, 93, 94, 97, 98, 100, 103, 104, 107, 109, 110, 112, 115, 117, 118, 121, 122, 124, 127, 128, 131, 133, 134, 137, 138, 140, 143, 145, 146, 148, 151, 152, 155, 157, 158, 161, 162, 164, 167, 168, 171, 173, 174, 176, 179, 181, 182, 185, 186, 188, 191, 193, 194, 196, 199, 200, 203, 205, 206, 208, 211, 213, 214, 217, 218, 220, 223, 224, 227, 229, 230, 233, 234, 236, 239, 241, 242, 244, 247, 248, 251, 253, 254 }; void des_key_set_parity( unsigned char key[DES_KEY_SIZE] ) { int i; for( i = 0; i < DES_KEY_SIZE; i++ ) key[i] = odd_parity_table[key[i] / 2]; } /* * Check the given key's parity, returns 1 on failure, 0 on SUCCESS */ int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] ) { int i; for( i = 0; i < DES_KEY_SIZE; i++ ) if ( key[i] != odd_parity_table[key[i] / 2] ) return( 1 ); return( 0 ); } /* * Table of weak and semi-weak keys * * Source: http://en.wikipedia.org/wiki/Weak_key * * Weak: * Alternating ones + zeros (0x0101010101010101) * Alternating 'F' + 'E' (0xFEFEFEFEFEFEFEFE) * '0xE0E0E0E0F1F1F1F1' * '0x1F1F1F1F0E0E0E0E' * * Semi-weak: * 0x011F011F010E010E and 0x1F011F010E010E01 * 0x01E001E001F101F1 and 0xE001E001F101F101 * 0x01FE01FE01FE01FE and 0xFE01FE01FE01FE01 * 0x1FE01FE00EF10EF1 and 0xE01FE01FF10EF10E * 0x1FFE1FFE0EFE0EFE and 0xFE1FFE1FFE0EFE0E * 0xE0FEE0FEF1FEF1FE and 0xFEE0FEE0FEF1FEF1 * */ #define WEAK_KEY_COUNT 16 static const unsigned char weak_key_table[WEAK_KEY_COUNT][DES_KEY_SIZE] = { { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, { 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE }, { 0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E }, { 0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1 }, { 0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E }, { 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01 }, { 0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1 }, { 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01 }, { 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE }, { 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01 }, { 0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1 }, { 0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E }, { 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE }, { 0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E }, { 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE }, { 0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1 } }; int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] ) { int i; for( i = 0; i < WEAK_KEY_COUNT; i++ ) if( memcmp( weak_key_table[i], key, DES_KEY_SIZE) == 0) return( 1 ); return( 0 ); } static void des_setkey( unsigned long SK[32], const unsigned char key[DES_KEY_SIZE] ) { int i; unsigned long X, Y, T; GET_ULONG_BE( X, key, 0 ); GET_ULONG_BE( Y, key, 4 ); /* * Permuted Choice 1 */ T = ((Y >> 4) ^ X) & 0x0F0F0F0F; X ^= T; Y ^= (T << 4); T = ((Y ) ^ X) & 0x10101010; X ^= T; Y ^= (T ); X = (LHs[ (X ) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2) | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ] ) | (LHs[ (X >> 5) & 0xF] << 7) | (LHs[ (X >> 13) & 0xF ] << 6) | (LHs[ (X >> 21) & 0xF] << 5) | (LHs[ (X >> 29) & 0xF ] << 4); Y = (RHs[ (Y >> 1) & 0xF] << 3) | (RHs[ (Y >> 9) & 0xF ] << 2) | (RHs[ (Y >> 17) & 0xF] << 1) | (RHs[ (Y >> 25) & 0xF ] ) | (RHs[ (Y >> 4) & 0xF] << 7) | (RHs[ (Y >> 12) & 0xF ] << 6) | (RHs[ (Y >> 20) & 0xF] << 5) | (RHs[ (Y >> 28) & 0xF ] << 4); X &= 0x0FFFFFFF; Y &= 0x0FFFFFFF; /* * calculate subkeys */ for( i = 0; i < 16; i++ ) { if( i < 2 || i == 8 || i == 15 ) { X = ((X << 1) | (X >> 27)) & 0x0FFFFFFF; Y = ((Y << 1) | (Y >> 27)) & 0x0FFFFFFF; } else { X = ((X << 2) | (X >> 26)) & 0x0FFFFFFF; Y = ((Y << 2) | (Y >> 26)) & 0x0FFFFFFF; } *SK++ = ((X << 4) & 0x24000000) | ((X << 28) & 0x10000000) | ((X << 14) & 0x08000000) | ((X << 18) & 0x02080000) | ((X << 6) & 0x01000000) | ((X << 9) & 0x00200000) | ((X >> 1) & 0x00100000) | ((X << 10) & 0x00040000) | ((X << 2) & 0x00020000) | ((X >> 10) & 0x00010000) | ((Y >> 13) & 0x00002000) | ((Y >> 4) & 0x00001000) | ((Y << 6) & 0x00000800) | ((Y >> 1) & 0x00000400) | ((Y >> 14) & 0x00000200) | ((Y ) & 0x00000100) | ((Y >> 5) & 0x00000020) | ((Y >> 10) & 0x00000010) | ((Y >> 3) & 0x00000008) | ((Y >> 18) & 0x00000004) | ((Y >> 26) & 0x00000002) | ((Y >> 24) & 0x00000001); *SK++ = ((X << 15) & 0x20000000) | ((X << 17) & 0x10000000) | ((X << 10) & 0x08000000) | ((X << 22) & 0x04000000) | ((X >> 2) & 0x02000000) | ((X << 1) & 0x01000000) | ((X << 16) & 0x00200000) | ((X << 11) & 0x00100000) | ((X << 3) & 0x00080000) | ((X >> 6) & 0x00040000) | ((X << 15) & 0x00020000) | ((X >> 4) & 0x00010000) | ((Y >> 2) & 0x00002000) | ((Y << 8) & 0x00001000) | ((Y >> 14) & 0x00000808) | ((Y >> 9) & 0x00000400) | ((Y ) & 0x00000200) | ((Y << 7) & 0x00000100) | ((Y >> 7) & 0x00000020) | ((Y >> 3) & 0x00000011) | ((Y << 2) & 0x00000004) | ((Y >> 21) & 0x00000002); } } /* * DES key schedule (56-bit, encryption) */ int des_setkey_enc( des_context *ctx, const unsigned char key[DES_KEY_SIZE] ) { des_setkey( ctx->sk, key ); return( 0 ); } /* * DES key schedule (56-bit, decryption) */ int des_setkey_dec( des_context *ctx, const unsigned char key[DES_KEY_SIZE] ) { int i; des_setkey( ctx->sk, key ); for( i = 0; i < 16; i += 2 ) { SWAP( ctx->sk[i ], ctx->sk[30 - i] ); SWAP( ctx->sk[i + 1], ctx->sk[31 - i] ); } return( 0 ); } static void des3_set2key( unsigned long esk[96], unsigned long dsk[96], const unsigned char key[DES_KEY_SIZE*2] ) { int i; des_setkey( esk, key ); des_setkey( dsk + 32, key + 8 ); for( i = 0; i < 32; i += 2 ) { dsk[i ] = esk[30 - i]; dsk[i + 1] = esk[31 - i]; esk[i + 32] = dsk[62 - i]; esk[i + 33] = dsk[63 - i]; esk[i + 64] = esk[i ]; esk[i + 65] = esk[i + 1]; dsk[i + 64] = dsk[i ]; dsk[i + 65] = dsk[i + 1]; } } /* * Triple-DES key schedule (112-bit, encryption) */ int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ) { unsigned long sk[96]; des3_set2key( ctx->sk, sk, key ); memset( sk, 0, sizeof( sk ) ); return( 0 ); } /* * Triple-DES key schedule (112-bit, decryption) */ int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ) { unsigned long sk[96]; des3_set2key( sk, ctx->sk, key ); memset( sk, 0, sizeof( sk ) ); return( 0 ); } static void des3_set3key( unsigned long esk[96], unsigned long dsk[96], const unsigned char key[24] ) { int i; des_setkey( esk, key ); des_setkey( dsk + 32, key + 8 ); des_setkey( esk + 64, key + 16 ); for( i = 0; i < 32; i += 2 ) { dsk[i ] = esk[94 - i]; dsk[i + 1] = esk[95 - i]; esk[i + 32] = dsk[62 - i]; esk[i + 33] = dsk[63 - i]; dsk[i + 64] = esk[30 - i]; dsk[i + 65] = esk[31 - i]; } } /* * Triple-DES key schedule (168-bit, encryption) */ int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ) { unsigned long sk[96]; des3_set3key( ctx->sk, sk, key ); memset( sk, 0, sizeof( sk ) ); return( 0 ); } /* * Triple-DES key schedule (168-bit, decryption) */ int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ) { unsigned long sk[96]; des3_set3key( sk, ctx->sk, key ); memset( sk, 0, sizeof( sk ) ); return( 0 ); } /* * DES-ECB block encryption/decryption */ int des_crypt_ecb( des_context *ctx, const unsigned char input[8], unsigned char output[8] ) { int i; unsigned long X, Y, T, *SK; SK = ctx->sk; GET_ULONG_BE( X, input, 0 ); GET_ULONG_BE( Y, input, 4 ); DES_IP( X, Y ); for( i = 0; i < 8; i++ ) { DES_ROUND( Y, X ); DES_ROUND( X, Y ); } DES_FP( Y, X ); PUT_ULONG_BE( Y, output, 0 ); PUT_ULONG_BE( X, output, 4 ); return( 0 ); } /* * DES-CBC buffer encryption/decryption */ int des_crypt_cbc( des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ) { int i; unsigned char temp[8]; if( length % 8 ) return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH ); if( mode == DES_ENCRYPT ) { while( length > 0 ) { for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); des_crypt_ecb( ctx, output, output ); memcpy( iv, output, 8 ); input += 8; output += 8; length -= 8; } } else /* DES_DECRYPT */ { while( length > 0 ) { memcpy( temp, input, 8 ); des_crypt_ecb( ctx, input, output ); for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); memcpy( iv, temp, 8 ); input += 8; output += 8; length -= 8; } } return( 0 ); } /* * 3DES-ECB block encryption/decryption */ int des3_crypt_ecb( des3_context *ctx, const unsigned char input[8], unsigned char output[8] ) { int i; unsigned long X, Y, T, *SK; SK = ctx->sk; GET_ULONG_BE( X, input, 0 ); GET_ULONG_BE( Y, input, 4 ); DES_IP( X, Y ); for( i = 0; i < 8; i++ ) { DES_ROUND( Y, X ); DES_ROUND( X, Y ); } for( i = 0; i < 8; i++ ) { DES_ROUND( X, Y ); DES_ROUND( Y, X ); } for( i = 0; i < 8; i++ ) { DES_ROUND( Y, X ); DES_ROUND( X, Y ); } DES_FP( Y, X ); PUT_ULONG_BE( Y, output, 0 ); PUT_ULONG_BE( X, output, 4 ); return( 0 ); } /* * 3DES-CBC buffer encryption/decryption */ int des3_crypt_cbc( des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ) { int i; unsigned char temp[8]; if( length % 8 ) return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH ); if( mode == DES_ENCRYPT ) { while( length > 0 ) { for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); des3_crypt_ecb( ctx, output, output ); memcpy( iv, output, 8 ); input += 8; output += 8; length -= 8; } } else /* DES_DECRYPT */ { while( length > 0 ) { memcpy( temp, input, 8 ); des3_crypt_ecb( ctx, input, output ); for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); memcpy( iv, temp, 8 ); input += 8; output += 8; length -= 8; } } return( 0 ); } #if defined(POLARSSL_SELF_TEST) #include /* * DES and 3DES test vectors from: * * http://csrc.nist.gov/groups/STM/cavp/documents/des/tripledes-vectors.zip */ static const unsigned char des3_test_keys[24] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23 }; static const unsigned char des3_test_iv[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, }; static const unsigned char des3_test_buf[8] = { 0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 }; static const unsigned char des3_test_ecb_dec[3][8] = { { 0xCD, 0xD6, 0x4F, 0x2F, 0x94, 0x27, 0xC1, 0x5D }, { 0x69, 0x96, 0xC8, 0xFA, 0x47, 0xA2, 0xAB, 0xEB }, { 0x83, 0x25, 0x39, 0x76, 0x44, 0x09, 0x1A, 0x0A } }; static const unsigned char des3_test_ecb_enc[3][8] = { { 0x6A, 0x2A, 0x19, 0xF4, 0x1E, 0xCA, 0x85, 0x4B }, { 0x03, 0xE6, 0x9F, 0x5B, 0xFA, 0x58, 0xEB, 0x42 }, { 0xDD, 0x17, 0xE8, 0xB8, 0xB4, 0x37, 0xD2, 0x32 } }; static const unsigned char des3_test_cbc_dec[3][8] = { { 0x12, 0x9F, 0x40, 0xB9, 0xD2, 0x00, 0x56, 0xB3 }, { 0x47, 0x0E, 0xFC, 0x9A, 0x6B, 0x8E, 0xE3, 0x93 }, { 0xC5, 0xCE, 0xCF, 0x63, 0xEC, 0xEC, 0x51, 0x4C } }; static const unsigned char des3_test_cbc_enc[3][8] = { { 0x54, 0xF1, 0x5A, 0xF6, 0xEB, 0xE3, 0xA4, 0xB4 }, { 0x35, 0x76, 0x11, 0x56, 0x5F, 0xA1, 0x8E, 0x4D }, { 0xCB, 0x19, 0x1F, 0x85, 0xD1, 0xED, 0x84, 0x39 } }; /* * Checkup routine */ int des_self_test( int verbose ) { int i, j, u, v; des_context ctx; des3_context ctx3; unsigned char key[24]; unsigned char buf[8]; unsigned char prv[8]; unsigned char iv[8]; memset( key, 0, 24 ); /* * ECB mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " DES%c-ECB-%3d (%s): ", ( u == 0 ) ? ' ' : '3', 56 + u * 56, ( v == DES_DECRYPT ) ? "dec" : "enc" ); memcpy( buf, des3_test_buf, 8 ); switch( i ) { case 0: des_setkey_dec( &ctx, (unsigned char *) des3_test_keys ); break; case 1: des_setkey_enc( &ctx, (unsigned char *) des3_test_keys ); break; case 2: des3_set2key_dec( &ctx3, (unsigned char *) des3_test_keys ); break; case 3: des3_set2key_enc( &ctx3, (unsigned char *) des3_test_keys ); break; case 4: des3_set3key_dec( &ctx3, (unsigned char *) des3_test_keys ); break; case 5: des3_set3key_enc( &ctx3, (unsigned char *) des3_test_keys ); break; default: return( 1 ); } for( j = 0; j < 10000; j++ ) { if( u == 0 ) des_crypt_ecb( &ctx, buf, buf ); else des3_crypt_ecb( &ctx3, buf, buf ); } if( ( v == DES_DECRYPT && memcmp( buf, des3_test_ecb_dec[u], 8 ) != 0 ) || ( v != DES_DECRYPT && memcmp( buf, des3_test_ecb_enc[u], 8 ) != 0 ) ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); /* * CBC mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " DES%c-CBC-%3d (%s): ", ( u == 0 ) ? ' ' : '3', 56 + u * 56, ( v == DES_DECRYPT ) ? "dec" : "enc" ); memcpy( iv, des3_test_iv, 8 ); memcpy( prv, des3_test_iv, 8 ); memcpy( buf, des3_test_buf, 8 ); switch( i ) { case 0: des_setkey_dec( &ctx, (unsigned char *) des3_test_keys ); break; case 1: des_setkey_enc( &ctx, (unsigned char *) des3_test_keys ); break; case 2: des3_set2key_dec( &ctx3, (unsigned char *) des3_test_keys ); break; case 3: des3_set2key_enc( &ctx3, (unsigned char *) des3_test_keys ); break; case 4: des3_set3key_dec( &ctx3, (unsigned char *) des3_test_keys ); break; case 5: des3_set3key_enc( &ctx3, (unsigned char *) des3_test_keys ); break; default: return( 1 ); } if( v == DES_DECRYPT ) { for( j = 0; j < 10000; j++ ) { if( u == 0 ) des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); else des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); } } else { for( j = 0; j < 10000; j++ ) { unsigned char tmp[8]; if( u == 0 ) des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); else des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); memcpy( tmp, prv, 8 ); memcpy( prv, buf, 8 ); memcpy( buf, tmp, 8 ); } memcpy( buf, prv, 8 ); } if( ( v == DES_DECRYPT && memcmp( buf, des3_test_cbc_dec[u], 8 ) != 0 ) || ( v != DES_DECRYPT && memcmp( buf, des3_test_cbc_enc[u], 8 ) != 0 ) ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/certs.c0000644000014601777760000002571312165464055022573 0ustar00jenkinsnogroup00000000000000/* * X.509 test certificates * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_CERTS_C) const char test_ca_crt[] = "-----BEGIN CERTIFICATE-----\r\n" "MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" "MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" "A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" "mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" "50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" "YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" "R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" "KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" "gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH\r\n" "/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV\r\n" "BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz\r\n" "dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n" "SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n" "DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n" "pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n" "m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" "7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" "-----END CERTIFICATE-----\r\n"; const char test_ca_key[] = "-----BEGIN RSA PRIVATE KEY-----\r\n" "Proc-Type: 4,ENCRYPTED\r\n" "DEK-Info: DES-EDE3-CBC,A8A95B05D5B7206B\r\n" "\r\n" "9Qd9GeArejl1GDVh2lLV1bHt0cPtfbh5h/5zVpAVaFpqtSPMrElp50Rntn9et+JA\r\n" "7VOyboR+Iy2t/HU4WvA687k3Bppe9GwKHjHhtl//8xFKwZr3Xb5yO5JUP8AUctQq\r\n" "Nb8CLlZyuUC+52REAAthdWgsX+7dJO4yabzUcQ22Tp9JSD0hiL43BlkWYUNK3dAo\r\n" "PZlmiptjnzVTjg1MxsBSydZinWOLBV8/JQgxSPo2yD4uEfig28qbvQ2wNIn0pnAb\r\n" "GxnSAOazkongEGfvcjIIs+LZN9gXFhxcOh6kc4Q/c99B7QWETwLLkYgZ+z1a9VY9\r\n" "gEU7CwCxYCD+h9hY6FPmsK0/lC4O7aeRKpYq00rPPxs6i7phiexg6ax6yTMmArQq\r\n" "QmK3TAsJm8V/J5AWpLEV6jAFgRGymGGHnof0DXzVWZidrcZJWTNuGEX90nB3ee2w\r\n" "PXJEFWKoD3K3aFcSLdHYr3mLGxP7H9ThQai9VsycxZKS5kwvBKQ//YMrmFfwPk8x\r\n" "vTeY4KZMaUrveEel5tWZC94RSMKgxR6cyE1nBXyTQnDOGbfpNNgBKxyKbINWoOJU\r\n" "WJZAwlsQn+QzCDwpri7+sV1mS3gBE6UY7aQmnmiiaC2V3Hbphxct/en5QsfDOt1X\r\n" "JczSfpRWLlbPznZg8OQh/VgCMA58N5DjOzTIK7sJJ5r+94ZBTCpgAMbF588f0NTR\r\n" "KCe4yrxGJR7X02M4nvD4IwOlpsQ8xQxZtOSgXv4LkxvdU9XJJKWZ/XNKJeWztxSe\r\n" "Z1vdTc2YfsDBA2SEv33vxHx2g1vqtw8SjDRT2RaQSS0QuSaMJimdOX6mTOCBKk1J\r\n" "9Q5mXTrER+/LnK0jEmXsBXWA5bqqVZIyahXSx4VYZ7l7w/PHiUDtDgyRhMMKi4n2\r\n" "iQvQcWSQTjrpnlJbca1/DkpRt3YwrvJwdqb8asZU2VrNETh5x0QVefDRLFiVpif/\r\n" "tUaeAe/P1F8OkS7OIZDs1SUbv/sD2vMbhNkUoCms3/PvNtdnvgL4F0zhaDpKCmlT\r\n" "P8vx49E7v5CyRNmED9zZg4o3wmMqrQO93PtTug3Eu9oVx1zPQM1NVMyBa2+f29DL\r\n" "1nuTCeXdo9+ni45xx+jAI4DCwrRdhJ9uzZyC6962H37H6D+5naNvClFR1s6li1Gb\r\n" "nqPoiy/OBsEx9CaDGcqQBp5Wme/3XW+6z1ISOx+igwNTVCT14mHdBMbya0eIKft5\r\n" "X+GnwtgEMyCYyyWuUct8g4RzErcY9+yW9Om5Hzpx4zOuW4NPZgPDTgK+t2RSL/Yq\r\n" "rE1njrgeGYcVeG3f+OftH4s6fPbq7t1A5ZgUscbLMBqr9tK+OqygR4EgKBPsH6Cz\r\n" "L6zlv/2RV0qAHvVuDJcIDIgwY5rJtINEm32rhOeFNJwZS5MNIC1czXZx5//ugX7l\r\n" "I4sy5nbVhwSjtAk8Xg5dZbdTZ6mIrb7xqH+fdakZor1khG7bC2uIwibD3cSl2XkR\r\n" "wN48lslbHnqqagr6Xm1nNOSVl8C/6kbJEsMpLhAezfRtGwvOucoaE+WbeUNolGde\r\n" "P/eQiddSf0brnpiLJRh7qZrl9XuqYdpUqnoEdMAfotDOID8OtV7gt8a48ad8VPW2\r\n" "-----END RSA PRIVATE KEY-----\r\n"; const char test_ca_pwd[] = "PolarSSLTest"; const char test_srv_crt[] = "-----BEGIN CERTIFICATE-----\r\n" "MIIDPzCCAiegAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n" "A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN\r\n" "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/\r\n" "uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD\r\n" "d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf\r\n" "CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr\r\n" "lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w\r\n" "bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB\r\n" "o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAf\r\n" "BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQUFAAOC\r\n" "AQEAvc+WwZUemsJu2IiI2Cp6liA+UAvIx98dQe3kZs2zAoF9VwQbXcYzWQ/BILkj\r\n" "NImKbPL9x0g2jIDn4ZvGYFywMwIO/d++YbwYiQw42/v7RiMy94zBPnzeHi86dy/0\r\n" "jpOOJUx3IXRsGLdyjb/1T11klcFqGnARiK+8VYolMPP6afKvLXX7K4kiUpsFQhUp\r\n" "E5VeM5pV1Mci2ETOJau2cO40FJvI/C9W/wR+GAArMaw2fxG77E3laaa0LAOlexM6\r\n" "A4KOb5f5cGTM5Ih6tEF5FVq3/9vzNIYMa1FqzacBLZF8zSHYLEimXBdzjBoN4qDU\r\n" "/WzRyYRBRjAI49mzHX6raleqnw==\r\n" "-----END CERTIFICATE-----\r\n"; const char test_srv_key[] = "-----BEGIN RSA PRIVATE KEY-----\r\n" "MIIEogIBAAKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/uOhFkNvuiBZS0/FDUEeW\r\n" "Ellkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFDd185fAkER4KwVzlw7aPs\r\n" "FRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVfCrFTxjB+FTms+Vruf5Ke\r\n" "pgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTrlZvc/kFeF6babFtpzAK6\r\n" "FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9wbp7OvViJ4lNZnm5akmXi\r\n" "iD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQABAoIBABaJ9eiRQq4Ypv+w\r\n" "UTcVpLC0oTueWzcpor1i1zjG4Vzqe/Ok2FqyGToGKMlFK7Hwwa+LEyeJ3xyV5yd4\r\n" "v1Mw9bDZFdJC1eCBjoUAHtX6k9HOE0Vd6woVQ4Vi6OPI1g7B5Mnr/58rNrnN6TMs\r\n" "x58NF6euecwTU811QJrZtLbX7j2Cr28yB2Vs8qyYlHwVw5jbDOv43D7vU5gmlIDN\r\n" "0JQRuWAnOuPzZNoJr4SfJKqHNGxYYY6pHZ1s0dOTLIDb/B8KQWapA2kRmZyid2EH\r\n" "nwzgLbAsHJCf+bQnhXjXuxtUsrcIL8noZLazlOMxwNEammglVWW23Ud/QRnFgJg5\r\n" "UgcAcRECgYEA19uYetht5qmwdJ+12oC6zeO+vXLcyD9gon23T5J6w2YThld7/OW0\r\n" "oArQJGgkAdaq0pcTyOIjtTQVMFygdVmCEJmxh/3RutPcTeydqW9fphKDMej32J8e\r\n" "GniGmNGiclbcfNOS8E5TGp445yZb9P1+7AHng16bGg3Ykj5EA4G+HCcCgYEAyHAl\r\n" "//ekk8YjQElm+8izLtFkymIK0aCtEe9C/RIRhFYBeFaotC5dStNhBOncn4ovMAPD\r\n" "lX/92yDi9OP8PPLN3a4B9XpW3k/SS5GrbT5cwOivBHNllZSmu/2qz5WPGcjVCOrB\r\n" "LYl3YWr2h3EGKICT03kEoTkiDBvCeOpW7cCGl2cCgYBD5whoXHz1+ptPlI4YVjZt\r\n" "Xh86aU+ajpVPiEyJ84I6xXmO4SZXv8q6LaycR0ZMbcL+zBelMb4Z2nBv7jNrtuR7\r\n" "ZF28cdPv+YVr3esaybZE/73VjXup4SQPH6r3l7qKTVi+y6+FeJ4b2Xn8/MwgnT23\r\n" "8EFrye7wmzpthrjOgZnUMQKBgE9Lhsz/5J0Nis6Y+2Pqn3CLKEukg9Ewtqdct2y0\r\n" "5Dcta0F3TyCRIxlCDKTL/BslqMtfAdY4H268UO0+8IAQMn9boqzBrHIgs/pvc5kx\r\n" "TbKHmw2wtWR6vYersBKVgVpbCGSRssDYHGFu1n74qM4HJ/RGcR1zI9QUe1gopSFD\r\n" "xDtLAoGAVAdWvrqDwgoL2hHW3scGpxdE/ygJDOwHnf+1B9goKAOP5lf2FJaiAxf3\r\n" "ectoPOgZbCmm/iiDmigu703ld3O+VoCLDD4qx3R+KyALL78gtVJYzSRiKhzgCZ3g\r\n" "mKsIVRBq4IfwiwyMNG2BYZQAwbSDjjPtn/kPBduPzPj7eriByhI=\r\n" "-----END RSA PRIVATE KEY-----\r\n"; const char test_cli_crt[] = "-----BEGIN CERTIFICATE-----\r\n" "MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" "MTEwMjEyMTQ0NDA3WhcNMjEwMjEyMTQ0NDA3WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n" "A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n" "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f\r\n" "M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu\r\n" "1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw\r\n" "MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v\r\n" "4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/\r\n" "/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB\r\n" "o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf\r\n" "BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQUFAAOC\r\n" "AQEAAn86isAM8X+mVwJqeItt6E9slhEQbAofyk+diH1Lh8Y9iLlWQSKbw/UXYjx5\r\n" "LLPZcniovxIcARC/BjyZR9g3UwTHNGNm+rwrqa15viuNOFBchykX/Orsk02EH7NR\r\n" "Alw5WLPorYjED6cdVQgBl9ot93HdJogRiXCxErM7NC8/eP511mjq+uLDjLKH8ZPQ\r\n" "8I4ekHJnroLsDkIwXKGIsvIBHQy2ac/NwHLCQOK6mfum1pRx52V4Utu5dLLjD5bM\r\n" "xOBC7KU4xZKuMXXZM6/93Yb51K/J4ahf1TxJlTWXtnzDr9saEYdNy2SKY/6ZiDNH\r\n" "D+stpAKiQLAWaAusIWKYEyw9MQ==\r\n" "-----END CERTIFICATE-----\r\n"; const char test_cli_key[] = "-----BEGIN RSA PRIVATE KEY-----\r\n" "MIIEpAIBAAKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6fM60Nj4o8VmXl3ETZzGaF\r\n" "B9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu1C93KYRhTYJQj6eVSHD1\r\n" "bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEwMjDV0/YI0FZPRo7yX/k9\r\n" "Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v4Jv4EFbMs44TFeY0BGbH\r\n" "7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx//DZrtenNLQNiTrM9AM+v\r\n" "dqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQABAoIBAGdNtfYDiap6bzst\r\n" "yhCiI8m9TtrhZw4MisaEaN/ll3XSjaOG2dvV6xMZCMV+5TeXDHOAZnY18Yi18vzz\r\n" "4Ut2TnNFzizCECYNaA2fST3WgInnxUkV3YXAyP6CNxJaCmv2aA0yFr2kFVSeaKGt\r\n" "ymvljNp2NVkvm7Th8fBQBO7I7AXhz43k0mR7XmPgewe8ApZOG3hstkOaMvbWAvWA\r\n" "zCZupdDjZYjOJqlA4eEA4H8/w7F83r5CugeBE8LgEREjLPiyejrU5H1fubEY+h0d\r\n" "l5HZBJ68ybTXfQ5U9o/QKA3dd0toBEhhdRUDGzWtjvwkEQfqF1reGWj/tod/gCpf\r\n" "DFi6X0ECgYEA4wOv/pjSC3ty6TuOvKX2rOUiBrLXXv2JSxZnMoMiWI5ipLQt+RYT\r\n" "VPafL/m7Dn6MbwjayOkcZhBwk5CNz5A6Q4lJ64Mq/lqHznRCQQ2Mc1G8eyDF/fYL\r\n" "Ze2pLvwP9VD5jTc2miDfw+MnvJhywRRLcemDFP8k4hQVtm8PMp3ZmNECgYEA4gz7\r\n" "wzObR4gn8ibe617uQPZjWzUj9dUHYd+in1gwBCIrtNnaRn9I9U/Q6tegRYpii4ys\r\n" "c176NmU+umy6XmuSKV5qD9bSpZWG2nLFnslrN15Lm3fhZxoeMNhBaEDTnLT26yoi\r\n" "33gp0mSSWy94ZEqipms+ULF6sY1ZtFW6tpGFoy8CgYAQHhnnvJflIs2ky4q10B60\r\n" "ZcxFp3rtDpkp0JxhFLhiizFrujMtZSjYNm5U7KkgPVHhLELEUvCmOnKTt4ap/vZ0\r\n" "BxJNe1GZH3pW6SAvGDQpl9sG7uu/vTFP+lCxukmzxB0DrrDcvorEkKMom7ZCCRvW\r\n" "KZsZ6YeH2Z81BauRj218kQKBgQCUV/DgKP2985xDTT79N08jUo3hTP5MVYCCuj/+\r\n" "UeEw1TvZcx3LJby7P6Xad6a1/BqveaGyFKIfEFIaBUBItk801sDDpDaYc4gL00Xc\r\n" "7lFuBHOZkxJYlss5QrGpuOEl9ZwUt5IrFLBdYaKqNHzNVC1pCPfb/JyH6Dr2HUxq\r\n" "gxUwAQKBgQCcU6G2L8AG9d9c0UpOyL1tMvFe5Ttw0KjlQVdsh1MP6yigYo9DYuwu\r\n" "bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n" "8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n" "-----END RSA PRIVATE KEY-----\r\n"; const char test_dhm_params[] = "-----BEGIN DH PARAMETERS-----\r\n" "MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh\r\n" "1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32\r\n" "9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC\r\n" "-----END DH PARAMETERS-----\r\n"; #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/aes.c0000644000014601777760000012727212165464055022226 0ustar00jenkinsnogroup00000000000000/* * FIPS-197 compliant AES implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The AES block cipher was designed by Vincent Rijmen and Joan Daemen. * * http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_AES_C) #include "polarssl/aes.h" #include "polarssl/padlock.h" /* * 32-bit integer manipulation macros (little endian) */ #ifndef GET_ULONG_LE #define GET_ULONG_LE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] ) \ | ( (unsigned long) (b)[(i) + 1] << 8 ) \ | ( (unsigned long) (b)[(i) + 2] << 16 ) \ | ( (unsigned long) (b)[(i) + 3] << 24 ); \ } #endif #ifndef PUT_ULONG_LE #define PUT_ULONG_LE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ } #endif #if defined(POLARSSL_AES_ROM_TABLES) /* * Forward S-box */ static const unsigned char FSb[256] = { 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 }; /* * Forward tables */ #define FT \ \ V(A5,63,63,C6), V(84,7C,7C,F8), V(99,77,77,EE), V(8D,7B,7B,F6), \ V(0D,F2,F2,FF), V(BD,6B,6B,D6), V(B1,6F,6F,DE), V(54,C5,C5,91), \ V(50,30,30,60), V(03,01,01,02), V(A9,67,67,CE), V(7D,2B,2B,56), \ V(19,FE,FE,E7), V(62,D7,D7,B5), V(E6,AB,AB,4D), V(9A,76,76,EC), \ V(45,CA,CA,8F), V(9D,82,82,1F), V(40,C9,C9,89), V(87,7D,7D,FA), \ V(15,FA,FA,EF), V(EB,59,59,B2), V(C9,47,47,8E), V(0B,F0,F0,FB), \ V(EC,AD,AD,41), V(67,D4,D4,B3), V(FD,A2,A2,5F), V(EA,AF,AF,45), \ V(BF,9C,9C,23), V(F7,A4,A4,53), V(96,72,72,E4), V(5B,C0,C0,9B), \ V(C2,B7,B7,75), V(1C,FD,FD,E1), V(AE,93,93,3D), V(6A,26,26,4C), \ V(5A,36,36,6C), V(41,3F,3F,7E), V(02,F7,F7,F5), V(4F,CC,CC,83), \ V(5C,34,34,68), V(F4,A5,A5,51), V(34,E5,E5,D1), V(08,F1,F1,F9), \ V(93,71,71,E2), V(73,D8,D8,AB), V(53,31,31,62), V(3F,15,15,2A), \ V(0C,04,04,08), V(52,C7,C7,95), V(65,23,23,46), V(5E,C3,C3,9D), \ V(28,18,18,30), V(A1,96,96,37), V(0F,05,05,0A), V(B5,9A,9A,2F), \ V(09,07,07,0E), V(36,12,12,24), V(9B,80,80,1B), V(3D,E2,E2,DF), \ V(26,EB,EB,CD), V(69,27,27,4E), V(CD,B2,B2,7F), V(9F,75,75,EA), \ V(1B,09,09,12), V(9E,83,83,1D), V(74,2C,2C,58), V(2E,1A,1A,34), \ V(2D,1B,1B,36), V(B2,6E,6E,DC), V(EE,5A,5A,B4), V(FB,A0,A0,5B), \ V(F6,52,52,A4), V(4D,3B,3B,76), V(61,D6,D6,B7), V(CE,B3,B3,7D), \ V(7B,29,29,52), V(3E,E3,E3,DD), V(71,2F,2F,5E), V(97,84,84,13), \ V(F5,53,53,A6), V(68,D1,D1,B9), V(00,00,00,00), V(2C,ED,ED,C1), \ V(60,20,20,40), V(1F,FC,FC,E3), V(C8,B1,B1,79), V(ED,5B,5B,B6), \ V(BE,6A,6A,D4), V(46,CB,CB,8D), V(D9,BE,BE,67), V(4B,39,39,72), \ V(DE,4A,4A,94), V(D4,4C,4C,98), V(E8,58,58,B0), V(4A,CF,CF,85), \ V(6B,D0,D0,BB), V(2A,EF,EF,C5), V(E5,AA,AA,4F), V(16,FB,FB,ED), \ V(C5,43,43,86), V(D7,4D,4D,9A), V(55,33,33,66), V(94,85,85,11), \ V(CF,45,45,8A), V(10,F9,F9,E9), V(06,02,02,04), V(81,7F,7F,FE), \ V(F0,50,50,A0), V(44,3C,3C,78), V(BA,9F,9F,25), V(E3,A8,A8,4B), \ V(F3,51,51,A2), V(FE,A3,A3,5D), V(C0,40,40,80), V(8A,8F,8F,05), \ V(AD,92,92,3F), V(BC,9D,9D,21), V(48,38,38,70), V(04,F5,F5,F1), \ V(DF,BC,BC,63), V(C1,B6,B6,77), V(75,DA,DA,AF), V(63,21,21,42), \ V(30,10,10,20), V(1A,FF,FF,E5), V(0E,F3,F3,FD), V(6D,D2,D2,BF), \ V(4C,CD,CD,81), V(14,0C,0C,18), V(35,13,13,26), V(2F,EC,EC,C3), \ V(E1,5F,5F,BE), V(A2,97,97,35), V(CC,44,44,88), V(39,17,17,2E), \ V(57,C4,C4,93), V(F2,A7,A7,55), V(82,7E,7E,FC), V(47,3D,3D,7A), \ V(AC,64,64,C8), V(E7,5D,5D,BA), V(2B,19,19,32), V(95,73,73,E6), \ V(A0,60,60,C0), V(98,81,81,19), V(D1,4F,4F,9E), V(7F,DC,DC,A3), \ V(66,22,22,44), V(7E,2A,2A,54), V(AB,90,90,3B), V(83,88,88,0B), \ V(CA,46,46,8C), V(29,EE,EE,C7), V(D3,B8,B8,6B), V(3C,14,14,28), \ V(79,DE,DE,A7), V(E2,5E,5E,BC), V(1D,0B,0B,16), V(76,DB,DB,AD), \ V(3B,E0,E0,DB), V(56,32,32,64), V(4E,3A,3A,74), V(1E,0A,0A,14), \ V(DB,49,49,92), V(0A,06,06,0C), V(6C,24,24,48), V(E4,5C,5C,B8), \ V(5D,C2,C2,9F), V(6E,D3,D3,BD), V(EF,AC,AC,43), V(A6,62,62,C4), \ V(A8,91,91,39), V(A4,95,95,31), V(37,E4,E4,D3), V(8B,79,79,F2), \ V(32,E7,E7,D5), V(43,C8,C8,8B), V(59,37,37,6E), V(B7,6D,6D,DA), \ V(8C,8D,8D,01), V(64,D5,D5,B1), V(D2,4E,4E,9C), V(E0,A9,A9,49), \ V(B4,6C,6C,D8), V(FA,56,56,AC), V(07,F4,F4,F3), V(25,EA,EA,CF), \ V(AF,65,65,CA), V(8E,7A,7A,F4), V(E9,AE,AE,47), V(18,08,08,10), \ V(D5,BA,BA,6F), V(88,78,78,F0), V(6F,25,25,4A), V(72,2E,2E,5C), \ V(24,1C,1C,38), V(F1,A6,A6,57), V(C7,B4,B4,73), V(51,C6,C6,97), \ V(23,E8,E8,CB), V(7C,DD,DD,A1), V(9C,74,74,E8), V(21,1F,1F,3E), \ V(DD,4B,4B,96), V(DC,BD,BD,61), V(86,8B,8B,0D), V(85,8A,8A,0F), \ V(90,70,70,E0), V(42,3E,3E,7C), V(C4,B5,B5,71), V(AA,66,66,CC), \ V(D8,48,48,90), V(05,03,03,06), V(01,F6,F6,F7), V(12,0E,0E,1C), \ V(A3,61,61,C2), V(5F,35,35,6A), V(F9,57,57,AE), V(D0,B9,B9,69), \ V(91,86,86,17), V(58,C1,C1,99), V(27,1D,1D,3A), V(B9,9E,9E,27), \ V(38,E1,E1,D9), V(13,F8,F8,EB), V(B3,98,98,2B), V(33,11,11,22), \ V(BB,69,69,D2), V(70,D9,D9,A9), V(89,8E,8E,07), V(A7,94,94,33), \ V(B6,9B,9B,2D), V(22,1E,1E,3C), V(92,87,87,15), V(20,E9,E9,C9), \ V(49,CE,CE,87), V(FF,55,55,AA), V(78,28,28,50), V(7A,DF,DF,A5), \ V(8F,8C,8C,03), V(F8,A1,A1,59), V(80,89,89,09), V(17,0D,0D,1A), \ V(DA,BF,BF,65), V(31,E6,E6,D7), V(C6,42,42,84), V(B8,68,68,D0), \ V(C3,41,41,82), V(B0,99,99,29), V(77,2D,2D,5A), V(11,0F,0F,1E), \ V(CB,B0,B0,7B), V(FC,54,54,A8), V(D6,BB,BB,6D), V(3A,16,16,2C) #define V(a,b,c,d) 0x##a##b##c##d static const unsigned long FT0[256] = { FT }; #undef V #define V(a,b,c,d) 0x##b##c##d##a static const unsigned long FT1[256] = { FT }; #undef V #define V(a,b,c,d) 0x##c##d##a##b static const unsigned long FT2[256] = { FT }; #undef V #define V(a,b,c,d) 0x##d##a##b##c static const unsigned long FT3[256] = { FT }; #undef V #undef FT /* * Reverse S-box */ static const unsigned char RSb[256] = { 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D }; /* * Reverse tables */ #define RT \ \ V(50,A7,F4,51), V(53,65,41,7E), V(C3,A4,17,1A), V(96,5E,27,3A), \ V(CB,6B,AB,3B), V(F1,45,9D,1F), V(AB,58,FA,AC), V(93,03,E3,4B), \ V(55,FA,30,20), V(F6,6D,76,AD), V(91,76,CC,88), V(25,4C,02,F5), \ V(FC,D7,E5,4F), V(D7,CB,2A,C5), V(80,44,35,26), V(8F,A3,62,B5), \ V(49,5A,B1,DE), V(67,1B,BA,25), V(98,0E,EA,45), V(E1,C0,FE,5D), \ V(02,75,2F,C3), V(12,F0,4C,81), V(A3,97,46,8D), V(C6,F9,D3,6B), \ V(E7,5F,8F,03), V(95,9C,92,15), V(EB,7A,6D,BF), V(DA,59,52,95), \ V(2D,83,BE,D4), V(D3,21,74,58), V(29,69,E0,49), V(44,C8,C9,8E), \ V(6A,89,C2,75), V(78,79,8E,F4), V(6B,3E,58,99), V(DD,71,B9,27), \ V(B6,4F,E1,BE), V(17,AD,88,F0), V(66,AC,20,C9), V(B4,3A,CE,7D), \ V(18,4A,DF,63), V(82,31,1A,E5), V(60,33,51,97), V(45,7F,53,62), \ V(E0,77,64,B1), V(84,AE,6B,BB), V(1C,A0,81,FE), V(94,2B,08,F9), \ V(58,68,48,70), V(19,FD,45,8F), V(87,6C,DE,94), V(B7,F8,7B,52), \ V(23,D3,73,AB), V(E2,02,4B,72), V(57,8F,1F,E3), V(2A,AB,55,66), \ V(07,28,EB,B2), V(03,C2,B5,2F), V(9A,7B,C5,86), V(A5,08,37,D3), \ V(F2,87,28,30), V(B2,A5,BF,23), V(BA,6A,03,02), V(5C,82,16,ED), \ V(2B,1C,CF,8A), V(92,B4,79,A7), V(F0,F2,07,F3), V(A1,E2,69,4E), \ V(CD,F4,DA,65), V(D5,BE,05,06), V(1F,62,34,D1), V(8A,FE,A6,C4), \ V(9D,53,2E,34), V(A0,55,F3,A2), V(32,E1,8A,05), V(75,EB,F6,A4), \ V(39,EC,83,0B), V(AA,EF,60,40), V(06,9F,71,5E), V(51,10,6E,BD), \ V(F9,8A,21,3E), V(3D,06,DD,96), V(AE,05,3E,DD), V(46,BD,E6,4D), \ V(B5,8D,54,91), V(05,5D,C4,71), V(6F,D4,06,04), V(FF,15,50,60), \ V(24,FB,98,19), V(97,E9,BD,D6), V(CC,43,40,89), V(77,9E,D9,67), \ V(BD,42,E8,B0), V(88,8B,89,07), V(38,5B,19,E7), V(DB,EE,C8,79), \ V(47,0A,7C,A1), V(E9,0F,42,7C), V(C9,1E,84,F8), V(00,00,00,00), \ V(83,86,80,09), V(48,ED,2B,32), V(AC,70,11,1E), V(4E,72,5A,6C), \ V(FB,FF,0E,FD), V(56,38,85,0F), V(1E,D5,AE,3D), V(27,39,2D,36), \ V(64,D9,0F,0A), V(21,A6,5C,68), V(D1,54,5B,9B), V(3A,2E,36,24), \ V(B1,67,0A,0C), V(0F,E7,57,93), V(D2,96,EE,B4), V(9E,91,9B,1B), \ V(4F,C5,C0,80), V(A2,20,DC,61), V(69,4B,77,5A), V(16,1A,12,1C), \ V(0A,BA,93,E2), V(E5,2A,A0,C0), V(43,E0,22,3C), V(1D,17,1B,12), \ V(0B,0D,09,0E), V(AD,C7,8B,F2), V(B9,A8,B6,2D), V(C8,A9,1E,14), \ V(85,19,F1,57), V(4C,07,75,AF), V(BB,DD,99,EE), V(FD,60,7F,A3), \ V(9F,26,01,F7), V(BC,F5,72,5C), V(C5,3B,66,44), V(34,7E,FB,5B), \ V(76,29,43,8B), V(DC,C6,23,CB), V(68,FC,ED,B6), V(63,F1,E4,B8), \ V(CA,DC,31,D7), V(10,85,63,42), V(40,22,97,13), V(20,11,C6,84), \ V(7D,24,4A,85), V(F8,3D,BB,D2), V(11,32,F9,AE), V(6D,A1,29,C7), \ V(4B,2F,9E,1D), V(F3,30,B2,DC), V(EC,52,86,0D), V(D0,E3,C1,77), \ V(6C,16,B3,2B), V(99,B9,70,A9), V(FA,48,94,11), V(22,64,E9,47), \ V(C4,8C,FC,A8), V(1A,3F,F0,A0), V(D8,2C,7D,56), V(EF,90,33,22), \ V(C7,4E,49,87), V(C1,D1,38,D9), V(FE,A2,CA,8C), V(36,0B,D4,98), \ V(CF,81,F5,A6), V(28,DE,7A,A5), V(26,8E,B7,DA), V(A4,BF,AD,3F), \ V(E4,9D,3A,2C), V(0D,92,78,50), V(9B,CC,5F,6A), V(62,46,7E,54), \ V(C2,13,8D,F6), V(E8,B8,D8,90), V(5E,F7,39,2E), V(F5,AF,C3,82), \ V(BE,80,5D,9F), V(7C,93,D0,69), V(A9,2D,D5,6F), V(B3,12,25,CF), \ V(3B,99,AC,C8), V(A7,7D,18,10), V(6E,63,9C,E8), V(7B,BB,3B,DB), \ V(09,78,26,CD), V(F4,18,59,6E), V(01,B7,9A,EC), V(A8,9A,4F,83), \ V(65,6E,95,E6), V(7E,E6,FF,AA), V(08,CF,BC,21), V(E6,E8,15,EF), \ V(D9,9B,E7,BA), V(CE,36,6F,4A), V(D4,09,9F,EA), V(D6,7C,B0,29), \ V(AF,B2,A4,31), V(31,23,3F,2A), V(30,94,A5,C6), V(C0,66,A2,35), \ V(37,BC,4E,74), V(A6,CA,82,FC), V(B0,D0,90,E0), V(15,D8,A7,33), \ V(4A,98,04,F1), V(F7,DA,EC,41), V(0E,50,CD,7F), V(2F,F6,91,17), \ V(8D,D6,4D,76), V(4D,B0,EF,43), V(54,4D,AA,CC), V(DF,04,96,E4), \ V(E3,B5,D1,9E), V(1B,88,6A,4C), V(B8,1F,2C,C1), V(7F,51,65,46), \ V(04,EA,5E,9D), V(5D,35,8C,01), V(73,74,87,FA), V(2E,41,0B,FB), \ V(5A,1D,67,B3), V(52,D2,DB,92), V(33,56,10,E9), V(13,47,D6,6D), \ V(8C,61,D7,9A), V(7A,0C,A1,37), V(8E,14,F8,59), V(89,3C,13,EB), \ V(EE,27,A9,CE), V(35,C9,61,B7), V(ED,E5,1C,E1), V(3C,B1,47,7A), \ V(59,DF,D2,9C), V(3F,73,F2,55), V(79,CE,14,18), V(BF,37,C7,73), \ V(EA,CD,F7,53), V(5B,AA,FD,5F), V(14,6F,3D,DF), V(86,DB,44,78), \ V(81,F3,AF,CA), V(3E,C4,68,B9), V(2C,34,24,38), V(5F,40,A3,C2), \ V(72,C3,1D,16), V(0C,25,E2,BC), V(8B,49,3C,28), V(41,95,0D,FF), \ V(71,01,A8,39), V(DE,B3,0C,08), V(9C,E4,B4,D8), V(90,C1,56,64), \ V(61,84,CB,7B), V(70,B6,32,D5), V(74,5C,6C,48), V(42,57,B8,D0) #define V(a,b,c,d) 0x##a##b##c##d static const unsigned long RT0[256] = { RT }; #undef V #define V(a,b,c,d) 0x##b##c##d##a static const unsigned long RT1[256] = { RT }; #undef V #define V(a,b,c,d) 0x##c##d##a##b static const unsigned long RT2[256] = { RT }; #undef V #define V(a,b,c,d) 0x##d##a##b##c static const unsigned long RT3[256] = { RT }; #undef V #undef RT /* * Round constants */ static const unsigned long RCON[10] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036 }; #else /* * Forward S-box & tables */ static unsigned char FSb[256]; static unsigned long FT0[256]; static unsigned long FT1[256]; static unsigned long FT2[256]; static unsigned long FT3[256]; /* * Reverse S-box & tables */ static unsigned char RSb[256]; static unsigned long RT0[256]; static unsigned long RT1[256]; static unsigned long RT2[256]; static unsigned long RT3[256]; /* * Round constants */ static unsigned long RCON[10]; /* * Tables generation code */ #define ROTL8(x) ( ( x << 8 ) & 0xFFFFFFFF ) | ( x >> 24 ) #define XTIME(x) ( ( x << 1 ) ^ ( ( x & 0x80 ) ? 0x1B : 0x00 ) ) #define MUL(x,y) ( ( x && y ) ? pow[(log[x]+log[y]) % 255] : 0 ) static int aes_init_done = 0; static void aes_gen_tables( void ) { int i, x, y, z; int pow[256]; int log[256]; /* * compute pow and log tables over GF(2^8) */ for( i = 0, x = 1; i < 256; i++ ) { pow[i] = x; log[x] = i; x = ( x ^ XTIME( x ) ) & 0xFF; } /* * calculate the round constants */ for( i = 0, x = 1; i < 10; i++ ) { RCON[i] = (unsigned long) x; x = XTIME( x ) & 0xFF; } /* * generate the forward and reverse S-boxes */ FSb[0x00] = 0x63; RSb[0x63] = 0x00; for( i = 1; i < 256; i++ ) { x = pow[255 - log[i]]; y = x; y = ( (y << 1) | (y >> 7) ) & 0xFF; x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF; x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF; x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF; x ^= y ^ 0x63; FSb[i] = (unsigned char) x; RSb[x] = (unsigned char) i; } /* * generate the forward and reverse tables */ for( i = 0; i < 256; i++ ) { x = FSb[i]; y = XTIME( x ) & 0xFF; z = ( y ^ x ) & 0xFF; FT0[i] = ( (unsigned long) y ) ^ ( (unsigned long) x << 8 ) ^ ( (unsigned long) x << 16 ) ^ ( (unsigned long) z << 24 ); FT1[i] = ROTL8( FT0[i] ); FT2[i] = ROTL8( FT1[i] ); FT3[i] = ROTL8( FT2[i] ); x = RSb[i]; RT0[i] = ( (unsigned long) MUL( 0x0E, x ) ) ^ ( (unsigned long) MUL( 0x09, x ) << 8 ) ^ ( (unsigned long) MUL( 0x0D, x ) << 16 ) ^ ( (unsigned long) MUL( 0x0B, x ) << 24 ); RT1[i] = ROTL8( RT0[i] ); RT2[i] = ROTL8( RT1[i] ); RT3[i] = ROTL8( RT2[i] ); } } #endif /* * AES key schedule (encryption) */ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize ) { unsigned int i; unsigned long *RK; #if !defined(POLARSSL_AES_ROM_TABLES) if( aes_init_done == 0 ) { aes_gen_tables(); aes_init_done = 1; } #endif switch( keysize ) { case 128: ctx->nr = 10; break; case 192: ctx->nr = 12; break; case 256: ctx->nr = 14; break; default : return( POLARSSL_ERR_AES_INVALID_KEY_LENGTH ); } #if defined(PADLOCK_ALIGN16) ctx->rk = RK = PADLOCK_ALIGN16( ctx->buf ); #else ctx->rk = RK = ctx->buf; #endif for( i = 0; i < (keysize >> 5); i++ ) { GET_ULONG_LE( RK[i], key, i << 2 ); } switch( ctx->nr ) { case 10: for( i = 0; i < 10; i++, RK += 4 ) { RK[4] = RK[0] ^ RCON[i] ^ ( (unsigned long) FSb[ ( RK[3] >> 8 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( RK[3] >> 16 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( RK[3] >> 24 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( RK[3] ) & 0xFF ] << 24 ); RK[5] = RK[1] ^ RK[4]; RK[6] = RK[2] ^ RK[5]; RK[7] = RK[3] ^ RK[6]; } break; case 12: for( i = 0; i < 8; i++, RK += 6 ) { RK[6] = RK[0] ^ RCON[i] ^ ( (unsigned long) FSb[ ( RK[5] >> 8 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( RK[5] >> 16 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( RK[5] >> 24 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( RK[5] ) & 0xFF ] << 24 ); RK[7] = RK[1] ^ RK[6]; RK[8] = RK[2] ^ RK[7]; RK[9] = RK[3] ^ RK[8]; RK[10] = RK[4] ^ RK[9]; RK[11] = RK[5] ^ RK[10]; } break; case 14: for( i = 0; i < 7; i++, RK += 8 ) { RK[8] = RK[0] ^ RCON[i] ^ ( (unsigned long) FSb[ ( RK[7] >> 8 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( RK[7] >> 16 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( RK[7] >> 24 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( RK[7] ) & 0xFF ] << 24 ); RK[9] = RK[1] ^ RK[8]; RK[10] = RK[2] ^ RK[9]; RK[11] = RK[3] ^ RK[10]; RK[12] = RK[4] ^ ( (unsigned long) FSb[ ( RK[11] ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( RK[11] >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( RK[11] >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( RK[11] >> 24 ) & 0xFF ] << 24 ); RK[13] = RK[5] ^ RK[12]; RK[14] = RK[6] ^ RK[13]; RK[15] = RK[7] ^ RK[14]; } break; default: break; } return( 0 ); } /* * AES key schedule (decryption) */ int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize ) { int i, j; aes_context cty; unsigned long *RK; unsigned long *SK; int ret; switch( keysize ) { case 128: ctx->nr = 10; break; case 192: ctx->nr = 12; break; case 256: ctx->nr = 14; break; default : return( POLARSSL_ERR_AES_INVALID_KEY_LENGTH ); } #if defined(PADLOCK_ALIGN16) ctx->rk = RK = PADLOCK_ALIGN16( ctx->buf ); #else ctx->rk = RK = ctx->buf; #endif ret = aes_setkey_enc( &cty, key, keysize ); if( ret != 0 ) return( ret ); SK = cty.rk + cty.nr * 4; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; for( i = ctx->nr - 1, SK -= 8; i > 0; i--, SK -= 8 ) { for( j = 0; j < 4; j++, SK++ ) { *RK++ = RT0[ FSb[ ( *SK ) & 0xFF ] ] ^ RT1[ FSb[ ( *SK >> 8 ) & 0xFF ] ] ^ RT2[ FSb[ ( *SK >> 16 ) & 0xFF ] ] ^ RT3[ FSb[ ( *SK >> 24 ) & 0xFF ] ]; } } *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; memset( &cty, 0, sizeof( aes_context ) ); return( 0 ); } #define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ { \ X0 = *RK++ ^ FT0[ ( Y0 ) & 0xFF ] ^ \ FT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ FT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ FT3[ ( Y3 >> 24 ) & 0xFF ]; \ \ X1 = *RK++ ^ FT0[ ( Y1 ) & 0xFF ] ^ \ FT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ FT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ FT3[ ( Y0 >> 24 ) & 0xFF ]; \ \ X2 = *RK++ ^ FT0[ ( Y2 ) & 0xFF ] ^ \ FT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ FT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ FT3[ ( Y1 >> 24 ) & 0xFF ]; \ \ X3 = *RK++ ^ FT0[ ( Y3 ) & 0xFF ] ^ \ FT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ FT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ FT3[ ( Y2 >> 24 ) & 0xFF ]; \ } #define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ { \ X0 = *RK++ ^ RT0[ ( Y0 ) & 0xFF ] ^ \ RT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ RT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ RT3[ ( Y1 >> 24 ) & 0xFF ]; \ \ X1 = *RK++ ^ RT0[ ( Y1 ) & 0xFF ] ^ \ RT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ RT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ RT3[ ( Y2 >> 24 ) & 0xFF ]; \ \ X2 = *RK++ ^ RT0[ ( Y2 ) & 0xFF ] ^ \ RT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ RT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ RT3[ ( Y3 >> 24 ) & 0xFF ]; \ \ X3 = *RK++ ^ RT0[ ( Y3 ) & 0xFF ] ^ \ RT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ RT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ RT3[ ( Y0 >> 24 ) & 0xFF ]; \ } /* * AES-ECB block encryption/decryption */ int aes_crypt_ecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) { int i; unsigned long *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; #if defined(POLARSSL_PADLOCK_C) && defined(POLARSSL_HAVE_X86) if( padlock_supports( PADLOCK_ACE ) ) { if( padlock_xcryptecb( ctx, mode, input, output ) == 0 ) return( 0 ); // If padlock data misaligned, we just fall back to // unaccelerated mode // } #endif RK = ctx->rk; GET_ULONG_LE( X0, input, 0 ); X0 ^= *RK++; GET_ULONG_LE( X1, input, 4 ); X1 ^= *RK++; GET_ULONG_LE( X2, input, 8 ); X2 ^= *RK++; GET_ULONG_LE( X3, input, 12 ); X3 ^= *RK++; if( mode == AES_DECRYPT ) { for( i = (ctx->nr >> 1) - 1; i > 0; i-- ) { AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); } AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); X0 = *RK++ ^ \ ( (unsigned long) RSb[ ( Y0 ) & 0xFF ] ) ^ ( (unsigned long) RSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) RSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) RSb[ ( Y1 >> 24 ) & 0xFF ] << 24 ); X1 = *RK++ ^ \ ( (unsigned long) RSb[ ( Y1 ) & 0xFF ] ) ^ ( (unsigned long) RSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) RSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) RSb[ ( Y2 >> 24 ) & 0xFF ] << 24 ); X2 = *RK++ ^ \ ( (unsigned long) RSb[ ( Y2 ) & 0xFF ] ) ^ ( (unsigned long) RSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) RSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) RSb[ ( Y3 >> 24 ) & 0xFF ] << 24 ); X3 = *RK++ ^ \ ( (unsigned long) RSb[ ( Y3 ) & 0xFF ] ) ^ ( (unsigned long) RSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) RSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) RSb[ ( Y0 >> 24 ) & 0xFF ] << 24 ); } else /* AES_ENCRYPT */ { for( i = (ctx->nr >> 1) - 1; i > 0; i-- ) { AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); } AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); X0 = *RK++ ^ \ ( (unsigned long) FSb[ ( Y0 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( Y3 >> 24 ) & 0xFF ] << 24 ); X1 = *RK++ ^ \ ( (unsigned long) FSb[ ( Y1 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( Y0 >> 24 ) & 0xFF ] << 24 ); X2 = *RK++ ^ \ ( (unsigned long) FSb[ ( Y2 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( Y1 >> 24 ) & 0xFF ] << 24 ); X3 = *RK++ ^ \ ( (unsigned long) FSb[ ( Y3 ) & 0xFF ] ) ^ ( (unsigned long) FSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( (unsigned long) FSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( (unsigned long) FSb[ ( Y2 >> 24 ) & 0xFF ] << 24 ); } PUT_ULONG_LE( X0, output, 0 ); PUT_ULONG_LE( X1, output, 4 ); PUT_ULONG_LE( X2, output, 8 ); PUT_ULONG_LE( X3, output, 12 ); return( 0 ); } /* * AES-CBC buffer encryption/decryption */ int aes_crypt_cbc( aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ) { int i; unsigned char temp[16]; if( length % 16 ) return( POLARSSL_ERR_AES_INVALID_INPUT_LENGTH ); #if defined(POLARSSL_PADLOCK_C) && defined(POLARSSL_HAVE_X86) if( padlock_supports( PADLOCK_ACE ) ) { if( padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 ) return( 0 ); // If padlock data misaligned, we just fall back to // unaccelerated mode // } #endif if( mode == AES_DECRYPT ) { while( length > 0 ) { memcpy( temp, input, 16 ); aes_crypt_ecb( ctx, mode, input, output ); for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); memcpy( iv, temp, 16 ); input += 16; output += 16; length -= 16; } } else { while( length > 0 ) { for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); aes_crypt_ecb( ctx, mode, output, output ); memcpy( iv, output, 16 ); input += 16; output += 16; length -= 16; } } return( 0 ); } #if defined(POLARSSL_CIPHER_MODE_CFB) /* * AES-CFB128 buffer encryption/decryption */ int aes_crypt_cfb128( aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ) { int c; size_t n = *iv_off; if( mode == AES_DECRYPT ) { while( length-- ) { if( n == 0 ) aes_crypt_ecb( ctx, AES_ENCRYPT, iv, iv ); c = *input++; *output++ = (unsigned char)( c ^ iv[n] ); iv[n] = (unsigned char) c; n = (n + 1) & 0x0F; } } else { while( length-- ) { if( n == 0 ) aes_crypt_ecb( ctx, AES_ENCRYPT, iv, iv ); iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); n = (n + 1) & 0x0F; } } *iv_off = n; return( 0 ); } #endif /*POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) /* * AES-CTR buffer encryption/decryption */ int aes_crypt_ctr( aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ) { int c, i, cb; size_t n = *nc_off; while( length-- ) { if( n == 0 ) { aes_crypt_ecb( ctx, AES_ENCRYPT, nonce_counter, stream_block ); i = 15; do { nonce_counter[i]++; cb = nonce_counter[i] == 0; } while( i-- && cb ); } c = *input++; *output++ = (unsigned char)( c ^ stream_block[n] ); n = (n + 1) & 0x0F; } *nc_off = n; return( 0 ); } #endif /* POLARSSL_CIPHER_MODE_CTR */ #if defined(POLARSSL_SELF_TEST) #include /* * AES test vectors from: * * http://csrc.nist.gov/archive/aes/rijndael/rijndael-vals.zip */ static const unsigned char aes_test_ecb_dec[3][16] = { { 0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C, 0x58, 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0 }, { 0x48, 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, 0x92, 0x29, 0x31, 0x9C, 0x19, 0xF1, 0x5B, 0xA4 }, { 0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB, 0x38, 0x2D, 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE } }; static const unsigned char aes_test_ecb_enc[3][16] = { { 0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D, 0x73, 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F }, { 0xF3, 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, 0x38, 0xF0, 0x41, 0x56, 0x06, 0x31, 0xB1, 0x14 }, { 0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0, 0xEE, 0x5D, 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4 } }; static const unsigned char aes_test_cbc_dec[3][16] = { { 0xFA, 0xCA, 0x37, 0xE0, 0xB0, 0xC8, 0x53, 0x73, 0xDF, 0x70, 0x6E, 0x73, 0xF7, 0xC9, 0xAF, 0x86 }, { 0x5D, 0xF6, 0x78, 0xDD, 0x17, 0xBA, 0x4E, 0x75, 0xB6, 0x17, 0x68, 0xC6, 0xAD, 0xEF, 0x7C, 0x7B }, { 0x48, 0x04, 0xE1, 0x81, 0x8F, 0xE6, 0x29, 0x75, 0x19, 0xA3, 0xE8, 0x8C, 0x57, 0x31, 0x04, 0x13 } }; static const unsigned char aes_test_cbc_enc[3][16] = { { 0x8A, 0x05, 0xFC, 0x5E, 0x09, 0x5A, 0xF4, 0x84, 0x8A, 0x08, 0xD3, 0x28, 0xD3, 0x68, 0x8E, 0x3D }, { 0x7B, 0xD9, 0x66, 0xD5, 0x3A, 0xD8, 0xC1, 0xBB, 0x85, 0xD2, 0xAD, 0xFA, 0xE8, 0x7B, 0xB1, 0x04 }, { 0xFE, 0x3C, 0x53, 0x65, 0x3E, 0x2F, 0x45, 0xB5, 0x6F, 0xCD, 0x88, 0xB2, 0xCC, 0x89, 0x8F, 0xF0 } }; #if defined(POLARSSL_CIPHER_MODE_CFB) /* * AES-CFB128 test vectors from: * * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */ static const unsigned char aes_test_cfb128_key[3][32] = { { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }, { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B }, { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } }; static const unsigned char aes_test_cfb128_iv[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; static const unsigned char aes_test_cfb128_pt[64] = { 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10 }; static const unsigned char aes_test_cfb128_ct[3][64] = { { 0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, 0xC8, 0xA6, 0x45, 0x37, 0xA0, 0xB3, 0xA9, 0x3F, 0xCD, 0xE3, 0xCD, 0xAD, 0x9F, 0x1C, 0xE5, 0x8B, 0x26, 0x75, 0x1F, 0x67, 0xA3, 0xCB, 0xB1, 0x40, 0xB1, 0x80, 0x8C, 0xF1, 0x87, 0xA4, 0xF4, 0xDF, 0xC0, 0x4B, 0x05, 0x35, 0x7C, 0x5D, 0x1C, 0x0E, 0xEA, 0xC4, 0xC6, 0x6F, 0x9F, 0xF7, 0xF2, 0xE6 }, { 0xCD, 0xC8, 0x0D, 0x6F, 0xDD, 0xF1, 0x8C, 0xAB, 0x34, 0xC2, 0x59, 0x09, 0xC9, 0x9A, 0x41, 0x74, 0x67, 0xCE, 0x7F, 0x7F, 0x81, 0x17, 0x36, 0x21, 0x96, 0x1A, 0x2B, 0x70, 0x17, 0x1D, 0x3D, 0x7A, 0x2E, 0x1E, 0x8A, 0x1D, 0xD5, 0x9B, 0x88, 0xB1, 0xC8, 0xE6, 0x0F, 0xED, 0x1E, 0xFA, 0xC4, 0xC9, 0xC0, 0x5F, 0x9F, 0x9C, 0xA9, 0x83, 0x4F, 0xA0, 0x42, 0xAE, 0x8F, 0xBA, 0x58, 0x4B, 0x09, 0xFF }, { 0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, 0x39, 0xFF, 0xED, 0x14, 0x3B, 0x28, 0xB1, 0xC8, 0x32, 0x11, 0x3C, 0x63, 0x31, 0xE5, 0x40, 0x7B, 0xDF, 0x10, 0x13, 0x24, 0x15, 0xE5, 0x4B, 0x92, 0xA1, 0x3E, 0xD0, 0xA8, 0x26, 0x7A, 0xE2, 0xF9, 0x75, 0xA3, 0x85, 0x74, 0x1A, 0xB9, 0xCE, 0xF8, 0x20, 0x31, 0x62, 0x3D, 0x55, 0xB1, 0xE4, 0x71 } }; #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) /* * AES-CTR test vectors from: * * http://www.faqs.org/rfcs/rfc3686.html */ static const unsigned char aes_test_ctr_key[3][16] = { { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E }, { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63 }, { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC } }; static const unsigned char aes_test_ctr_nonce_counter[3][16] = { { 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, { 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01 } }; static const unsigned char aes_test_ctr_pt[3][48] = { { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23 } }; static const unsigned char aes_test_ctr_ct[3][48] = { { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 }, { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 }, { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, 0x25, 0xB2, 0x07, 0x2F } }; static const int aes_test_ctr_len[3] = { 16, 32, 36 }; #endif /* POLARSSL_CIPHER_MODE_CTR */ /* * Checkup routine */ int aes_self_test( int verbose ) { int i, j, u, v; unsigned char key[32]; unsigned char buf[64]; unsigned char prv[16]; unsigned char iv[16]; #if defined(POLARSSL_CIPHER_MODE_CTR) || defined(POLARSSL_CIPHER_MODE_CFB) size_t offset; #endif #if defined(POLARSSL_CIPHER_MODE_CTR) int len; unsigned char nonce_counter[16]; unsigned char stream_block[16]; #endif aes_context ctx; memset( key, 0, 32 ); /* * ECB mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " AES-ECB-%3d (%s): ", 128 + u * 64, ( v == AES_DECRYPT ) ? "dec" : "enc" ); memset( buf, 0, 16 ); if( v == AES_DECRYPT ) { aes_setkey_dec( &ctx, key, 128 + u * 64 ); for( j = 0; j < 10000; j++ ) aes_crypt_ecb( &ctx, v, buf, buf ); if( memcmp( buf, aes_test_ecb_dec[u], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } else { aes_setkey_enc( &ctx, key, 128 + u * 64 ); for( j = 0; j < 10000; j++ ) aes_crypt_ecb( &ctx, v, buf, buf ); if( memcmp( buf, aes_test_ecb_enc[u], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); /* * CBC mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " AES-CBC-%3d (%s): ", 128 + u * 64, ( v == AES_DECRYPT ) ? "dec" : "enc" ); memset( iv , 0, 16 ); memset( prv, 0, 16 ); memset( buf, 0, 16 ); if( v == AES_DECRYPT ) { aes_setkey_dec( &ctx, key, 128 + u * 64 ); for( j = 0; j < 10000; j++ ) aes_crypt_cbc( &ctx, v, 16, iv, buf, buf ); if( memcmp( buf, aes_test_cbc_dec[u], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } else { aes_setkey_enc( &ctx, key, 128 + u * 64 ); for( j = 0; j < 10000; j++ ) { unsigned char tmp[16]; aes_crypt_cbc( &ctx, v, 16, iv, buf, buf ); memcpy( tmp, prv, 16 ); memcpy( prv, buf, 16 ); memcpy( buf, tmp, 16 ); } if( memcmp( prv, aes_test_cbc_enc[u], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); #if defined(POLARSSL_CIPHER_MODE_CFB) /* * CFB128 mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " AES-CFB128-%3d (%s): ", 128 + u * 64, ( v == AES_DECRYPT ) ? "dec" : "enc" ); memcpy( iv, aes_test_cfb128_iv, 16 ); memcpy( key, aes_test_cfb128_key[u], 16 + u * 8 ); offset = 0; aes_setkey_enc( &ctx, key, 128 + u * 64 ); if( v == AES_DECRYPT ) { memcpy( buf, aes_test_cfb128_ct[u], 64 ); aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf ); if( memcmp( buf, aes_test_cfb128_pt, 64 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } else { memcpy( buf, aes_test_cfb128_pt, 64 ); aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf ); if( memcmp( buf, aes_test_cfb128_ct[u], 64 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) /* * CTR mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " AES-CTR-128 (%s): ", ( v == AES_DECRYPT ) ? "dec" : "enc" ); memcpy( nonce_counter, aes_test_ctr_nonce_counter[u], 16 ); memcpy( key, aes_test_ctr_key[u], 16 ); offset = 0; aes_setkey_enc( &ctx, key, 128 ); if( v == AES_DECRYPT ) { len = aes_test_ctr_len[u]; memcpy( buf, aes_test_ctr_ct[u], len ); aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); if( memcmp( buf, aes_test_ctr_pt[u], len ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } else { len = aes_test_ctr_len[u]; memcpy( buf, aes_test_ctr_pt[u], len ); aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); if( memcmp( buf, aes_test_ctr_ct[u], len ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); #endif /* POLARSSL_CIPHER_MODE_CTR */ return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/sha2.c0000644000014601777760000005167012165464055022311 0ustar00jenkinsnogroup00000000000000/* * FIPS-180-2 compliant SHA-256 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The SHA-256 Secure Hash Standard was published by NIST in 2002. * * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_SHA2_C) #include "polarssl/sha2.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif /* * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE #define GET_ULONG_BE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ | ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (unsigned long) (b)[(i) + 3] ); \ } #endif #ifndef PUT_ULONG_BE #define PUT_ULONG_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ } #endif /* * SHA-256 context setup */ void sha2_starts( sha2_context *ctx, int is224 ) { ctx->total[0] = 0; ctx->total[1] = 0; if( is224 == 0 ) { /* SHA-256 */ ctx->state[0] = 0x6A09E667; ctx->state[1] = 0xBB67AE85; ctx->state[2] = 0x3C6EF372; ctx->state[3] = 0xA54FF53A; ctx->state[4] = 0x510E527F; ctx->state[5] = 0x9B05688C; ctx->state[6] = 0x1F83D9AB; ctx->state[7] = 0x5BE0CD19; } else { /* SHA-224 */ ctx->state[0] = 0xC1059ED8; ctx->state[1] = 0x367CD507; ctx->state[2] = 0x3070DD17; ctx->state[3] = 0xF70E5939; ctx->state[4] = 0xFFC00B31; ctx->state[5] = 0x68581511; ctx->state[6] = 0x64F98FA7; ctx->state[7] = 0xBEFA4FA4; } ctx->is224 = is224; } static void sha2_process( sha2_context *ctx, const unsigned char data[64] ) { unsigned long temp1, temp2, W[64]; unsigned long A, B, C, D, E, F, G, H; GET_ULONG_BE( W[ 0], data, 0 ); GET_ULONG_BE( W[ 1], data, 4 ); GET_ULONG_BE( W[ 2], data, 8 ); GET_ULONG_BE( W[ 3], data, 12 ); GET_ULONG_BE( W[ 4], data, 16 ); GET_ULONG_BE( W[ 5], data, 20 ); GET_ULONG_BE( W[ 6], data, 24 ); GET_ULONG_BE( W[ 7], data, 28 ); GET_ULONG_BE( W[ 8], data, 32 ); GET_ULONG_BE( W[ 9], data, 36 ); GET_ULONG_BE( W[10], data, 40 ); GET_ULONG_BE( W[11], data, 44 ); GET_ULONG_BE( W[12], data, 48 ); GET_ULONG_BE( W[13], data, 52 ); GET_ULONG_BE( W[14], data, 56 ); GET_ULONG_BE( W[15], data, 60 ); #define SHR(x,n) ((x & 0xFFFFFFFF) >> n) #define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) #define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) #define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) #define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) #define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) #define F0(x,y,z) ((x & y) | (z & (x | y))) #define F1(x,y,z) (z ^ (x & (y ^ z))) #define R(t) \ ( \ W[t] = S1(W[t - 2]) + W[t - 7] + \ S0(W[t - 15]) + W[t - 16] \ ) #define P(a,b,c,d,e,f,g,h,x,K) \ { \ temp1 = h + S3(e) + F1(e,f,g) + K + x; \ temp2 = S2(a) + F0(a,b,c); \ d += temp1; h = temp1 + temp2; \ } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; E = ctx->state[4]; F = ctx->state[5]; G = ctx->state[6]; H = ctx->state[7]; P( A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98 ); P( H, A, B, C, D, E, F, G, W[ 1], 0x71374491 ); P( G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF ); P( F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5 ); P( E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B ); P( D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1 ); P( C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4 ); P( B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5 ); P( A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98 ); P( H, A, B, C, D, E, F, G, W[ 9], 0x12835B01 ); P( G, H, A, B, C, D, E, F, W[10], 0x243185BE ); P( F, G, H, A, B, C, D, E, W[11], 0x550C7DC3 ); P( E, F, G, H, A, B, C, D, W[12], 0x72BE5D74 ); P( D, E, F, G, H, A, B, C, W[13], 0x80DEB1FE ); P( C, D, E, F, G, H, A, B, W[14], 0x9BDC06A7 ); P( B, C, D, E, F, G, H, A, W[15], 0xC19BF174 ); P( A, B, C, D, E, F, G, H, R(16), 0xE49B69C1 ); P( H, A, B, C, D, E, F, G, R(17), 0xEFBE4786 ); P( G, H, A, B, C, D, E, F, R(18), 0x0FC19DC6 ); P( F, G, H, A, B, C, D, E, R(19), 0x240CA1CC ); P( E, F, G, H, A, B, C, D, R(20), 0x2DE92C6F ); P( D, E, F, G, H, A, B, C, R(21), 0x4A7484AA ); P( C, D, E, F, G, H, A, B, R(22), 0x5CB0A9DC ); P( B, C, D, E, F, G, H, A, R(23), 0x76F988DA ); P( A, B, C, D, E, F, G, H, R(24), 0x983E5152 ); P( H, A, B, C, D, E, F, G, R(25), 0xA831C66D ); P( G, H, A, B, C, D, E, F, R(26), 0xB00327C8 ); P( F, G, H, A, B, C, D, E, R(27), 0xBF597FC7 ); P( E, F, G, H, A, B, C, D, R(28), 0xC6E00BF3 ); P( D, E, F, G, H, A, B, C, R(29), 0xD5A79147 ); P( C, D, E, F, G, H, A, B, R(30), 0x06CA6351 ); P( B, C, D, E, F, G, H, A, R(31), 0x14292967 ); P( A, B, C, D, E, F, G, H, R(32), 0x27B70A85 ); P( H, A, B, C, D, E, F, G, R(33), 0x2E1B2138 ); P( G, H, A, B, C, D, E, F, R(34), 0x4D2C6DFC ); P( F, G, H, A, B, C, D, E, R(35), 0x53380D13 ); P( E, F, G, H, A, B, C, D, R(36), 0x650A7354 ); P( D, E, F, G, H, A, B, C, R(37), 0x766A0ABB ); P( C, D, E, F, G, H, A, B, R(38), 0x81C2C92E ); P( B, C, D, E, F, G, H, A, R(39), 0x92722C85 ); P( A, B, C, D, E, F, G, H, R(40), 0xA2BFE8A1 ); P( H, A, B, C, D, E, F, G, R(41), 0xA81A664B ); P( G, H, A, B, C, D, E, F, R(42), 0xC24B8B70 ); P( F, G, H, A, B, C, D, E, R(43), 0xC76C51A3 ); P( E, F, G, H, A, B, C, D, R(44), 0xD192E819 ); P( D, E, F, G, H, A, B, C, R(45), 0xD6990624 ); P( C, D, E, F, G, H, A, B, R(46), 0xF40E3585 ); P( B, C, D, E, F, G, H, A, R(47), 0x106AA070 ); P( A, B, C, D, E, F, G, H, R(48), 0x19A4C116 ); P( H, A, B, C, D, E, F, G, R(49), 0x1E376C08 ); P( G, H, A, B, C, D, E, F, R(50), 0x2748774C ); P( F, G, H, A, B, C, D, E, R(51), 0x34B0BCB5 ); P( E, F, G, H, A, B, C, D, R(52), 0x391C0CB3 ); P( D, E, F, G, H, A, B, C, R(53), 0x4ED8AA4A ); P( C, D, E, F, G, H, A, B, R(54), 0x5B9CCA4F ); P( B, C, D, E, F, G, H, A, R(55), 0x682E6FF3 ); P( A, B, C, D, E, F, G, H, R(56), 0x748F82EE ); P( H, A, B, C, D, E, F, G, R(57), 0x78A5636F ); P( G, H, A, B, C, D, E, F, R(58), 0x84C87814 ); P( F, G, H, A, B, C, D, E, R(59), 0x8CC70208 ); P( E, F, G, H, A, B, C, D, R(60), 0x90BEFFFA ); P( D, E, F, G, H, A, B, C, R(61), 0xA4506CEB ); P( C, D, E, F, G, H, A, B, R(62), 0xBEF9A3F7 ); P( B, C, D, E, F, G, H, A, R(63), 0xC67178F2 ); ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; ctx->state[4] += E; ctx->state[5] += F; ctx->state[6] += G; ctx->state[7] += H; } /* * SHA-256 process buffer */ void sha2_update( sha2_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; unsigned long left; if( ilen <= 0 ) return; left = ctx->total[0] & 0x3F; fill = 64 - left; ctx->total[0] += (unsigned long) ilen; ctx->total[0] &= 0xFFFFFFFF; if( ctx->total[0] < (unsigned long) ilen ) ctx->total[1]++; if( left && ilen >= fill ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); sha2_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; } while( ilen >= 64 ) { sha2_process( ctx, input ); input += 64; ilen -= 64; } if( ilen > 0 ) { memcpy( (void *) (ctx->buffer + left), (void *) input, ilen ); } } static const unsigned char sha2_padding[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * SHA-256 final digest */ void sha2_finish( sha2_context *ctx, unsigned char output[32] ) { unsigned long last, padn; unsigned long high, low; unsigned char msglen[8]; high = ( ctx->total[0] >> 29 ) | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_ULONG_BE( high, msglen, 0 ); PUT_ULONG_BE( low, msglen, 4 ); last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); sha2_update( ctx, (unsigned char *) sha2_padding, padn ); sha2_update( ctx, msglen, 8 ); PUT_ULONG_BE( ctx->state[0], output, 0 ); PUT_ULONG_BE( ctx->state[1], output, 4 ); PUT_ULONG_BE( ctx->state[2], output, 8 ); PUT_ULONG_BE( ctx->state[3], output, 12 ); PUT_ULONG_BE( ctx->state[4], output, 16 ); PUT_ULONG_BE( ctx->state[5], output, 20 ); PUT_ULONG_BE( ctx->state[6], output, 24 ); if( ctx->is224 == 0 ) PUT_ULONG_BE( ctx->state[7], output, 28 ); } /* * output = SHA-256( input buffer ) */ void sha2( const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ) { sha2_context ctx; sha2_starts( &ctx, is224 ); sha2_update( &ctx, input, ilen ); sha2_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha2_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = SHA-256( file contents ) */ int sha2_file( const char *path, unsigned char output[32], int is224 ) { FILE *f; size_t n; sha2_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_SHA2_FILE_IO_ERROR ); sha2_starts( &ctx, is224 ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) sha2_update( &ctx, buf, n ); sha2_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha2_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_SHA2_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * SHA-256 HMAC context setup */ void sha2_hmac_starts( sha2_context *ctx, const unsigned char *key, size_t keylen, int is224 ) { size_t i; unsigned char sum[32]; if( keylen > 64 ) { sha2( key, keylen, sum, is224 ); keylen = ( is224 ) ? 28 : 32; key = sum; } memset( ctx->ipad, 0x36, 64 ); memset( ctx->opad, 0x5C, 64 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } sha2_starts( ctx, is224 ); sha2_update( ctx, ctx->ipad, 64 ); memset( sum, 0, sizeof( sum ) ); } /* * SHA-256 HMAC process buffer */ void sha2_hmac_update( sha2_context *ctx, const unsigned char *input, size_t ilen ) { sha2_update( ctx, input, ilen ); } /* * SHA-256 HMAC final digest */ void sha2_hmac_finish( sha2_context *ctx, unsigned char output[32] ) { int is224, hlen; unsigned char tmpbuf[32]; is224 = ctx->is224; hlen = ( is224 == 0 ) ? 32 : 28; sha2_finish( ctx, tmpbuf ); sha2_starts( ctx, is224 ); sha2_update( ctx, ctx->opad, 64 ); sha2_update( ctx, tmpbuf, hlen ); sha2_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * SHA-256 HMAC context reset */ void sha2_hmac_reset( sha2_context *ctx ) { sha2_starts( ctx, ctx->is224 ); sha2_update( ctx, ctx->ipad, 64 ); } /* * output = HMAC-SHA-256( hmac key, input buffer ) */ void sha2_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224 ) { sha2_context ctx; sha2_hmac_starts( &ctx, key, keylen, is224 ); sha2_hmac_update( &ctx, input, ilen ); sha2_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha2_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * FIPS-180-2 test vectors */ static unsigned char sha2_test_buf[3][57] = { { "abc" }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }, { "" } }; static const int sha2_test_buflen[3] = { 3, 56, 1000 }; static const unsigned char sha2_test_sum[6][32] = { /* * SHA-224 test vectors */ { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3, 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7, 0xE3, 0x6C, 0x9D, 0xA7 }, { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC, 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50, 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19, 0x52, 0x52, 0x25, 0x25 }, { 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, 0xBB, 0xB4, 0xC1, 0xEA, 0x97, 0x61, 0x8A, 0x4B, 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48, 0xB2, 0xEE, 0x4E, 0xE7, 0xAD, 0x67 }, /* * SHA-256 test vectors */ { 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD }, { 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 }, { 0xCD, 0xC7, 0x6E, 0x5C, 0x99, 0x14, 0xFB, 0x92, 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7, 0x3E, 0x67, 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, 0x04, 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0 } }; /* * RFC 4231 test vectors */ static unsigned char sha2_hmac_test_key[7][26] = { { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B" "\x0B\x0B\x0B\x0B" }, { "Jefe" }, { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" "\xAA\xAA\xAA\xAA" }, { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10" "\x11\x12\x13\x14\x15\x16\x17\x18\x19" }, { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C" "\x0C\x0C\x0C\x0C" }, { "" }, /* 0xAA 131 times */ { "" } }; static const int sha2_hmac_test_keylen[7] = { 20, 4, 20, 25, 20, 131, 131 }; static unsigned char sha2_hmac_test_buf[7][153] = { { "Hi There" }, { "what do ya want for nothing?" }, { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" }, { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" }, { "Test With Truncation" }, { "Test Using Larger Than Block-Size Key - Hash Key First" }, { "This is a test using a larger than block-size key " "and a larger than block-size data. The key needs to " "be hashed before being used by the HMAC algorithm." } }; static const int sha2_hmac_test_buflen[7] = { 8, 28, 50, 50, 20, 54, 152 }; static const unsigned char sha2_hmac_test_sum[14][32] = { /* * HMAC-SHA-224 test vectors */ { 0x89, 0x6F, 0xB1, 0x12, 0x8A, 0xBB, 0xDF, 0x19, 0x68, 0x32, 0x10, 0x7C, 0xD4, 0x9D, 0xF3, 0x3F, 0x47, 0xB4, 0xB1, 0x16, 0x99, 0x12, 0xBA, 0x4F, 0x53, 0x68, 0x4B, 0x22 }, { 0xA3, 0x0E, 0x01, 0x09, 0x8B, 0xC6, 0xDB, 0xBF, 0x45, 0x69, 0x0F, 0x3A, 0x7E, 0x9E, 0x6D, 0x0F, 0x8B, 0xBE, 0xA2, 0xA3, 0x9E, 0x61, 0x48, 0x00, 0x8F, 0xD0, 0x5E, 0x44 }, { 0x7F, 0xB3, 0xCB, 0x35, 0x88, 0xC6, 0xC1, 0xF6, 0xFF, 0xA9, 0x69, 0x4D, 0x7D, 0x6A, 0xD2, 0x64, 0x93, 0x65, 0xB0, 0xC1, 0xF6, 0x5D, 0x69, 0xD1, 0xEC, 0x83, 0x33, 0xEA }, { 0x6C, 0x11, 0x50, 0x68, 0x74, 0x01, 0x3C, 0xAC, 0x6A, 0x2A, 0xBC, 0x1B, 0xB3, 0x82, 0x62, 0x7C, 0xEC, 0x6A, 0x90, 0xD8, 0x6E, 0xFC, 0x01, 0x2D, 0xE7, 0xAF, 0xEC, 0x5A }, { 0x0E, 0x2A, 0xEA, 0x68, 0xA9, 0x0C, 0x8D, 0x37, 0xC9, 0x88, 0xBC, 0xDB, 0x9F, 0xCA, 0x6F, 0xA8 }, { 0x95, 0xE9, 0xA0, 0xDB, 0x96, 0x20, 0x95, 0xAD, 0xAE, 0xBE, 0x9B, 0x2D, 0x6F, 0x0D, 0xBC, 0xE2, 0xD4, 0x99, 0xF1, 0x12, 0xF2, 0xD2, 0xB7, 0x27, 0x3F, 0xA6, 0x87, 0x0E }, { 0x3A, 0x85, 0x41, 0x66, 0xAC, 0x5D, 0x9F, 0x02, 0x3F, 0x54, 0xD5, 0x17, 0xD0, 0xB3, 0x9D, 0xBD, 0x94, 0x67, 0x70, 0xDB, 0x9C, 0x2B, 0x95, 0xC9, 0xF6, 0xF5, 0x65, 0xD1 }, /* * HMAC-SHA-256 test vectors */ { 0xB0, 0x34, 0x4C, 0x61, 0xD8, 0xDB, 0x38, 0x53, 0x5C, 0xA8, 0xAF, 0xCE, 0xAF, 0x0B, 0xF1, 0x2B, 0x88, 0x1D, 0xC2, 0x00, 0xC9, 0x83, 0x3D, 0xA7, 0x26, 0xE9, 0x37, 0x6C, 0x2E, 0x32, 0xCF, 0xF7 }, { 0x5B, 0xDC, 0xC1, 0x46, 0xBF, 0x60, 0x75, 0x4E, 0x6A, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xC7, 0x5A, 0x00, 0x3F, 0x08, 0x9D, 0x27, 0x39, 0x83, 0x9D, 0xEC, 0x58, 0xB9, 0x64, 0xEC, 0x38, 0x43 }, { 0x77, 0x3E, 0xA9, 0x1E, 0x36, 0x80, 0x0E, 0x46, 0x85, 0x4D, 0xB8, 0xEB, 0xD0, 0x91, 0x81, 0xA7, 0x29, 0x59, 0x09, 0x8B, 0x3E, 0xF8, 0xC1, 0x22, 0xD9, 0x63, 0x55, 0x14, 0xCE, 0xD5, 0x65, 0xFE }, { 0x82, 0x55, 0x8A, 0x38, 0x9A, 0x44, 0x3C, 0x0E, 0xA4, 0xCC, 0x81, 0x98, 0x99, 0xF2, 0x08, 0x3A, 0x85, 0xF0, 0xFA, 0xA3, 0xE5, 0x78, 0xF8, 0x07, 0x7A, 0x2E, 0x3F, 0xF4, 0x67, 0x29, 0x66, 0x5B }, { 0xA3, 0xB6, 0x16, 0x74, 0x73, 0x10, 0x0E, 0xE0, 0x6E, 0x0C, 0x79, 0x6C, 0x29, 0x55, 0x55, 0x2B }, { 0x60, 0xE4, 0x31, 0x59, 0x1E, 0xE0, 0xB6, 0x7F, 0x0D, 0x8A, 0x26, 0xAA, 0xCB, 0xF5, 0xB7, 0x7F, 0x8E, 0x0B, 0xC6, 0x21, 0x37, 0x28, 0xC5, 0x14, 0x05, 0x46, 0x04, 0x0F, 0x0E, 0xE3, 0x7F, 0x54 }, { 0x9B, 0x09, 0xFF, 0xA7, 0x1B, 0x94, 0x2F, 0xCB, 0x27, 0x63, 0x5F, 0xBC, 0xD5, 0xB0, 0xE9, 0x44, 0xBF, 0xDC, 0x63, 0x64, 0x4F, 0x07, 0x13, 0x93, 0x8A, 0x7F, 0x51, 0x53, 0x5C, 0x3A, 0x35, 0xE2 } }; /* * Checkup routine */ int sha2_self_test( int verbose ) { int i, j, k, buflen; unsigned char buf[1024]; unsigned char sha2sum[32]; sha2_context ctx; for( i = 0; i < 6; i++ ) { j = i % 3; k = i < 3; if( verbose != 0 ) printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 ); sha2_starts( &ctx, k ); if( j == 2 ) { memset( buf, 'a', buflen = 1000 ); for( j = 0; j < 1000; j++ ) sha2_update( &ctx, buf, buflen ); } else sha2_update( &ctx, sha2_test_buf[j], sha2_test_buflen[j] ); sha2_finish( &ctx, sha2sum ); if( memcmp( sha2sum, sha2_test_sum[i], 32 - k * 4 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); for( i = 0; i < 14; i++ ) { j = i % 7; k = i < 7; if( verbose != 0 ) printf( " HMAC-SHA-%d test #%d: ", 256 - k * 32, j + 1 ); if( j == 5 || j == 6 ) { memset( buf, '\xAA', buflen = 131 ); sha2_hmac_starts( &ctx, buf, buflen, k ); } else sha2_hmac_starts( &ctx, sha2_hmac_test_key[j], sha2_hmac_test_keylen[j], k ); sha2_hmac_update( &ctx, sha2_hmac_test_buf[j], sha2_hmac_test_buflen[j] ); sha2_hmac_finish( &ctx, sha2sum ); buflen = ( j == 4 ) ? 16 : 32 - k * 4; if( memcmp( sha2sum, sha2_hmac_test_sum[i], buflen ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/timing.c0000644000014601777760000001266012165464055022737 0ustar00jenkinsnogroup00000000000000/* * Portable interface to the CPU cycle counter * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_TIMING_C) #include "polarssl/timing.h" #if defined(_WIN32) #include #include struct _hr_time { LARGE_INTEGER start; }; #else #include #include #include #include #include struct _hr_time { struct timeval start; }; #endif #if defined(POLARSSL_HAVE_ASM) && \ (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) unsigned long hardclock( void ) { unsigned long tsc; __asm rdtsc __asm mov [tsc], eax return( tsc ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) unsigned long hardclock( void ) { unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ (defined(__amd64__) || defined(__x86_64__)) unsigned long hardclock( void ) { unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo | (hi << 32) ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ (defined(__powerpc__) || defined(__ppc__)) unsigned long hardclock( void ) { unsigned long tbl, tbu0, tbu1; do { asm( "mftbu %0" : "=r" (tbu0) ); asm( "mftb %0" : "=r" (tbl ) ); asm( "mftbu %0" : "=r" (tbu1) ); } while( tbu0 != tbu1 ); return( tbl ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__sparc__) unsigned long hardclock( void ) { unsigned long tick; asm( ".byte 0x83, 0x41, 0x00, 0x00" ); asm( "mov %%g1, %0" : "=r" (tick) ); return( tick ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__alpha__) unsigned long hardclock( void ) { unsigned long cc; asm( "rpcc %0" : "=r" (cc) ); return( cc & 0xFFFFFFFF ); } #else #if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__ia64__) unsigned long hardclock( void ) { unsigned long itc; asm( "mov %0 = ar.itc" : "=r" (itc) ); return( itc ); } #else #if defined(_MSC_VER) unsigned long hardclock( void ) { LARGE_INTEGER offset; QueryPerformanceCounter( &offset ); return (unsigned long)( offset.QuadPart ); } #else static int hardclock_init = 0; static struct timeval tv_init; unsigned long hardclock( void ) { struct timeval tv_cur; if( hardclock_init == 0 ) { gettimeofday( &tv_init, NULL ); hardclock_init = 1; } gettimeofday( &tv_cur, NULL ); return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000 + ( tv_cur.tv_usec - tv_init.tv_usec ) ); } #endif /* generic */ #endif /* WIN32 */ #endif /* IA-64 */ #endif /* Alpha */ #endif /* SPARC8 */ #endif /* PowerPC */ #endif /* AMD64 */ #endif /* i586+ */ volatile int alarmed = 0; #if defined(_WIN32) unsigned long get_timer( struct hr_time *val, int reset ) { unsigned long delta; LARGE_INTEGER offset, hfreq; struct _hr_time *t = (struct _hr_time *) val; QueryPerformanceCounter( &offset ); QueryPerformanceFrequency( &hfreq ); delta = (unsigned long)( ( 1000 * ( offset.QuadPart - t->start.QuadPart ) ) / hfreq.QuadPart ); if( reset ) QueryPerformanceCounter( &t->start ); return( delta ); } DWORD WINAPI TimerProc( LPVOID uElapse ) { Sleep( (DWORD) uElapse ); alarmed = 1; return( TRUE ); } void set_alarm( int seconds ) { DWORD ThreadId; alarmed = 0; CloseHandle( CreateThread( NULL, 0, TimerProc, (LPVOID) ( seconds * 1000 ), 0, &ThreadId ) ); } void m_sleep( int milliseconds ) { Sleep( milliseconds ); } #else unsigned long get_timer( struct hr_time *val, int reset ) { unsigned long delta; struct timeval offset; struct _hr_time *t = (struct _hr_time *) val; gettimeofday( &offset, NULL ); delta = ( offset.tv_sec - t->start.tv_sec ) * 1000 + ( offset.tv_usec - t->start.tv_usec ) / 1000; if( reset ) { t->start.tv_sec = offset.tv_sec; t->start.tv_usec = offset.tv_usec; } return( delta ); } static void sighandler( int signum ) { alarmed = 1; signal( signum, sighandler ); } void set_alarm( int seconds ) { alarmed = 0; signal( SIGALRM, sighandler ); alarm( seconds ); } void m_sleep( int milliseconds ) { struct timeval tv; tv.tv_sec = milliseconds / 1000; tv.tv_usec = milliseconds * 1000; select( 0, NULL, NULL, NULL, &tv ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/camellia.c0000644000014601777760000010135612165464055023220 0ustar00jenkinsnogroup00000000000000/* * Camellia implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The Camellia block cipher was designed by NTT and Mitsubishi Electric * Corporation. * * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/01espec.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_CAMELLIA_C) #include "polarssl/camellia.h" /* * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE #define GET_ULONG_BE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ | ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (unsigned long) (b)[(i) + 3] ); \ } #endif #ifndef PUT_ULONG_BE #define PUT_ULONG_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ } #endif static const unsigned char SIGMA_CHARS[6][8] = { { 0xa0, 0x9e, 0x66, 0x7f, 0x3b, 0xcc, 0x90, 0x8b }, { 0xb6, 0x7a, 0xe8, 0x58, 0x4c, 0xaa, 0x73, 0xb2 }, { 0xc6, 0xef, 0x37, 0x2f, 0xe9, 0x4f, 0x82, 0xbe }, { 0x54, 0xff, 0x53, 0xa5, 0xf1, 0xd3, 0x6f, 0x1c }, { 0x10, 0xe5, 0x27, 0xfa, 0xde, 0x68, 0x2d, 0x1d }, { 0xb0, 0x56, 0x88, 0xc2, 0xb3, 0xe6, 0xc1, 0xfd } }; #if defined(POLARSSL_CAMELLIA_SMALL_MEMORY) static const unsigned char FSb[256] = { 112,130, 44,236,179, 39,192,229,228,133, 87, 53,234, 12,174, 65, 35,239,107,147, 69, 25,165, 33,237, 14, 79, 78, 29,101,146,189, 134,184,175,143,124,235, 31,206, 62, 48,220, 95, 94,197, 11, 26, 166,225, 57,202,213, 71, 93, 61,217, 1, 90,214, 81, 86,108, 77, 139, 13,154,102,251,204,176, 45,116, 18, 43, 32,240,177,132,153, 223, 76,203,194, 52,126,118, 5,109,183,169, 49,209, 23, 4,215, 20, 88, 58, 97,222, 27, 17, 28, 50, 15,156, 22, 83, 24,242, 34, 254, 68,207,178,195,181,122,145, 36, 8,232,168, 96,252,105, 80, 170,208,160,125,161,137, 98,151, 84, 91, 30,149,224,255,100,210, 16,196, 0, 72,163,247,117,219,138, 3,230,218, 9, 63,221,148, 135, 92,131, 2,205, 74,144, 51,115,103,246,243,157,127,191,226, 82,155,216, 38,200, 55,198, 59,129,150,111, 75, 19,190, 99, 46, 233,121,167,140,159,110,188,142, 41,245,249,182, 47,253,180, 89, 120,152, 6,106,231, 70,113,186,212, 37,171, 66,136,162,141,250, 114, 7,185, 85,248,238,172, 10, 54, 73, 42,104, 60, 56,241,164, 64, 40,211,123,187,201, 67,193, 21,227,173,244,119,199,128,158 }; #define SBOX1(n) FSb[(n)] #define SBOX2(n) (unsigned char)((FSb[(n)] >> 7 ^ FSb[(n)] << 1) & 0xff) #define SBOX3(n) (unsigned char)((FSb[(n)] >> 1 ^ FSb[(n)] << 7) & 0xff) #define SBOX4(n) FSb[((n) << 1 ^ (n) >> 7) &0xff] #else static const unsigned char FSb[256] = { 112, 130, 44, 236, 179, 39, 192, 229, 228, 133, 87, 53, 234, 12, 174, 65, 35, 239, 107, 147, 69, 25, 165, 33, 237, 14, 79, 78, 29, 101, 146, 189, 134, 184, 175, 143, 124, 235, 31, 206, 62, 48, 220, 95, 94, 197, 11, 26, 166, 225, 57, 202, 213, 71, 93, 61, 217, 1, 90, 214, 81, 86, 108, 77, 139, 13, 154, 102, 251, 204, 176, 45, 116, 18, 43, 32, 240, 177, 132, 153, 223, 76, 203, 194, 52, 126, 118, 5, 109, 183, 169, 49, 209, 23, 4, 215, 20, 88, 58, 97, 222, 27, 17, 28, 50, 15, 156, 22, 83, 24, 242, 34, 254, 68, 207, 178, 195, 181, 122, 145, 36, 8, 232, 168, 96, 252, 105, 80, 170, 208, 160, 125, 161, 137, 98, 151, 84, 91, 30, 149, 224, 255, 100, 210, 16, 196, 0, 72, 163, 247, 117, 219, 138, 3, 230, 218, 9, 63, 221, 148, 135, 92, 131, 2, 205, 74, 144, 51, 115, 103, 246, 243, 157, 127, 191, 226, 82, 155, 216, 38, 200, 55, 198, 59, 129, 150, 111, 75, 19, 190, 99, 46, 233, 121, 167, 140, 159, 110, 188, 142, 41, 245, 249, 182, 47, 253, 180, 89, 120, 152, 6, 106, 231, 70, 113, 186, 212, 37, 171, 66, 136, 162, 141, 250, 114, 7, 185, 85, 248, 238, 172, 10, 54, 73, 42, 104, 60, 56, 241, 164, 64, 40, 211, 123, 187, 201, 67, 193, 21, 227, 173, 244, 119, 199, 128, 158 }; static const unsigned char FSb2[256] = { 224, 5, 88, 217, 103, 78, 129, 203, 201, 11, 174, 106, 213, 24, 93, 130, 70, 223, 214, 39, 138, 50, 75, 66, 219, 28, 158, 156, 58, 202, 37, 123, 13, 113, 95, 31, 248, 215, 62, 157, 124, 96, 185, 190, 188, 139, 22, 52, 77, 195, 114, 149, 171, 142, 186, 122, 179, 2, 180, 173, 162, 172, 216, 154, 23, 26, 53, 204, 247, 153, 97, 90, 232, 36, 86, 64, 225, 99, 9, 51, 191, 152, 151, 133, 104, 252, 236, 10, 218, 111, 83, 98, 163, 46, 8, 175, 40, 176, 116, 194, 189, 54, 34, 56, 100, 30, 57, 44, 166, 48, 229, 68, 253, 136, 159, 101, 135, 107, 244, 35, 72, 16, 209, 81, 192, 249, 210, 160, 85, 161, 65, 250, 67, 19, 196, 47, 168, 182, 60, 43, 193, 255, 200, 165, 32, 137, 0, 144, 71, 239, 234, 183, 21, 6, 205, 181, 18, 126, 187, 41, 15, 184, 7, 4, 155, 148, 33, 102, 230, 206, 237, 231, 59, 254, 127, 197, 164, 55, 177, 76, 145, 110, 141, 118, 3, 45, 222, 150, 38, 125, 198, 92, 211, 242, 79, 25, 63, 220, 121, 29, 82, 235, 243, 109, 94, 251, 105, 178, 240, 49, 12, 212, 207, 140, 226, 117, 169, 74, 87, 132, 17, 69, 27, 245, 228, 14, 115, 170, 241, 221, 89, 20, 108, 146, 84, 208, 120, 112, 227, 73, 128, 80, 167, 246, 119, 147, 134, 131, 42, 199, 91, 233, 238, 143, 1, 61 }; static const unsigned char FSb3[256] = { 56, 65, 22, 118, 217, 147, 96, 242, 114, 194, 171, 154, 117, 6, 87, 160, 145, 247, 181, 201, 162, 140, 210, 144, 246, 7, 167, 39, 142, 178, 73, 222, 67, 92, 215, 199, 62, 245, 143, 103, 31, 24, 110, 175, 47, 226, 133, 13, 83, 240, 156, 101, 234, 163, 174, 158, 236, 128, 45, 107, 168, 43, 54, 166, 197, 134, 77, 51, 253, 102, 88, 150, 58, 9, 149, 16, 120, 216, 66, 204, 239, 38, 229, 97, 26, 63, 59, 130, 182, 219, 212, 152, 232, 139, 2, 235, 10, 44, 29, 176, 111, 141, 136, 14, 25, 135, 78, 11, 169, 12, 121, 17, 127, 34, 231, 89, 225, 218, 61, 200, 18, 4, 116, 84, 48, 126, 180, 40, 85, 104, 80, 190, 208, 196, 49, 203, 42, 173, 15, 202, 112, 255, 50, 105, 8, 98, 0, 36, 209, 251, 186, 237, 69, 129, 115, 109, 132, 159, 238, 74, 195, 46, 193, 1, 230, 37, 72, 153, 185, 179, 123, 249, 206, 191, 223, 113, 41, 205, 108, 19, 100, 155, 99, 157, 192, 75, 183, 165, 137, 95, 177, 23, 244, 188, 211, 70, 207, 55, 94, 71, 148, 250, 252, 91, 151, 254, 90, 172, 60, 76, 3, 53, 243, 35, 184, 93, 106, 146, 213, 33, 68, 81, 198, 125, 57, 131, 220, 170, 124, 119, 86, 5, 27, 164, 21, 52, 30, 28, 248, 82, 32, 20, 233, 189, 221, 228, 161, 224, 138, 241, 214, 122, 187, 227, 64, 79 }; static const unsigned char FSb4[256] = { 112, 44, 179, 192, 228, 87, 234, 174, 35, 107, 69, 165, 237, 79, 29, 146, 134, 175, 124, 31, 62, 220, 94, 11, 166, 57, 213, 93, 217, 90, 81, 108, 139, 154, 251, 176, 116, 43, 240, 132, 223, 203, 52, 118, 109, 169, 209, 4, 20, 58, 222, 17, 50, 156, 83, 242, 254, 207, 195, 122, 36, 232, 96, 105, 170, 160, 161, 98, 84, 30, 224, 100, 16, 0, 163, 117, 138, 230, 9, 221, 135, 131, 205, 144, 115, 246, 157, 191, 82, 216, 200, 198, 129, 111, 19, 99, 233, 167, 159, 188, 41, 249, 47, 180, 120, 6, 231, 113, 212, 171, 136, 141, 114, 185, 248, 172, 54, 42, 60, 241, 64, 211, 187, 67, 21, 173, 119, 128, 130, 236, 39, 229, 133, 53, 12, 65, 239, 147, 25, 33, 14, 78, 101, 189, 184, 143, 235, 206, 48, 95, 197, 26, 225, 202, 71, 61, 1, 214, 86, 77, 13, 102, 204, 45, 18, 32, 177, 153, 76, 194, 126, 5, 183, 49, 23, 215, 88, 97, 27, 28, 15, 22, 24, 34, 68, 178, 181, 145, 8, 168, 252, 80, 208, 125, 137, 151, 91, 149, 255, 210, 196, 72, 247, 219, 3, 218, 63, 148, 92, 2, 74, 51, 103, 243, 127, 226, 155, 38, 55, 59, 150, 75, 190, 46, 121, 140, 110, 142, 245, 182, 253, 89, 152, 106, 70, 186, 37, 66, 162, 250, 7, 85, 238, 10, 73, 104, 56, 164, 40, 123, 201, 193, 227, 244, 199, 158 }; #define SBOX1(n) FSb[(n)] #define SBOX2(n) FSb2[(n)] #define SBOX3(n) FSb3[(n)] #define SBOX4(n) FSb4[(n)] #endif static const unsigned char shifts[2][4][4] = { { { 1, 1, 1, 1 }, /* KL */ { 0, 0, 0, 0 }, /* KR */ { 1, 1, 1, 1 }, /* KA */ { 0, 0, 0, 0 } /* KB */ }, { { 1, 0, 1, 1 }, /* KL */ { 1, 1, 0, 1 }, /* KR */ { 1, 1, 1, 0 }, /* KA */ { 1, 1, 0, 1 } /* KB */ } }; static const signed char indexes[2][4][20] = { { { 0, 1, 2, 3, 8, 9, 10, 11, 38, 39, 36, 37, 23, 20, 21, 22, 27, -1, -1, 26 }, /* KL -> RK */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* KR -> RK */ { 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, -1, 24, 25, -1, 31, 28, 29, 30 }, /* KA -> RK */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } /* KB -> RK */ }, { { 0, 1, 2, 3, 61, 62, 63, 60, -1, -1, -1, -1, 27, 24, 25, 26, 35, 32, 33, 34 }, /* KL -> RK */ { -1, -1, -1, -1, 8, 9, 10, 11, 16, 17, 18, 19, -1, -1, -1, -1, 39, 36, 37, 38 }, /* KR -> RK */ { -1, -1, -1, -1, 12, 13, 14, 15, 58, 59, 56, 57, 31, 28, 29, 30, -1, -1, -1, -1 }, /* KA -> RK */ { 4, 5, 6, 7, 65, 66, 67, 64, 20, 21, 22, 23, -1, -1, -1, -1, 43, 40, 41, 42 } /* KB -> RK */ } }; static const signed char transposes[2][20] = { { 21, 22, 23, 20, -1, -1, -1, -1, 18, 19, 16, 17, 11, 8, 9, 10, 15, 12, 13, 14 }, { 25, 26, 27, 24, 29, 30, 31, 28, 18, 19, 16, 17, -1, -1, -1, -1, -1, -1, -1, -1 } }; /* Shift macro for 128 bit strings with rotation smaller than 32 bits (!) */ #define ROTL(DEST, SRC, SHIFT) \ { \ (DEST)[0] = (SRC)[0] << (SHIFT) ^ (SRC)[1] >> (32 - (SHIFT)); \ (DEST)[1] = (SRC)[1] << (SHIFT) ^ (SRC)[2] >> (32 - (SHIFT)); \ (DEST)[2] = (SRC)[2] << (SHIFT) ^ (SRC)[3] >> (32 - (SHIFT)); \ (DEST)[3] = (SRC)[3] << (SHIFT) ^ (SRC)[0] >> (32 - (SHIFT)); \ } #define FL(XL, XR, KL, KR) \ { \ (XR) = ((((XL) & (KL)) << 1) | (((XL) & (KL)) >> 31)) ^ (XR); \ (XL) = ((XR) | (KR)) ^ (XL); \ } #define FLInv(YL, YR, KL, KR) \ { \ (YL) = ((YR) | (KR)) ^ (YL); \ (YR) = ((((YL) & (KL)) << 1) | (((YL) & (KL)) >> 31)) ^ (YR); \ } #define SHIFT_AND_PLACE(INDEX, OFFSET) \ { \ TK[0] = KC[(OFFSET) * 4 + 0]; \ TK[1] = KC[(OFFSET) * 4 + 1]; \ TK[2] = KC[(OFFSET) * 4 + 2]; \ TK[3] = KC[(OFFSET) * 4 + 3]; \ \ for ( i = 1; i <= 4; i++ ) \ if (shifts[(INDEX)][(OFFSET)][i -1]) \ ROTL(TK + i * 4, TK, (15 * i) % 32); \ \ for ( i = 0; i < 20; i++ ) \ if (indexes[(INDEX)][(OFFSET)][i] != -1) { \ RK[indexes[(INDEX)][(OFFSET)][i]] = TK[ i ]; \ } \ } static void camellia_feistel(const uint32_t x[2], const uint32_t k[2], uint32_t z[2]) { uint32_t I0, I1; I0 = x[0] ^ k[0]; I1 = x[1] ^ k[1]; I0 = (SBOX1((I0 >> 24) & 0xFF) << 24) | (SBOX2((I0 >> 16) & 0xFF) << 16) | (SBOX3((I0 >> 8) & 0xFF) << 8) | (SBOX4((I0 ) & 0xFF) ); I1 = (SBOX2((I1 >> 24) & 0xFF) << 24) | (SBOX3((I1 >> 16) & 0xFF) << 16) | (SBOX4((I1 >> 8) & 0xFF) << 8) | (SBOX1((I1 ) & 0xFF) ); I0 ^= (I1 << 8) | (I1 >> 24); I1 ^= (I0 << 16) | (I0 >> 16); I0 ^= (I1 >> 8) | (I1 << 24); I1 ^= (I0 >> 8) | (I0 << 24); z[0] ^= I1; z[1] ^= I0; } /* * Camellia key schedule (encryption) */ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize ) { int idx; size_t i; uint32_t *RK; unsigned char t[64]; uint32_t SIGMA[6][2]; uint32_t KC[16]; uint32_t TK[20]; RK = ctx->rk; memset(t, 0, 64); memset(RK, 0, sizeof(ctx->rk)); switch( keysize ) { case 128: ctx->nr = 3; idx = 0; break; case 192: case 256: ctx->nr = 4; idx = 1; break; default : return( POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH ); } for( i = 0; i < keysize / 8; ++i) t[i] = key[i]; if (keysize == 192) { for (i = 0; i < 8; i++) t[24 + i] = ~t[16 + i]; } /* * Prepare SIGMA values */ for (i = 0; i < 6; i++) { GET_ULONG_BE(SIGMA[i][0], SIGMA_CHARS[i], 0); GET_ULONG_BE(SIGMA[i][1], SIGMA_CHARS[i], 4); } /* * Key storage in KC * Order: KL, KR, KA, KB */ memset(KC, 0, sizeof(KC)); /* Store KL, KR */ for (i = 0; i < 8; i++) GET_ULONG_BE(KC[i], t, i * 4); /* Generate KA */ for( i = 0; i < 4; ++i) KC[8 + i] = KC[i] ^ KC[4 + i]; camellia_feistel(KC + 8, SIGMA[0], KC + 10); camellia_feistel(KC + 10, SIGMA[1], KC + 8); for( i = 0; i < 4; ++i) KC[8 + i] ^= KC[i]; camellia_feistel(KC + 8, SIGMA[2], KC + 10); camellia_feistel(KC + 10, SIGMA[3], KC + 8); if (keysize > 128) { /* Generate KB */ for( i = 0; i < 4; ++i) KC[12 + i] = KC[4 + i] ^ KC[8 + i]; camellia_feistel(KC + 12, SIGMA[4], KC + 14); camellia_feistel(KC + 14, SIGMA[5], KC + 12); } /* * Generating subkeys */ /* Manipulating KL */ SHIFT_AND_PLACE(idx, 0); /* Manipulating KR */ if (keysize > 128) { SHIFT_AND_PLACE(idx, 1); } /* Manipulating KA */ SHIFT_AND_PLACE(idx, 2); /* Manipulating KB */ if (keysize > 128) { SHIFT_AND_PLACE(idx, 3); } /* Do transpositions */ for ( i = 0; i < 20; i++ ) { if (transposes[idx][i] != -1) { RK[32 + 12 * idx + i] = RK[transposes[idx][i]]; } } return( 0 ); } /* * Camellia key schedule (decryption) */ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize ) { int idx; size_t i; camellia_context cty; uint32_t *RK; uint32_t *SK; int ret; switch( keysize ) { case 128: ctx->nr = 3; idx = 0; break; case 192: case 256: ctx->nr = 4; idx = 1; break; default : return( POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH ); } RK = ctx->rk; ret = camellia_setkey_enc(&cty, key, keysize); if( ret != 0 ) return( ret ); SK = cty.rk + 24 * 2 + 8 * idx * 2; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; for (i = 22 + 8 * idx, SK -= 6; i > 0; i--, SK -= 4) { *RK++ = *SK++; *RK++ = *SK++; } SK -= 2; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; memset( &cty, 0, sizeof( camellia_context ) ); return( 0 ); } /* * Camellia-ECB block encryption/decryption */ int camellia_crypt_ecb( camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) { int NR; uint32_t *RK, X[4]; ( (void) mode ); NR = ctx->nr; RK = ctx->rk; GET_ULONG_BE( X[0], input, 0 ); GET_ULONG_BE( X[1], input, 4 ); GET_ULONG_BE( X[2], input, 8 ); GET_ULONG_BE( X[3], input, 12 ); X[0] ^= *RK++; X[1] ^= *RK++; X[2] ^= *RK++; X[3] ^= *RK++; while (NR) { --NR; camellia_feistel(X, RK, X + 2); RK += 2; camellia_feistel(X + 2, RK, X); RK += 2; camellia_feistel(X, RK, X + 2); RK += 2; camellia_feistel(X + 2, RK, X); RK += 2; camellia_feistel(X, RK, X + 2); RK += 2; camellia_feistel(X + 2, RK, X); RK += 2; if (NR) { FL(X[0], X[1], RK[0], RK[1]); RK += 2; FLInv(X[2], X[3], RK[0], RK[1]); RK += 2; } } X[2] ^= *RK++; X[3] ^= *RK++; X[0] ^= *RK++; X[1] ^= *RK++; PUT_ULONG_BE( X[2], output, 0 ); PUT_ULONG_BE( X[3], output, 4 ); PUT_ULONG_BE( X[0], output, 8 ); PUT_ULONG_BE( X[1], output, 12 ); return( 0 ); } /* * Camellia-CBC buffer encryption/decryption */ int camellia_crypt_cbc( camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ) { int i; unsigned char temp[16]; if( length % 16 ) return( POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH ); if( mode == CAMELLIA_DECRYPT ) { while( length > 0 ) { memcpy( temp, input, 16 ); camellia_crypt_ecb( ctx, mode, input, output ); for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); memcpy( iv, temp, 16 ); input += 16; output += 16; length -= 16; } } else { while( length > 0 ) { for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); camellia_crypt_ecb( ctx, mode, output, output ); memcpy( iv, output, 16 ); input += 16; output += 16; length -= 16; } } return( 0 ); } #if defined(POLARSSL_CIPHER_MODE_CFB) /* * Camellia-CFB128 buffer encryption/decryption */ int camellia_crypt_cfb128( camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output ) { int c; size_t n = *iv_off; if( mode == CAMELLIA_DECRYPT ) { while( length-- ) { if( n == 0 ) camellia_crypt_ecb( ctx, CAMELLIA_ENCRYPT, iv, iv ); c = *input++; *output++ = (unsigned char)( c ^ iv[n] ); iv[n] = (unsigned char) c; n = (n + 1) & 0x0F; } } else { while( length-- ) { if( n == 0 ) camellia_crypt_ecb( ctx, CAMELLIA_ENCRYPT, iv, iv ); iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); n = (n + 1) & 0x0F; } } *iv_off = n; return( 0 ); } #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) /* * Camellia-CTR buffer encryption/decryption */ int camellia_crypt_ctr( camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output ) { int c, i, cb; size_t n = *nc_off; while( length-- ) { if( n == 0 ) { camellia_crypt_ecb( ctx, CAMELLIA_ENCRYPT, nonce_counter, stream_block ); i = 15; do { nonce_counter[i]++; cb = nonce_counter[i] == 0; } while( i-- && cb ); } c = *input++; *output++ = (unsigned char)( c ^ stream_block[n] ); n = (n + 1) & 0x0F; } *nc_off = n; return( 0 ); } #endif /* POLARSSL_CIPHER_MODE_CTR */ #if defined(POLARSSL_SELF_TEST) #include /* * Camellia test vectors from: * * http://info.isl.ntt.co.jp/crypt/eng/camellia/technology.html: * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/cryptrec/intermediate.txt * http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/cryptrec/t_camellia.txt * (For each bitlength: Key 0, Nr 39) */ #define CAMELLIA_TESTS_ECB 2 static const unsigned char camellia_test_ecb_key[3][CAMELLIA_TESTS_ECB][32] = { { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, }; static const unsigned char camellia_test_ecb_plain[CAMELLIA_TESTS_ECB][16] = { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, { 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; static const unsigned char camellia_test_ecb_cipher[3][CAMELLIA_TESTS_ECB][16] = { { { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73, 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 }, { 0x38, 0x3C, 0x6C, 0x2A, 0xAB, 0xEF, 0x7F, 0xDE, 0x25, 0xCD, 0x47, 0x0B, 0xF7, 0x74, 0xA3, 0x31 } }, { { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8, 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 }, { 0xD1, 0x76, 0x3F, 0xC0, 0x19, 0xD7, 0x7C, 0xC9, 0x30, 0xBF, 0xF2, 0xA5, 0x6F, 0x7C, 0x93, 0x64 } }, { { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 }, { 0x05, 0x03, 0xFB, 0x10, 0xAB, 0x24, 0x1E, 0x7C, 0xF4, 0x5D, 0x8C, 0xDE, 0xEE, 0x47, 0x43, 0x35 } } }; #define CAMELLIA_TESTS_CBC 3 static const unsigned char camellia_test_cbc_key[3][32] = { { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } , { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B } , { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } }; static const unsigned char camellia_test_cbc_iv[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } ; static const unsigned char camellia_test_cbc_plain[CAMELLIA_TESTS_CBC][16] = { { 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A }, { 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51 }, { 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF } }; static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] = { { { 0x16, 0x07, 0xCF, 0x49, 0x4B, 0x36, 0xBB, 0xF0, 0x0D, 0xAE, 0xB0, 0xB5, 0x03, 0xC8, 0x31, 0xAB }, { 0xA2, 0xF2, 0xCF, 0x67, 0x16, 0x29, 0xEF, 0x78, 0x40, 0xC5, 0xA5, 0xDF, 0xB5, 0x07, 0x48, 0x87 }, { 0x0F, 0x06, 0x16, 0x50, 0x08, 0xCF, 0x8B, 0x8B, 0x5A, 0x63, 0x58, 0x63, 0x62, 0x54, 0x3E, 0x54 } }, { { 0x2A, 0x48, 0x30, 0xAB, 0x5A, 0xC4, 0xA1, 0xA2, 0x40, 0x59, 0x55, 0xFD, 0x21, 0x95, 0xCF, 0x93 }, { 0x5D, 0x5A, 0x86, 0x9B, 0xD1, 0x4C, 0xE5, 0x42, 0x64, 0xF8, 0x92, 0xA6, 0xDD, 0x2E, 0xC3, 0xD5 }, { 0x37, 0xD3, 0x59, 0xC3, 0x34, 0x98, 0x36, 0xD8, 0x84, 0xE3, 0x10, 0xAD, 0xDF, 0x68, 0xC4, 0x49 } }, { { 0xE6, 0xCF, 0xA3, 0x5F, 0xC0, 0x2B, 0x13, 0x4A, 0x4D, 0x2C, 0x0B, 0x67, 0x37, 0xAC, 0x3E, 0xDA }, { 0x36, 0xCB, 0xEB, 0x73, 0xBD, 0x50, 0x4B, 0x40, 0x70, 0xB1, 0xB7, 0xDE, 0x2B, 0x21, 0xEB, 0x50 }, { 0xE3, 0x1A, 0x60, 0x55, 0x29, 0x7D, 0x96, 0xCA, 0x33, 0x30, 0xCD, 0xF1, 0xB1, 0x86, 0x0A, 0x83 } } }; #if defined(POLARSSL_CIPHER_MODE_CTR) /* * Camellia-CTR test vectors from: * * http://www.faqs.org/rfcs/rfc5528.html */ static const unsigned char camellia_test_ctr_key[3][16] = { { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E }, { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63 }, { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC } }; static const unsigned char camellia_test_ctr_nonce_counter[3][16] = { { 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, { 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01 } }; static const unsigned char camellia_test_ctr_pt[3][48] = { { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23 } }; static const unsigned char camellia_test_ctr_ct[3][48] = { { 0xD0, 0x9D, 0xC2, 0x9A, 0x82, 0x14, 0x61, 0x9A, 0x20, 0x87, 0x7C, 0x76, 0xDB, 0x1F, 0x0B, 0x3F }, { 0xDB, 0xF3, 0xC7, 0x8D, 0xC0, 0x83, 0x96, 0xD4, 0xDA, 0x7C, 0x90, 0x77, 0x65, 0xBB, 0xCB, 0x44, 0x2B, 0x8E, 0x8E, 0x0F, 0x31, 0xF0, 0xDC, 0xA7, 0x2C, 0x74, 0x17, 0xE3, 0x53, 0x60, 0xE0, 0x48 }, { 0xB1, 0x9D, 0x1F, 0xCD, 0xCB, 0x75, 0xEB, 0x88, 0x2F, 0x84, 0x9C, 0xE2, 0x4D, 0x85, 0xCF, 0x73, 0x9C, 0xE6, 0x4B, 0x2B, 0x5C, 0x9D, 0x73, 0xF1, 0x4F, 0x2D, 0x5D, 0x9D, 0xCE, 0x98, 0x89, 0xCD, 0xDF, 0x50, 0x86, 0x96 } }; static const int camellia_test_ctr_len[3] = { 16, 32, 36 }; #endif /* POLARSSL_CIPHER_MODE_CTR */ /* * Checkup routine */ int camellia_self_test( int verbose ) { int i, j, u, v; unsigned char key[32]; unsigned char buf[64]; unsigned char src[16]; unsigned char dst[16]; unsigned char iv[16]; #if defined(POLARSSL_CIPHER_MODE_CTR) size_t offset, len; unsigned char nonce_counter[16]; unsigned char stream_block[16]; #endif camellia_context ctx; memset( key, 0, 32 ); for (j = 0; j < 6; j++) { u = j >> 1; v = j & 1; if( verbose != 0 ) printf( " CAMELLIA-ECB-%3d (%s): ", 128 + u * 64, (v == CAMELLIA_DECRYPT) ? "dec" : "enc"); for (i = 0; i < CAMELLIA_TESTS_ECB; i++ ) { memcpy( key, camellia_test_ecb_key[u][i], 16 + 8 * u); if (v == CAMELLIA_DECRYPT) { camellia_setkey_dec(&ctx, key, 128 + u * 64); memcpy(src, camellia_test_ecb_cipher[u][i], 16); memcpy(dst, camellia_test_ecb_plain[i], 16); } else { /* CAMELLIA_ENCRYPT */ camellia_setkey_enc(&ctx, key, 128 + u * 64); memcpy(src, camellia_test_ecb_plain[i], 16); memcpy(dst, camellia_test_ecb_cipher[u][i], 16); } camellia_crypt_ecb(&ctx, v, src, buf); if( memcmp( buf, dst, 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); /* * CBC mode */ for( j = 0; j < 6; j++ ) { u = j >> 1; v = j & 1; if( verbose != 0 ) printf( " CAMELLIA-CBC-%3d (%s): ", 128 + u * 64, ( v == CAMELLIA_DECRYPT ) ? "dec" : "enc" ); memcpy( src, camellia_test_cbc_iv, 16); memcpy( dst, camellia_test_cbc_iv, 16); memcpy( key, camellia_test_cbc_key[u], 16 + 8 * u); if (v == CAMELLIA_DECRYPT) { camellia_setkey_dec(&ctx, key, 128 + u * 64); } else { camellia_setkey_enc(&ctx, key, 128 + u * 64); } for (i = 0; i < CAMELLIA_TESTS_CBC; i++ ) { if (v == CAMELLIA_DECRYPT) { memcpy( iv , src, 16 ); memcpy(src, camellia_test_cbc_cipher[u][i], 16); memcpy(dst, camellia_test_cbc_plain[i], 16); } else { /* CAMELLIA_ENCRYPT */ memcpy( iv , dst, 16 ); memcpy(src, camellia_test_cbc_plain[i], 16); memcpy(dst, camellia_test_cbc_cipher[u][i], 16); } camellia_crypt_cbc(&ctx, v, 16, iv, src, buf); if( memcmp( buf, dst, 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); #if defined(POLARSSL_CIPHER_MODE_CTR) /* * CTR mode */ for( i = 0; i < 6; i++ ) { u = i >> 1; v = i & 1; if( verbose != 0 ) printf( " CAMELLIA-CTR-128 (%s): ", ( v == CAMELLIA_DECRYPT ) ? "dec" : "enc" ); memcpy( nonce_counter, camellia_test_ctr_nonce_counter[u], 16 ); memcpy( key, camellia_test_ctr_key[u], 16 ); offset = 0; camellia_setkey_enc( &ctx, key, 128 ); if( v == CAMELLIA_DECRYPT ) { len = camellia_test_ctr_len[u]; memcpy( buf, camellia_test_ctr_ct[u], len ); camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); if( memcmp( buf, camellia_test_ctr_pt[u], len ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } else { len = camellia_test_ctr_len[u]; memcpy( buf, camellia_test_ctr_pt[u], len ); camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); if( memcmp( buf, camellia_test_ctr_ct[u], len ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); #endif /* POLARSSL_CIPHER_MODE_CTR */ return ( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/padlock.c0000644000014601777760000001102312165464055023055 0ustar00jenkinsnogroup00000000000000/* * VIA PadLock support functions * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * This implementation is based on the VIA PadLock Programming Guide: * * http://www.via.com.tw/en/downloads/whitepapers/initiatives/padlock/ * programming_guide.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_PADLOCK_C) #include "polarssl/padlock.h" #if defined(POLARSSL_HAVE_X86) /* * PadLock detection routine */ int padlock_supports( int feature ) { static int flags = -1; int ebx, edx; if( flags == -1 ) { asm( "movl %%ebx, %0 \n" \ "movl $0xC0000000, %%eax \n" \ "cpuid \n" \ "cmpl $0xC0000001, %%eax \n" \ "movl $0, %%edx \n" \ "jb unsupported \n" \ "movl $0xC0000001, %%eax \n" \ "cpuid \n" \ "unsupported: \n" \ "movl %%edx, %1 \n" \ "movl %2, %%ebx \n" : "=m" (ebx), "=m" (edx) : "m" (ebx) : "eax", "ecx", "edx" ); flags = edx; } return( flags & feature ); } /* * PadLock AES-ECB block en(de)cryption */ int padlock_xcryptecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) { int ebx; unsigned long *rk; unsigned long *blk; unsigned long *ctrl; unsigned char buf[256]; rk = ctx->rk; blk = PADLOCK_ALIGN16( buf ); memcpy( blk, input, 16 ); ctrl = blk + 4; *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + ( mode^1 ) - 10 ) << 9 ); asm( "pushfl; popfl \n" \ "movl %%ebx, %0 \n" \ "movl $1, %%ecx \n" \ "movl %2, %%edx \n" \ "movl %3, %%ebx \n" \ "movl %4, %%esi \n" \ "movl %4, %%edi \n" \ ".byte 0xf3,0x0f,0xa7,0xc8\n" \ "movl %1, %%ebx \n" : "=m" (ebx) : "m" (ebx), "m" (ctrl), "m" (rk), "m" (blk) : "ecx", "edx", "esi", "edi" ); memcpy( output, blk, 16 ); return( 0 ); } /* * PadLock AES-CBC buffer en(de)cryption */ int padlock_xcryptcbc( aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output ) { int ebx; size_t count; unsigned long *rk; unsigned long *iw; unsigned long *ctrl; unsigned char buf[256]; if( ( (long) input & 15 ) != 0 || ( (long) output & 15 ) != 0 ) return( POLARSSL_ERR_PADLOCK_DATA_MISALIGNED ); rk = ctx->rk; iw = PADLOCK_ALIGN16( buf ); memcpy( iw, iv, 16 ); ctrl = iw + 4; *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + (mode^1) - 10 ) << 9 ); count = (length + 15) >> 4; asm( "pushfl; popfl \n" \ "movl %%ebx, %0 \n" \ "movl %2, %%ecx \n" \ "movl %3, %%edx \n" \ "movl %4, %%ebx \n" \ "movl %5, %%esi \n" \ "movl %6, %%edi \n" \ "movl %7, %%eax \n" \ ".byte 0xf3,0x0f,0xa7,0xd0\n" \ "movl %1, %%ebx \n" : "=m" (ebx) : "m" (ebx), "m" (count), "m" (ctrl), "m" (rk), "m" (input), "m" (output), "m" (iw) : "eax", "ecx", "edx", "esi", "edi" ); memcpy( iv, iw, 16 ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/error.c0000644000014601777760000005755412165464055022614 0ustar00jenkinsnogroup00000000000000/* * Error message information * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_ERROR_C) #if defined(POLARSSL_AES_C) #include "polarssl/aes.h" #endif #if defined(POLARSSL_BASE64_C) #include "polarssl/base64.h" #endif #if defined(POLARSSL_BIGNUM_C) #include "polarssl/bignum.h" #endif #if defined(POLARSSL_CAMELLIA_C) #include "polarssl/camellia.h" #endif #if defined(POLARSSL_CIPHER_C) #include "polarssl/cipher.h" #endif #if defined(POLARSSL_CTR_DRBG_C) #include "polarssl/ctr_drbg.h" #endif #if defined(POLARSSL_DES_C) #include "polarssl/des.h" #endif #if defined(POLARSSL_DHM_C) #include "polarssl/dhm.h" #endif #if defined(POLARSSL_ENTROPY_C) #include "polarssl/entropy.h" #endif #if defined(POLARSSL_MD_C) #include "polarssl/md.h" #endif #if defined(POLARSSL_MD2_C) #include "polarssl/md2.h" #endif #if defined(POLARSSL_MD4_C) #include "polarssl/md4.h" #endif #if defined(POLARSSL_MD5_C) #include "polarssl/md5.h" #endif #if defined(POLARSSL_NET_C) #include "polarssl/net.h" #endif #if defined(POLARSSL_PADLOCK_C) #include "polarssl/padlock.h" #endif #if defined(POLARSSL_PEM_C) #include "polarssl/pem.h" #endif #if defined(POLARSSL_RSA_C) #include "polarssl/rsa.h" #endif #if defined(POLARSSL_SHA1_C) #include "polarssl/sha1.h" #endif #if defined(POLARSSL_SHA2_C) #include "polarssl/sha2.h" #endif #if defined(POLARSSL_SHA4_C) #include "polarssl/sha4.h" #endif #if defined(POLARSSL_SSL_TLS_C) #include "polarssl/ssl.h" #endif #if defined(POLARSSL_X509_PARSE_C) #include "polarssl/x509.h" #endif #if defined(POLARSSL_XTEA_C) #include "polarssl/xtea.h" #endif #include #if defined _MSC_VER && !defined snprintf #define snprintf _snprintf #endif void error_strerror( int ret, char *buf, size_t buflen ) { size_t len; int use_ret; memset( buf, 0x00, buflen ); if( ret < 0 ) ret = -ret; if( ret & 0xFF80 ) { use_ret = ret & 0xFF80; // High level error codes // #if defined(POLARSSL_CIPHER_C) if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); #endif /* POLARSSL_CIPHER_C */ #if defined(POLARSSL_DHM_C) if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) snprintf( buf, buflen, "DHM - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) snprintf( buf, buflen, "DHM - Reading of the public values failed" ); if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) snprintf( buf, buflen, "DHM - Makeing of the public value failed" ); if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); #endif /* POLARSSL_DHM_C */ #if defined(POLARSSL_MD_C) if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) snprintf( buf, buflen, "MD - The selected feature is not available" ); if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) snprintf( buf, buflen, "MD - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) snprintf( buf, buflen, "MD - Failed to allocate memory" ); if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) snprintf( buf, buflen, "MD - Opening or reading of file failed" ); #endif /* POLARSSL_MD_C */ #if defined(POLARSSL_PEM_C) if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_PRESENT) ) snprintf( buf, buflen, "PEM - No PEM header found" ); if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) snprintf( buf, buflen, "PEM - PEM string is not as expected" ); if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) snprintf( buf, buflen, "PEM - Failed to allocate memory" ); if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) snprintf( buf, buflen, "PEM - Private key password can't be empty" ); if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); #endif /* POLARSSL_PEM_C */ #if defined(POLARSSL_RSA_C) if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) snprintf( buf, buflen, "RSA - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" ); if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) snprintf( buf, buflen, "RSA - The public key operation failed" ); if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) snprintf( buf, buflen, "RSA - The private key operation failed" ); if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); #endif /* POLARSSL_RSA_C */ #if defined(POLARSSL_SSL_TLS_C) if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) snprintf( buf, buflen, "SSL - The requested feature is not available" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) snprintf( buf, buflen, "SSL - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) snprintf( buf, buflen, "SSL - An unknown cipher was received" ); if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); if( use_ret == -(POLARSSL_ERR_SSL_NO_SESSION_FOUND) ) snprintf( buf, buflen, "SSL - No session to recover was found" ); if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) snprintf( buf, buflen, "SSL - DESCRIPTION MISSING" ); if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) snprintf( buf, buflen, "SSL - The own private key is not set, but needed" ); if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) snprintf( buf, buflen, "SSL - Verification of our peer failed" ); if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP) ) snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Read Public" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS) ) snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Calculate Secret" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) snprintf( buf, buflen, "SSL - Memory allocation failed" ); #endif /* POLARSSL_SSL_TLS_C */ #if defined(POLARSSL_X509_PARSE_C) if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PEM) ) snprintf( buf, buflen, "X509 - The PEM-encoded certificate contains invalid elements, e.g. invalid character" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_FORMAT) ) snprintf( buf, buflen, "X509 - The certificate format is invalid, e.g. different type expected" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_VERSION) ) snprintf( buf, buflen, "X509 - The certificate version element is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SERIAL) ) snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_ALG) ) snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_NAME) ) snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_DATE) ) snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PUBKEY) ) snprintf( buf, buflen, "X509 - The pubkey tag or value is invalid (only RSA is supported)" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE) ) snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS) ) snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION) ) snprintf( buf, buflen, "X509 - Certificate or CRL has an unsupported version number" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG) ) snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_PK_ALG) ) snprintf( buf, buflen, "X509 - Key algorithm is unsupported (only RSA is supported)" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_SIG_MISMATCH) ) snprintf( buf, buflen, "X509 - Certificate signature algorithms do not match. (see \\c ::x509_cert sig_oid)" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_VERSION) ) snprintf( buf, buflen, "X509 - Unsupported RSA key version" ); if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_FORMAT) ) snprintf( buf, buflen, "X509 - Invalid RSA key tag or value" ); if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); if( use_ret == -(POLARSSL_ERR_X509_INVALID_INPUT) ) snprintf( buf, buflen, "X509 - Input invalid" ); if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) snprintf( buf, buflen, "X509 - Allocation of memory failed" ); if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) snprintf( buf, buflen, "X509 - Read/write of file failed" ); #endif /* POLARSSL_X509_PARSE_C */ if( strlen( buf ) == 0 ) snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); } use_ret = ret & ~0xFF80; if( use_ret == 0 ) return; // If high level code is present, make a concatenation between both // error strings. // len = strlen( buf ); if( len > 0 ) { if( buflen - len < 5 ) return; snprintf( buf + len, buflen - len, " : " ); buf += len + 3; buflen -= len + 3; } // Low level error codes // #if defined(POLARSSL_AES_C) if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) snprintf( buf, buflen, "AES - Invalid key length" ); if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) snprintf( buf, buflen, "AES - Invalid data input length" ); #endif /* POLARSSL_AES_C */ #if defined(POLARSSL_ASN1_PARSE_C) if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); #endif /* POLARSSL_ASN1_PARSE_C */ #if defined(POLARSSL_BASE64_C) if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) snprintf( buf, buflen, "BASE64 - Output buffer too small" ); if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) snprintf( buf, buflen, "BASE64 - Invalid character in input" ); #endif /* POLARSSL_BASE64_C */ #if defined(POLARSSL_BIGNUM_C) if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); #endif /* POLARSSL_BIGNUM_C */ #if defined(POLARSSL_CAMELLIA_C) if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); #endif /* POLARSSL_CAMELLIA_C */ #if defined(POLARSSL_CTR_DRBG_C) if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); #endif /* POLARSSL_CTR_DRBG_C */ #if defined(POLARSSL_DES_C) if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) snprintf( buf, buflen, "DES - The data input has an invalid length" ); #endif /* POLARSSL_DES_C */ #if defined(POLARSSL_ENTROPY_C) if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); #endif /* POLARSSL_ENTROPY_C */ #if defined(POLARSSL_MD2_C) if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) snprintf( buf, buflen, "MD2 - Read/write error in file" ); #endif /* POLARSSL_MD2_C */ #if defined(POLARSSL_MD4_C) if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) snprintf( buf, buflen, "MD4 - Read/write error in file" ); #endif /* POLARSSL_MD4_C */ #if defined(POLARSSL_MD5_C) if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) snprintf( buf, buflen, "MD5 - Read/write error in file" ); #endif /* POLARSSL_MD5_C */ #if defined(POLARSSL_NET_C) if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) snprintf( buf, buflen, "NET - Failed to open a socket" ); if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) snprintf( buf, buflen, "NET - Binding of the socket failed" ); if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) snprintf( buf, buflen, "NET - Could not listen on the socket" ); if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) snprintf( buf, buflen, "NET - Reading information from the socket failed" ); if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) snprintf( buf, buflen, "NET - Sending information through the socket failed" ); if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) snprintf( buf, buflen, "NET - Connection was reset by peer" ); if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) snprintf( buf, buflen, "NET - Connection requires a read call" ); if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) snprintf( buf, buflen, "NET - Connection requires a write call" ); #endif /* POLARSSL_NET_C */ #if defined(POLARSSL_PADLOCK_C) if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); #endif /* POLARSSL_PADLOCK_C */ #if defined(POLARSSL_SHA1_C) if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) snprintf( buf, buflen, "SHA1 - Read/write error in file" ); #endif /* POLARSSL_SHA1_C */ #if defined(POLARSSL_SHA2_C) if( use_ret == -(POLARSSL_ERR_SHA2_FILE_IO_ERROR) ) snprintf( buf, buflen, "SHA2 - Read/write error in file" ); #endif /* POLARSSL_SHA2_C */ #if defined(POLARSSL_SHA4_C) if( use_ret == -(POLARSSL_ERR_SHA4_FILE_IO_ERROR) ) snprintf( buf, buflen, "SHA4 - Read/write error in file" ); #endif /* POLARSSL_SHA4_C */ #if defined(POLARSSL_XTEA_C) if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); #endif /* POLARSSL_XTEA_C */ if( strlen( buf ) != 0 ) return; snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); } #endif /* POLARSSL_VERBOSE_ERROR */ pdns-3.3/pdns/ext/polarssl-1.1.2/library/sha1.c0000644000014601777760000003775612165464055022321 0ustar00jenkinsnogroup00000000000000/* * FIPS-180-1 compliant SHA-1 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The SHA-1 standard was published by NIST in 1993. * * http://www.itl.nist.gov/fipspubs/fip180-1.htm */ #include "polarssl/config.h" #if defined(POLARSSL_SHA1_C) #include "polarssl/sha1.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif /* * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE #define GET_ULONG_BE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ | ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (unsigned long) (b)[(i) + 3] ); \ } #endif #ifndef PUT_ULONG_BE #define PUT_ULONG_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ } #endif /* * SHA-1 context setup */ void sha1_starts( sha1_context *ctx ) { ctx->total[0] = 0; ctx->total[1] = 0; ctx->state[0] = 0x67452301; ctx->state[1] = 0xEFCDAB89; ctx->state[2] = 0x98BADCFE; ctx->state[3] = 0x10325476; ctx->state[4] = 0xC3D2E1F0; } static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) { unsigned long temp, W[16], A, B, C, D, E; GET_ULONG_BE( W[ 0], data, 0 ); GET_ULONG_BE( W[ 1], data, 4 ); GET_ULONG_BE( W[ 2], data, 8 ); GET_ULONG_BE( W[ 3], data, 12 ); GET_ULONG_BE( W[ 4], data, 16 ); GET_ULONG_BE( W[ 5], data, 20 ); GET_ULONG_BE( W[ 6], data, 24 ); GET_ULONG_BE( W[ 7], data, 28 ); GET_ULONG_BE( W[ 8], data, 32 ); GET_ULONG_BE( W[ 9], data, 36 ); GET_ULONG_BE( W[10], data, 40 ); GET_ULONG_BE( W[11], data, 44 ); GET_ULONG_BE( W[12], data, 48 ); GET_ULONG_BE( W[13], data, 52 ); GET_ULONG_BE( W[14], data, 56 ); GET_ULONG_BE( W[15], data, 60 ); #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) #define R(t) \ ( \ temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \ W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \ ( W[t & 0x0F] = S(temp,1) ) \ ) #define P(a,b,c,d,e,x) \ { \ e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; E = ctx->state[4]; #define F(x,y,z) (z ^ (x & (y ^ z))) #define K 0x5A827999 P( A, B, C, D, E, W[0] ); P( E, A, B, C, D, W[1] ); P( D, E, A, B, C, W[2] ); P( C, D, E, A, B, W[3] ); P( B, C, D, E, A, W[4] ); P( A, B, C, D, E, W[5] ); P( E, A, B, C, D, W[6] ); P( D, E, A, B, C, W[7] ); P( C, D, E, A, B, W[8] ); P( B, C, D, E, A, W[9] ); P( A, B, C, D, E, W[10] ); P( E, A, B, C, D, W[11] ); P( D, E, A, B, C, W[12] ); P( C, D, E, A, B, W[13] ); P( B, C, D, E, A, W[14] ); P( A, B, C, D, E, W[15] ); P( E, A, B, C, D, R(16) ); P( D, E, A, B, C, R(17) ); P( C, D, E, A, B, R(18) ); P( B, C, D, E, A, R(19) ); #undef K #undef F #define F(x,y,z) (x ^ y ^ z) #define K 0x6ED9EBA1 P( A, B, C, D, E, R(20) ); P( E, A, B, C, D, R(21) ); P( D, E, A, B, C, R(22) ); P( C, D, E, A, B, R(23) ); P( B, C, D, E, A, R(24) ); P( A, B, C, D, E, R(25) ); P( E, A, B, C, D, R(26) ); P( D, E, A, B, C, R(27) ); P( C, D, E, A, B, R(28) ); P( B, C, D, E, A, R(29) ); P( A, B, C, D, E, R(30) ); P( E, A, B, C, D, R(31) ); P( D, E, A, B, C, R(32) ); P( C, D, E, A, B, R(33) ); P( B, C, D, E, A, R(34) ); P( A, B, C, D, E, R(35) ); P( E, A, B, C, D, R(36) ); P( D, E, A, B, C, R(37) ); P( C, D, E, A, B, R(38) ); P( B, C, D, E, A, R(39) ); #undef K #undef F #define F(x,y,z) ((x & y) | (z & (x | y))) #define K 0x8F1BBCDC P( A, B, C, D, E, R(40) ); P( E, A, B, C, D, R(41) ); P( D, E, A, B, C, R(42) ); P( C, D, E, A, B, R(43) ); P( B, C, D, E, A, R(44) ); P( A, B, C, D, E, R(45) ); P( E, A, B, C, D, R(46) ); P( D, E, A, B, C, R(47) ); P( C, D, E, A, B, R(48) ); P( B, C, D, E, A, R(49) ); P( A, B, C, D, E, R(50) ); P( E, A, B, C, D, R(51) ); P( D, E, A, B, C, R(52) ); P( C, D, E, A, B, R(53) ); P( B, C, D, E, A, R(54) ); P( A, B, C, D, E, R(55) ); P( E, A, B, C, D, R(56) ); P( D, E, A, B, C, R(57) ); P( C, D, E, A, B, R(58) ); P( B, C, D, E, A, R(59) ); #undef K #undef F #define F(x,y,z) (x ^ y ^ z) #define K 0xCA62C1D6 P( A, B, C, D, E, R(60) ); P( E, A, B, C, D, R(61) ); P( D, E, A, B, C, R(62) ); P( C, D, E, A, B, R(63) ); P( B, C, D, E, A, R(64) ); P( A, B, C, D, E, R(65) ); P( E, A, B, C, D, R(66) ); P( D, E, A, B, C, R(67) ); P( C, D, E, A, B, R(68) ); P( B, C, D, E, A, R(69) ); P( A, B, C, D, E, R(70) ); P( E, A, B, C, D, R(71) ); P( D, E, A, B, C, R(72) ); P( C, D, E, A, B, R(73) ); P( B, C, D, E, A, R(74) ); P( A, B, C, D, E, R(75) ); P( E, A, B, C, D, R(76) ); P( D, E, A, B, C, R(77) ); P( C, D, E, A, B, R(78) ); P( B, C, D, E, A, R(79) ); #undef K #undef F ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; ctx->state[4] += E; } /* * SHA-1 process buffer */ void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; unsigned long left; if( ilen <= 0 ) return; left = ctx->total[0] & 0x3F; fill = 64 - left; ctx->total[0] += (unsigned long) ilen; ctx->total[0] &= 0xFFFFFFFF; if( ctx->total[0] < (unsigned long) ilen ) ctx->total[1]++; if( left && ilen >= fill ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); sha1_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; } while( ilen >= 64 ) { sha1_process( ctx, input ); input += 64; ilen -= 64; } if( ilen > 0 ) { memcpy( (void *) (ctx->buffer + left), (void *) input, ilen ); } } static const unsigned char sha1_padding[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * SHA-1 final digest */ void sha1_finish( sha1_context *ctx, unsigned char output[20] ) { unsigned long last, padn; unsigned long high, low; unsigned char msglen[8]; high = ( ctx->total[0] >> 29 ) | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_ULONG_BE( high, msglen, 0 ); PUT_ULONG_BE( low, msglen, 4 ); last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); sha1_update( ctx, (unsigned char *) sha1_padding, padn ); sha1_update( ctx, msglen, 8 ); PUT_ULONG_BE( ctx->state[0], output, 0 ); PUT_ULONG_BE( ctx->state[1], output, 4 ); PUT_ULONG_BE( ctx->state[2], output, 8 ); PUT_ULONG_BE( ctx->state[3], output, 12 ); PUT_ULONG_BE( ctx->state[4], output, 16 ); } /* * output = SHA-1( input buffer ) */ void sha1( const unsigned char *input, size_t ilen, unsigned char output[20] ) { sha1_context ctx; sha1_starts( &ctx ); sha1_update( &ctx, input, ilen ); sha1_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha1_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = SHA-1( file contents ) */ int sha1_file( const char *path, unsigned char output[20] ) { FILE *f; size_t n; sha1_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_SHA1_FILE_IO_ERROR ); sha1_starts( &ctx ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) sha1_update( &ctx, buf, n ); sha1_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha1_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_SHA1_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * SHA-1 HMAC context setup */ void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keylen ) { size_t i; unsigned char sum[20]; if( keylen > 64 ) { sha1( key, keylen, sum ); keylen = 20; key = sum; } memset( ctx->ipad, 0x36, 64 ); memset( ctx->opad, 0x5C, 64 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } sha1_starts( ctx ); sha1_update( ctx, ctx->ipad, 64 ); memset( sum, 0, sizeof( sum ) ); } /* * SHA-1 HMAC process buffer */ void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, size_t ilen ) { sha1_update( ctx, input, ilen ); } /* * SHA-1 HMAC final digest */ void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] ) { unsigned char tmpbuf[20]; sha1_finish( ctx, tmpbuf ); sha1_starts( ctx ); sha1_update( ctx, ctx->opad, 64 ); sha1_update( ctx, tmpbuf, 20 ); sha1_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * SHA1 HMAC context reset */ void sha1_hmac_reset( sha1_context *ctx ) { sha1_starts( ctx ); sha1_update( ctx, ctx->ipad, 64 ); } /* * output = HMAC-SHA-1( hmac key, input buffer ) */ void sha1_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[20] ) { sha1_context ctx; sha1_hmac_starts( &ctx, key, keylen ); sha1_hmac_update( &ctx, input, ilen ); sha1_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha1_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * FIPS-180-1 test vectors */ static unsigned char sha1_test_buf[3][57] = { { "abc" }, { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }, { "" } }; static const int sha1_test_buflen[3] = { 3, 56, 1000 }; static const unsigned char sha1_test_sum[3][20] = { { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D }, { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1 }, { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F } }; /* * RFC 2202 test vectors */ static unsigned char sha1_hmac_test_key[7][26] = { { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B" "\x0B\x0B\x0B\x0B" }, { "Jefe" }, { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" "\xAA\xAA\xAA\xAA" }, { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10" "\x11\x12\x13\x14\x15\x16\x17\x18\x19" }, { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C" "\x0C\x0C\x0C\x0C" }, { "" }, /* 0xAA 80 times */ { "" } }; static const int sha1_hmac_test_keylen[7] = { 20, 4, 20, 25, 20, 80, 80 }; static unsigned char sha1_hmac_test_buf[7][74] = { { "Hi There" }, { "what do ya want for nothing?" }, { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" }, { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" }, { "Test With Truncation" }, { "Test Using Larger Than Block-Size Key - Hash Key First" }, { "Test Using Larger Than Block-Size Key and Larger" " Than One Block-Size Data" } }; static const int sha1_hmac_test_buflen[7] = { 8, 28, 50, 50, 20, 54, 73 }; static const unsigned char sha1_hmac_test_sum[7][20] = { { 0xB6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, 0xE2, 0x8B, 0xC0, 0xB6, 0xFB, 0x37, 0x8C, 0x8E, 0xF1, 0x46, 0xBE, 0x00 }, { 0xEF, 0xFC, 0xDF, 0x6A, 0xE5, 0xEB, 0x2F, 0xA2, 0xD2, 0x74, 0x16, 0xD5, 0xF1, 0x84, 0xDF, 0x9C, 0x25, 0x9A, 0x7C, 0x79 }, { 0x12, 0x5D, 0x73, 0x42, 0xB9, 0xAC, 0x11, 0xCD, 0x91, 0xA3, 0x9A, 0xF4, 0x8A, 0xA1, 0x7B, 0x4F, 0x63, 0xF1, 0x75, 0xD3 }, { 0x4C, 0x90, 0x07, 0xF4, 0x02, 0x62, 0x50, 0xC6, 0xBC, 0x84, 0x14, 0xF9, 0xBF, 0x50, 0xC8, 0x6C, 0x2D, 0x72, 0x35, 0xDA }, { 0x4C, 0x1A, 0x03, 0x42, 0x4B, 0x55, 0xE0, 0x7F, 0xE7, 0xF2, 0x7B, 0xE1 }, { 0xAA, 0x4A, 0xE5, 0xE1, 0x52, 0x72, 0xD0, 0x0E, 0x95, 0x70, 0x56, 0x37, 0xCE, 0x8A, 0x3B, 0x55, 0xED, 0x40, 0x21, 0x12 }, { 0xE8, 0xE9, 0x9D, 0x0F, 0x45, 0x23, 0x7D, 0x78, 0x6D, 0x6B, 0xBA, 0xA7, 0x96, 0x5C, 0x78, 0x08, 0xBB, 0xFF, 0x1A, 0x91 } }; /* * Checkup routine */ int sha1_self_test( int verbose ) { int i, j, buflen; unsigned char buf[1024]; unsigned char sha1sum[20]; sha1_context ctx; /* * SHA-1 */ for( i = 0; i < 3; i++ ) { if( verbose != 0 ) printf( " SHA-1 test #%d: ", i + 1 ); sha1_starts( &ctx ); if( i == 2 ) { memset( buf, 'a', buflen = 1000 ); for( j = 0; j < 1000; j++ ) sha1_update( &ctx, buf, buflen ); } else sha1_update( &ctx, sha1_test_buf[i], sha1_test_buflen[i] ); sha1_finish( &ctx, sha1sum ); if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); for( i = 0; i < 7; i++ ) { if( verbose != 0 ) printf( " HMAC-SHA-1 test #%d: ", i + 1 ); if( i == 5 || i == 6 ) { memset( buf, '\xAA', buflen = 80 ); sha1_hmac_starts( &ctx, buf, buflen ); } else sha1_hmac_starts( &ctx, sha1_hmac_test_key[i], sha1_hmac_test_keylen[i] ); sha1_hmac_update( &ctx, sha1_hmac_test_buf[i], sha1_hmac_test_buflen[i] ); sha1_hmac_finish( &ctx, sha1sum ); buflen = ( i == 4 ) ? 12 : 20; if( memcmp( sha1sum, sha1_hmac_test_sum[i], buflen ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/cipher_wrap.c0000644000014601777760000003106012165464055023746 0ustar00jenkinsnogroup00000000000000/** * \file md_wrap.c * * \brief Generic cipher wrapper for PolarSSL * * \author Adriaan de Jong * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_CIPHER_C) #include "polarssl/cipher_wrap.h" #include "polarssl/aes.h" #include "polarssl/camellia.h" #include "polarssl/des.h" #include #if defined(POLARSSL_AES_C) int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input, output ); } int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CFB) return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv, input, output ); #else ((void) ctx); ((void) operation); ((void) length); ((void) iv_off); ((void) iv); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; #endif } int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CTR) return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter, stream_block, input, output ); #else ((void) ctx); ((void) length); ((void) nc_off); ((void) nonce_counter); ((void) stream_block); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; #endif } int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { return aes_setkey_dec( (aes_context *) ctx, key, key_length ); } int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { return aes_setkey_enc( (aes_context *) ctx, key, key_length ); } static void * aes_ctx_alloc( void ) { return malloc( sizeof( aes_context ) ); } static void aes_ctx_free( void *ctx ) { free( ctx ); } const cipher_base_t aes_info = { POLARSSL_CIPHER_ID_AES, aes_crypt_cbc_wrap, aes_crypt_cfb128_wrap, aes_crypt_ctr_wrap, aes_setkey_enc_wrap, aes_setkey_dec_wrap, aes_ctx_alloc, aes_ctx_free }; const cipher_info_t aes_128_cbc_info = { POLARSSL_CIPHER_AES_128_CBC, POLARSSL_MODE_CBC, 128, "AES-128-CBC", 16, 16, &aes_info }; const cipher_info_t aes_192_cbc_info = { POLARSSL_CIPHER_AES_192_CBC, POLARSSL_MODE_CBC, 192, "AES-192-CBC", 16, 16, &aes_info }; const cipher_info_t aes_256_cbc_info = { POLARSSL_CIPHER_AES_256_CBC, POLARSSL_MODE_CBC, 256, "AES-256-CBC", 16, 16, &aes_info }; #if defined(POLARSSL_CIPHER_MODE_CFB) const cipher_info_t aes_128_cfb128_info = { POLARSSL_CIPHER_AES_128_CFB128, POLARSSL_MODE_CFB128, 128, "AES-128-CFB128", 16, 16, &aes_info }; const cipher_info_t aes_192_cfb128_info = { POLARSSL_CIPHER_AES_192_CFB128, POLARSSL_MODE_CFB128, 192, "AES-192-CFB128", 16, 16, &aes_info }; const cipher_info_t aes_256_cfb128_info = { POLARSSL_CIPHER_AES_256_CFB128, POLARSSL_MODE_CFB128, 256, "AES-256-CFB128", 16, 16, &aes_info }; #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) const cipher_info_t aes_128_ctr_info = { POLARSSL_CIPHER_AES_128_CTR, POLARSSL_MODE_CTR, 128, "AES-128-CTR", 16, 16, &aes_info }; const cipher_info_t aes_192_ctr_info = { POLARSSL_CIPHER_AES_192_CTR, POLARSSL_MODE_CTR, 192, "AES-192-CTR", 16, 16, &aes_info }; const cipher_info_t aes_256_ctr_info = { POLARSSL_CIPHER_AES_256_CTR, POLARSSL_MODE_CTR, 256, "AES-256-CTR", 16, 16, &aes_info }; #endif /* POLARSSL_CIPHER_MODE_CTR */ #endif #if defined(POLARSSL_CAMELLIA_C) int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv, input, output ); } int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CFB) return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length, iv_off, iv, input, output ); #else ((void) ctx); ((void) operation); ((void) length); ((void) iv_off); ((void) iv); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; #endif } int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CTR) return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off, nonce_counter, stream_block, input, output ); #else ((void) ctx); ((void) length); ((void) nc_off); ((void) nonce_counter); ((void) stream_block); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; #endif } int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { return camellia_setkey_dec( (camellia_context *) ctx, key, key_length ); } int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { return camellia_setkey_enc( (camellia_context *) ctx, key, key_length ); } static void * camellia_ctx_alloc( void ) { return malloc( sizeof( camellia_context ) ); } static void camellia_ctx_free( void *ctx ) { free( ctx ); } const cipher_base_t camellia_info = { POLARSSL_CIPHER_ID_CAMELLIA, camellia_crypt_cbc_wrap, camellia_crypt_cfb128_wrap, camellia_crypt_ctr_wrap, camellia_setkey_enc_wrap, camellia_setkey_dec_wrap, camellia_ctx_alloc, camellia_ctx_free }; const cipher_info_t camellia_128_cbc_info = { POLARSSL_CIPHER_CAMELLIA_128_CBC, POLARSSL_MODE_CBC, 128, "CAMELLIA-128-CBC", 16, 16, &camellia_info }; const cipher_info_t camellia_192_cbc_info = { POLARSSL_CIPHER_CAMELLIA_192_CBC, POLARSSL_MODE_CBC, 192, "CAMELLIA-192-CBC", 16, 16, &camellia_info }; const cipher_info_t camellia_256_cbc_info = { POLARSSL_CIPHER_CAMELLIA_256_CBC, POLARSSL_MODE_CBC, 256, "CAMELLIA-256-CBC", 16, 16, &camellia_info }; #if defined(POLARSSL_CIPHER_MODE_CFB) const cipher_info_t camellia_128_cfb128_info = { POLARSSL_CIPHER_CAMELLIA_128_CFB128, POLARSSL_MODE_CFB128, 128, "CAMELLIA-128-CFB128", 16, 16, &camellia_info }; const cipher_info_t camellia_192_cfb128_info = { POLARSSL_CIPHER_CAMELLIA_192_CFB128, POLARSSL_MODE_CFB128, 192, "CAMELLIA-192-CFB128", 16, 16, &camellia_info }; const cipher_info_t camellia_256_cfb128_info = { POLARSSL_CIPHER_CAMELLIA_256_CFB128, POLARSSL_MODE_CFB128, 256, "CAMELLIA-256-CFB128", 16, 16, &camellia_info }; #endif /* POLARSSL_CIPHER_MODE_CFB */ #if defined(POLARSSL_CIPHER_MODE_CTR) const cipher_info_t camellia_128_ctr_info = { POLARSSL_CIPHER_CAMELLIA_128_CTR, POLARSSL_MODE_CTR, 128, "CAMELLIA-128-CTR", 16, 16, &camellia_info }; const cipher_info_t camellia_192_ctr_info = { POLARSSL_CIPHER_CAMELLIA_192_CTR, POLARSSL_MODE_CTR, 192, "CAMELLIA-192-CTR", 16, 16, &camellia_info }; const cipher_info_t camellia_256_ctr_info = { POLARSSL_CIPHER_CAMELLIA_256_CTR, POLARSSL_MODE_CTR, 256, "CAMELLIA-256-CTR", 16, 16, &camellia_info }; #endif /* POLARSSL_CIPHER_MODE_CTR */ #endif #if defined(POLARSSL_DES_C) int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input, output ); } int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input, output ); } int des_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) { ((void) ctx); ((void) operation); ((void) length); ((void) iv_off); ((void) iv); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } int des_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { ((void) ctx); ((void) length); ((void) nc_off); ((void) nonce_counter); ((void) stream_block); ((void) input); ((void) output); return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } int des_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des_setkey_dec( (des_context *) ctx, key ); } int des_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des_setkey_enc( (des_context *) ctx, key ); } int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des3_set2key_dec( (des3_context *) ctx, key ); } int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des3_set2key_enc( (des3_context *) ctx, key ); } int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des3_set3key_dec( (des3_context *) ctx, key ); } int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) { ((void) key_length); return des3_set3key_enc( (des3_context *) ctx, key ); } static void * des_ctx_alloc( void ) { return malloc( sizeof( des_context ) ); } static void * des3_ctx_alloc( void ) { return malloc( sizeof( des3_context ) ); } static void des_ctx_free( void *ctx ) { free( ctx ); } const cipher_base_t des_info = { POLARSSL_CIPHER_ID_DES, des_crypt_cbc_wrap, des_crypt_cfb128_wrap, des_crypt_ctr_wrap, des_setkey_enc_wrap, des_setkey_dec_wrap, des_ctx_alloc, des_ctx_free }; const cipher_info_t des_cbc_info = { POLARSSL_CIPHER_DES_CBC, POLARSSL_MODE_CBC, POLARSSL_KEY_LENGTH_DES, "DES-CBC", 8, 8, &des_info }; const cipher_base_t des_ede_info = { POLARSSL_CIPHER_ID_DES, des3_crypt_cbc_wrap, des_crypt_cfb128_wrap, des_crypt_ctr_wrap, des3_set2key_enc_wrap, des3_set2key_dec_wrap, des3_ctx_alloc, des_ctx_free }; const cipher_info_t des_ede_cbc_info = { POLARSSL_CIPHER_DES_EDE_CBC, POLARSSL_MODE_CBC, POLARSSL_KEY_LENGTH_DES_EDE, "DES-EDE-CBC", 16, 16, &des_ede_info }; const cipher_base_t des_ede3_info = { POLARSSL_CIPHER_ID_DES, des3_crypt_cbc_wrap, des_crypt_cfb128_wrap, des_crypt_ctr_wrap, des3_set3key_enc_wrap, des3_set3key_dec_wrap, des3_ctx_alloc, des_ctx_free }; const cipher_info_t des_ede3_cbc_info = { POLARSSL_CIPHER_DES_EDE3_CBC, POLARSSL_MODE_CBC, POLARSSL_KEY_LENGTH_DES_EDE3, "DES-EDE3-CBC", 8, 8, &des_ede3_info }; #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/md4.c0000644000014601777760000002650712165464055022141 0ustar00jenkinsnogroup00000000000000/* * RFC 1186/1320 compliant MD4 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The MD4 algorithm was designed by Ron Rivest in 1990. * * http://www.ietf.org/rfc/rfc1186.txt * http://www.ietf.org/rfc/rfc1320.txt */ #include "polarssl/config.h" #if defined(POLARSSL_MD4_C) #include "polarssl/md4.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif /* * 32-bit integer manipulation macros (little endian) */ #ifndef GET_ULONG_LE #define GET_ULONG_LE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] ) \ | ( (unsigned long) (b)[(i) + 1] << 8 ) \ | ( (unsigned long) (b)[(i) + 2] << 16 ) \ | ( (unsigned long) (b)[(i) + 3] << 24 ); \ } #endif #ifndef PUT_ULONG_LE #define PUT_ULONG_LE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ } #endif /* * MD4 context setup */ void md4_starts( md4_context *ctx ) { ctx->total[0] = 0; ctx->total[1] = 0; ctx->state[0] = 0x67452301; ctx->state[1] = 0xEFCDAB89; ctx->state[2] = 0x98BADCFE; ctx->state[3] = 0x10325476; } static void md4_process( md4_context *ctx, const unsigned char data[64] ) { unsigned long X[16], A, B, C, D; GET_ULONG_LE( X[ 0], data, 0 ); GET_ULONG_LE( X[ 1], data, 4 ); GET_ULONG_LE( X[ 2], data, 8 ); GET_ULONG_LE( X[ 3], data, 12 ); GET_ULONG_LE( X[ 4], data, 16 ); GET_ULONG_LE( X[ 5], data, 20 ); GET_ULONG_LE( X[ 6], data, 24 ); GET_ULONG_LE( X[ 7], data, 28 ); GET_ULONG_LE( X[ 8], data, 32 ); GET_ULONG_LE( X[ 9], data, 36 ); GET_ULONG_LE( X[10], data, 40 ); GET_ULONG_LE( X[11], data, 44 ); GET_ULONG_LE( X[12], data, 48 ); GET_ULONG_LE( X[13], data, 52 ); GET_ULONG_LE( X[14], data, 56 ); GET_ULONG_LE( X[15], data, 60 ); #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; #define F(x, y, z) ((x & y) | ((~x) & z)) #define P(a,b,c,d,x,s) { a += F(b,c,d) + x; a = S(a,s); } P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 1], 7 ); P( C, D, A, B, X[ 2], 11 ); P( B, C, D, A, X[ 3], 19 ); P( A, B, C, D, X[ 4], 3 ); P( D, A, B, C, X[ 5], 7 ); P( C, D, A, B, X[ 6], 11 ); P( B, C, D, A, X[ 7], 19 ); P( A, B, C, D, X[ 8], 3 ); P( D, A, B, C, X[ 9], 7 ); P( C, D, A, B, X[10], 11 ); P( B, C, D, A, X[11], 19 ); P( A, B, C, D, X[12], 3 ); P( D, A, B, C, X[13], 7 ); P( C, D, A, B, X[14], 11 ); P( B, C, D, A, X[15], 19 ); #undef P #undef F #define F(x,y,z) ((x & y) | (x & z) | (y & z)) #define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); } P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 4], 5 ); P( C, D, A, B, X[ 8], 9 ); P( B, C, D, A, X[12], 13 ); P( A, B, C, D, X[ 1], 3 ); P( D, A, B, C, X[ 5], 5 ); P( C, D, A, B, X[ 9], 9 ); P( B, C, D, A, X[13], 13 ); P( A, B, C, D, X[ 2], 3 ); P( D, A, B, C, X[ 6], 5 ); P( C, D, A, B, X[10], 9 ); P( B, C, D, A, X[14], 13 ); P( A, B, C, D, X[ 3], 3 ); P( D, A, B, C, X[ 7], 5 ); P( C, D, A, B, X[11], 9 ); P( B, C, D, A, X[15], 13 ); #undef P #undef F #define F(x,y,z) (x ^ y ^ z) #define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); } P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 8], 9 ); P( C, D, A, B, X[ 4], 11 ); P( B, C, D, A, X[12], 15 ); P( A, B, C, D, X[ 2], 3 ); P( D, A, B, C, X[10], 9 ); P( C, D, A, B, X[ 6], 11 ); P( B, C, D, A, X[14], 15 ); P( A, B, C, D, X[ 1], 3 ); P( D, A, B, C, X[ 9], 9 ); P( C, D, A, B, X[ 5], 11 ); P( B, C, D, A, X[13], 15 ); P( A, B, C, D, X[ 3], 3 ); P( D, A, B, C, X[11], 9 ); P( C, D, A, B, X[ 7], 11 ); P( B, C, D, A, X[15], 15 ); #undef F #undef P ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; } /* * MD4 process buffer */ void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; unsigned long left; if( ilen <= 0 ) return; left = ctx->total[0] & 0x3F; fill = 64 - left; ctx->total[0] += (unsigned long) ilen; ctx->total[0] &= 0xFFFFFFFF; if( ctx->total[0] < (unsigned long) ilen ) ctx->total[1]++; if( left && ilen >= fill ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); md4_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; } while( ilen >= 64 ) { md4_process( ctx, input ); input += 64; ilen -= 64; } if( ilen > 0 ) { memcpy( (void *) (ctx->buffer + left), (void *) input, ilen ); } } static const unsigned char md4_padding[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * MD4 final digest */ void md4_finish( md4_context *ctx, unsigned char output[16] ) { unsigned long last, padn; unsigned long high, low; unsigned char msglen[8]; high = ( ctx->total[0] >> 29 ) | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_ULONG_LE( low, msglen, 0 ); PUT_ULONG_LE( high, msglen, 4 ); last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); md4_update( ctx, (unsigned char *) md4_padding, padn ); md4_update( ctx, msglen, 8 ); PUT_ULONG_LE( ctx->state[0], output, 0 ); PUT_ULONG_LE( ctx->state[1], output, 4 ); PUT_ULONG_LE( ctx->state[2], output, 8 ); PUT_ULONG_LE( ctx->state[3], output, 12 ); } /* * output = MD4( input buffer ) */ void md4( const unsigned char *input, size_t ilen, unsigned char output[16] ) { md4_context ctx; md4_starts( &ctx ); md4_update( &ctx, input, ilen ); md4_finish( &ctx, output ); memset( &ctx, 0, sizeof( md4_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = MD4( file contents ) */ int md4_file( const char *path, unsigned char output[16] ) { FILE *f; size_t n; md4_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_MD4_FILE_IO_ERROR ); md4_starts( &ctx ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) md4_update( &ctx, buf, n ); md4_finish( &ctx, output ); memset( &ctx, 0, sizeof( md4_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_MD4_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * MD4 HMAC context setup */ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen ) { size_t i; unsigned char sum[16]; if( keylen > 64 ) { md4( key, keylen, sum ); keylen = 16; key = sum; } memset( ctx->ipad, 0x36, 64 ); memset( ctx->opad, 0x5C, 64 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } md4_starts( ctx ); md4_update( ctx, ctx->ipad, 64 ); memset( sum, 0, sizeof( sum ) ); } /* * MD4 HMAC process buffer */ void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen ) { md4_update( ctx, input, ilen ); } /* * MD4 HMAC final digest */ void md4_hmac_finish( md4_context *ctx, unsigned char output[16] ) { unsigned char tmpbuf[16]; md4_finish( ctx, tmpbuf ); md4_starts( ctx ); md4_update( ctx, ctx->opad, 64 ); md4_update( ctx, tmpbuf, 16 ); md4_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * MD4 HMAC context reset */ void md4_hmac_reset( md4_context *ctx ) { md4_starts( ctx ); md4_update( ctx, ctx->ipad, 64 ); } /* * output = HMAC-MD4( hmac key, input buffer ) */ void md4_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ) { md4_context ctx; md4_hmac_starts( &ctx, key, keylen ); md4_hmac_update( &ctx, input, ilen ); md4_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( md4_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * RFC 1320 test vectors */ static const char md4_test_str[7][81] = { { "" }, { "a" }, { "abc" }, { "message digest" }, { "abcdefghijklmnopqrstuvwxyz" }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, { "12345678901234567890123456789012345678901234567890123456789012" \ "345678901234567890" } }; static const unsigned char md4_test_sum[7][16] = { { 0x31, 0xD6, 0xCF, 0xE0, 0xD1, 0x6A, 0xE9, 0x31, 0xB7, 0x3C, 0x59, 0xD7, 0xE0, 0xC0, 0x89, 0xC0 }, { 0xBD, 0xE5, 0x2C, 0xB3, 0x1D, 0xE3, 0x3E, 0x46, 0x24, 0x5E, 0x05, 0xFB, 0xDB, 0xD6, 0xFB, 0x24 }, { 0xA4, 0x48, 0x01, 0x7A, 0xAF, 0x21, 0xD8, 0x52, 0x5F, 0xC1, 0x0A, 0xE8, 0x7A, 0xA6, 0x72, 0x9D }, { 0xD9, 0x13, 0x0A, 0x81, 0x64, 0x54, 0x9F, 0xE8, 0x18, 0x87, 0x48, 0x06, 0xE1, 0xC7, 0x01, 0x4B }, { 0xD7, 0x9E, 0x1C, 0x30, 0x8A, 0xA5, 0xBB, 0xCD, 0xEE, 0xA8, 0xED, 0x63, 0xDF, 0x41, 0x2D, 0xA9 }, { 0x04, 0x3F, 0x85, 0x82, 0xF2, 0x41, 0xDB, 0x35, 0x1C, 0xE6, 0x27, 0xE1, 0x53, 0xE7, 0xF0, 0xE4 }, { 0xE3, 0x3B, 0x4D, 0xDC, 0x9C, 0x38, 0xF2, 0x19, 0x9C, 0x3E, 0x7B, 0x16, 0x4F, 0xCC, 0x05, 0x36 } }; /* * Checkup routine */ int md4_self_test( int verbose ) { int i; unsigned char md4sum[16]; for( i = 0; i < 7; i++ ) { if( verbose != 0 ) printf( " MD4 test #%d: ", i + 1 ); md4( (unsigned char *) md4_test_str[i], strlen( md4_test_str[i] ), md4sum ); if( memcmp( md4sum, md4_test_sum[i], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/sha4.c0000644000014601777760000005771412165464055022320 0ustar00jenkinsnogroup00000000000000/* * FIPS-180-2 compliant SHA-384/512 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The SHA-512 Secure Hash Standard was published by NIST in 2002. * * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_SHA4_C) #include "polarssl/sha4.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif /* * 64-bit integer manipulation macros (big endian) */ #ifndef GET_UINT64_BE #define GET_UINT64_BE(n,b,i) \ { \ (n) = ( (unsigned long64) (b)[(i) ] << 56 ) \ | ( (unsigned long64) (b)[(i) + 1] << 48 ) \ | ( (unsigned long64) (b)[(i) + 2] << 40 ) \ | ( (unsigned long64) (b)[(i) + 3] << 32 ) \ | ( (unsigned long64) (b)[(i) + 4] << 24 ) \ | ( (unsigned long64) (b)[(i) + 5] << 16 ) \ | ( (unsigned long64) (b)[(i) + 6] << 8 ) \ | ( (unsigned long64) (b)[(i) + 7] ); \ } #endif #ifndef PUT_UINT64_BE #define PUT_UINT64_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \ (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \ (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 7] = (unsigned char) ( (n) ); \ } #endif /* * Round constants */ static const unsigned long64 K[80] = { UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD), UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC), UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019), UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118), UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE), UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2), UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1), UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694), UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3), UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65), UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483), UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5), UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210), UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4), UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725), UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70), UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926), UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF), UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8), UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B), UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001), UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30), UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910), UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8), UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53), UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8), UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB), UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3), UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60), UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC), UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9), UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B), UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207), UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178), UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6), UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B), UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493), UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C), UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A), UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817) }; /* * SHA-512 context setup */ void sha4_starts( sha4_context *ctx, int is384 ) { ctx->total[0] = 0; ctx->total[1] = 0; if( is384 == 0 ) { /* SHA-512 */ ctx->state[0] = UL64(0x6A09E667F3BCC908); ctx->state[1] = UL64(0xBB67AE8584CAA73B); ctx->state[2] = UL64(0x3C6EF372FE94F82B); ctx->state[3] = UL64(0xA54FF53A5F1D36F1); ctx->state[4] = UL64(0x510E527FADE682D1); ctx->state[5] = UL64(0x9B05688C2B3E6C1F); ctx->state[6] = UL64(0x1F83D9ABFB41BD6B); ctx->state[7] = UL64(0x5BE0CD19137E2179); } else { /* SHA-384 */ ctx->state[0] = UL64(0xCBBB9D5DC1059ED8); ctx->state[1] = UL64(0x629A292A367CD507); ctx->state[2] = UL64(0x9159015A3070DD17); ctx->state[3] = UL64(0x152FECD8F70E5939); ctx->state[4] = UL64(0x67332667FFC00B31); ctx->state[5] = UL64(0x8EB44A8768581511); ctx->state[6] = UL64(0xDB0C2E0D64F98FA7); ctx->state[7] = UL64(0x47B5481DBEFA4FA4); } ctx->is384 = is384; } static void sha4_process( sha4_context *ctx, const unsigned char data[128] ) { int i; unsigned long64 temp1, temp2, W[80]; unsigned long64 A, B, C, D, E, F, G, H; #define SHR(x,n) (x >> n) #define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) #define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) #define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6)) #define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39)) #define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41)) #define F0(x,y,z) ((x & y) | (z & (x | y))) #define F1(x,y,z) (z ^ (x & (y ^ z))) #define P(a,b,c,d,e,f,g,h,x,K) \ { \ temp1 = h + S3(e) + F1(e,f,g) + K + x; \ temp2 = S2(a) + F0(a,b,c); \ d += temp1; h = temp1 + temp2; \ } for( i = 0; i < 16; i++ ) { GET_UINT64_BE( W[i], data, i << 3 ); } for( ; i < 80; i++ ) { W[i] = S1(W[i - 2]) + W[i - 7] + S0(W[i - 15]) + W[i - 16]; } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; E = ctx->state[4]; F = ctx->state[5]; G = ctx->state[6]; H = ctx->state[7]; i = 0; do { P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++; P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++; P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++; P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++; P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++; P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++; P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++; P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++; } while( i < 80 ); ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; ctx->state[4] += E; ctx->state[5] += F; ctx->state[6] += G; ctx->state[7] += H; } /* * SHA-512 process buffer */ void sha4_update( sha4_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; unsigned int left; if( ilen <= 0 ) return; left = (unsigned int) (ctx->total[0] & 0x7F); fill = 128 - left; ctx->total[0] += (unsigned long64) ilen; if( ctx->total[0] < (unsigned long64) ilen ) ctx->total[1]++; if( left && ilen >= fill ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); sha4_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; } while( ilen >= 128 ) { sha4_process( ctx, input ); input += 128; ilen -= 128; } if( ilen > 0 ) { memcpy( (void *) (ctx->buffer + left), (void *) input, ilen ); } } static const unsigned char sha4_padding[128] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * SHA-512 final digest */ void sha4_finish( sha4_context *ctx, unsigned char output[64] ) { size_t last, padn; unsigned long64 high, low; unsigned char msglen[16]; high = ( ctx->total[0] >> 61 ) | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_UINT64_BE( high, msglen, 0 ); PUT_UINT64_BE( low, msglen, 8 ); last = (size_t)( ctx->total[0] & 0x7F ); padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last ); sha4_update( ctx, (unsigned char *) sha4_padding, padn ); sha4_update( ctx, msglen, 16 ); PUT_UINT64_BE( ctx->state[0], output, 0 ); PUT_UINT64_BE( ctx->state[1], output, 8 ); PUT_UINT64_BE( ctx->state[2], output, 16 ); PUT_UINT64_BE( ctx->state[3], output, 24 ); PUT_UINT64_BE( ctx->state[4], output, 32 ); PUT_UINT64_BE( ctx->state[5], output, 40 ); if( ctx->is384 == 0 ) { PUT_UINT64_BE( ctx->state[6], output, 48 ); PUT_UINT64_BE( ctx->state[7], output, 56 ); } } /* * output = SHA-512( input buffer ) */ void sha4( const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ) { sha4_context ctx; sha4_starts( &ctx, is384 ); sha4_update( &ctx, input, ilen ); sha4_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha4_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = SHA-512( file contents ) */ int sha4_file( const char *path, unsigned char output[64], int is384 ) { FILE *f; size_t n; sha4_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_SHA4_FILE_IO_ERROR ); sha4_starts( &ctx, is384 ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) sha4_update( &ctx, buf, n ); sha4_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha4_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_SHA4_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * SHA-512 HMAC context setup */ void sha4_hmac_starts( sha4_context *ctx, const unsigned char *key, size_t keylen, int is384 ) { size_t i; unsigned char sum[64]; if( keylen > 128 ) { sha4( key, keylen, sum, is384 ); keylen = ( is384 ) ? 48 : 64; key = sum; } memset( ctx->ipad, 0x36, 128 ); memset( ctx->opad, 0x5C, 128 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } sha4_starts( ctx, is384 ); sha4_update( ctx, ctx->ipad, 128 ); memset( sum, 0, sizeof( sum ) ); } /* * SHA-512 HMAC process buffer */ void sha4_hmac_update( sha4_context *ctx, const unsigned char *input, size_t ilen ) { sha4_update( ctx, input, ilen ); } /* * SHA-512 HMAC final digest */ void sha4_hmac_finish( sha4_context *ctx, unsigned char output[64] ) { int is384, hlen; unsigned char tmpbuf[64]; is384 = ctx->is384; hlen = ( is384 == 0 ) ? 64 : 48; sha4_finish( ctx, tmpbuf ); sha4_starts( ctx, is384 ); sha4_update( ctx, ctx->opad, 128 ); sha4_update( ctx, tmpbuf, hlen ); sha4_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * SHA-512 HMAC context reset */ void sha4_hmac_reset( sha4_context *ctx ) { sha4_starts( ctx, ctx->is384 ); sha4_update( ctx, ctx->ipad, 128 ); } /* * output = HMAC-SHA-512( hmac key, input buffer ) */ void sha4_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ) { sha4_context ctx; sha4_hmac_starts( &ctx, key, keylen, is384 ); sha4_hmac_update( &ctx, input, ilen ); sha4_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( sha4_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * FIPS-180-2 test vectors */ static unsigned char sha4_test_buf[3][113] = { { "abc" }, { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" }, { "" } }; static const int sha4_test_buflen[3] = { 3, 112, 1000 }; static const unsigned char sha4_test_sum[6][64] = { /* * SHA-384 test vectors */ { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B, 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07, 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63, 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED, 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23, 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7 }, { 0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8, 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47, 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2, 0x2F, 0xA0, 0x80, 0x86, 0xE3, 0xB0, 0xF7, 0x12, 0xFC, 0xC7, 0xC7, 0x1A, 0x55, 0x7E, 0x2D, 0xB9, 0x66, 0xC3, 0xE9, 0xFA, 0x91, 0x74, 0x60, 0x39 }, { 0x9D, 0x0E, 0x18, 0x09, 0x71, 0x64, 0x74, 0xCB, 0x08, 0x6E, 0x83, 0x4E, 0x31, 0x0A, 0x4A, 0x1C, 0xED, 0x14, 0x9E, 0x9C, 0x00, 0xF2, 0x48, 0x52, 0x79, 0x72, 0xCE, 0xC5, 0x70, 0x4C, 0x2A, 0x5B, 0x07, 0xB8, 0xB3, 0xDC, 0x38, 0xEC, 0xC4, 0xEB, 0xAE, 0x97, 0xDD, 0xD8, 0x7F, 0x3D, 0x89, 0x85 }, /* * SHA-512 test vectors */ { 0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA, 0xCC, 0x41, 0x73, 0x49, 0xAE, 0x20, 0x41, 0x31, 0x12, 0xE6, 0xFA, 0x4E, 0x89, 0xA9, 0x7E, 0xA2, 0x0A, 0x9E, 0xEE, 0xE6, 0x4B, 0x55, 0xD3, 0x9A, 0x21, 0x92, 0x99, 0x2A, 0x27, 0x4F, 0xC1, 0xA8, 0x36, 0xBA, 0x3C, 0x23, 0xA3, 0xFE, 0xEB, 0xBD, 0x45, 0x4D, 0x44, 0x23, 0x64, 0x3C, 0xE8, 0x0E, 0x2A, 0x9A, 0xC9, 0x4F, 0xA5, 0x4C, 0xA4, 0x9F }, { 0x8E, 0x95, 0x9B, 0x75, 0xDA, 0xE3, 0x13, 0xDA, 0x8C, 0xF4, 0xF7, 0x28, 0x14, 0xFC, 0x14, 0x3F, 0x8F, 0x77, 0x79, 0xC6, 0xEB, 0x9F, 0x7F, 0xA1, 0x72, 0x99, 0xAE, 0xAD, 0xB6, 0x88, 0x90, 0x18, 0x50, 0x1D, 0x28, 0x9E, 0x49, 0x00, 0xF7, 0xE4, 0x33, 0x1B, 0x99, 0xDE, 0xC4, 0xB5, 0x43, 0x3A, 0xC7, 0xD3, 0x29, 0xEE, 0xB6, 0xDD, 0x26, 0x54, 0x5E, 0x96, 0xE5, 0x5B, 0x87, 0x4B, 0xE9, 0x09 }, { 0xE7, 0x18, 0x48, 0x3D, 0x0C, 0xE7, 0x69, 0x64, 0x4E, 0x2E, 0x42, 0xC7, 0xBC, 0x15, 0xB4, 0x63, 0x8E, 0x1F, 0x98, 0xB1, 0x3B, 0x20, 0x44, 0x28, 0x56, 0x32, 0xA8, 0x03, 0xAF, 0xA9, 0x73, 0xEB, 0xDE, 0x0F, 0xF2, 0x44, 0x87, 0x7E, 0xA6, 0x0A, 0x4C, 0xB0, 0x43, 0x2C, 0xE5, 0x77, 0xC3, 0x1B, 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E, 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B } }; /* * RFC 4231 test vectors */ static unsigned char sha4_hmac_test_key[7][26] = { { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B" "\x0B\x0B\x0B\x0B" }, { "Jefe" }, { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" "\xAA\xAA\xAA\xAA" }, { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10" "\x11\x12\x13\x14\x15\x16\x17\x18\x19" }, { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C" "\x0C\x0C\x0C\x0C" }, { "" }, /* 0xAA 131 times */ { "" } }; static const int sha4_hmac_test_keylen[7] = { 20, 4, 20, 25, 20, 131, 131 }; static unsigned char sha4_hmac_test_buf[7][153] = { { "Hi There" }, { "what do ya want for nothing?" }, { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" }, { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" }, { "Test With Truncation" }, { "Test Using Larger Than Block-Size Key - Hash Key First" }, { "This is a test using a larger than block-size key " "and a larger than block-size data. The key needs to " "be hashed before being used by the HMAC algorithm." } }; static const int sha4_hmac_test_buflen[7] = { 8, 28, 50, 50, 20, 54, 152 }; static const unsigned char sha4_hmac_test_sum[14][64] = { /* * HMAC-SHA-384 test vectors */ { 0xAF, 0xD0, 0x39, 0x44, 0xD8, 0x48, 0x95, 0x62, 0x6B, 0x08, 0x25, 0xF4, 0xAB, 0x46, 0x90, 0x7F, 0x15, 0xF9, 0xDA, 0xDB, 0xE4, 0x10, 0x1E, 0xC6, 0x82, 0xAA, 0x03, 0x4C, 0x7C, 0xEB, 0xC5, 0x9C, 0xFA, 0xEA, 0x9E, 0xA9, 0x07, 0x6E, 0xDE, 0x7F, 0x4A, 0xF1, 0x52, 0xE8, 0xB2, 0xFA, 0x9C, 0xB6 }, { 0xAF, 0x45, 0xD2, 0xE3, 0x76, 0x48, 0x40, 0x31, 0x61, 0x7F, 0x78, 0xD2, 0xB5, 0x8A, 0x6B, 0x1B, 0x9C, 0x7E, 0xF4, 0x64, 0xF5, 0xA0, 0x1B, 0x47, 0xE4, 0x2E, 0xC3, 0x73, 0x63, 0x22, 0x44, 0x5E, 0x8E, 0x22, 0x40, 0xCA, 0x5E, 0x69, 0xE2, 0xC7, 0x8B, 0x32, 0x39, 0xEC, 0xFA, 0xB2, 0x16, 0x49 }, { 0x88, 0x06, 0x26, 0x08, 0xD3, 0xE6, 0xAD, 0x8A, 0x0A, 0xA2, 0xAC, 0xE0, 0x14, 0xC8, 0xA8, 0x6F, 0x0A, 0xA6, 0x35, 0xD9, 0x47, 0xAC, 0x9F, 0xEB, 0xE8, 0x3E, 0xF4, 0xE5, 0x59, 0x66, 0x14, 0x4B, 0x2A, 0x5A, 0xB3, 0x9D, 0xC1, 0x38, 0x14, 0xB9, 0x4E, 0x3A, 0xB6, 0xE1, 0x01, 0xA3, 0x4F, 0x27 }, { 0x3E, 0x8A, 0x69, 0xB7, 0x78, 0x3C, 0x25, 0x85, 0x19, 0x33, 0xAB, 0x62, 0x90, 0xAF, 0x6C, 0xA7, 0x7A, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9C, 0xC5, 0x57, 0x7C, 0x6E, 0x1F, 0x57, 0x3B, 0x4E, 0x68, 0x01, 0xDD, 0x23, 0xC4, 0xA7, 0xD6, 0x79, 0xCC, 0xF8, 0xA3, 0x86, 0xC6, 0x74, 0xCF, 0xFB }, { 0x3A, 0xBF, 0x34, 0xC3, 0x50, 0x3B, 0x2A, 0x23, 0xA4, 0x6E, 0xFC, 0x61, 0x9B, 0xAE, 0xF8, 0x97 }, { 0x4E, 0xCE, 0x08, 0x44, 0x85, 0x81, 0x3E, 0x90, 0x88, 0xD2, 0xC6, 0x3A, 0x04, 0x1B, 0xC5, 0xB4, 0x4F, 0x9E, 0xF1, 0x01, 0x2A, 0x2B, 0x58, 0x8F, 0x3C, 0xD1, 0x1F, 0x05, 0x03, 0x3A, 0xC4, 0xC6, 0x0C, 0x2E, 0xF6, 0xAB, 0x40, 0x30, 0xFE, 0x82, 0x96, 0x24, 0x8D, 0xF1, 0x63, 0xF4, 0x49, 0x52 }, { 0x66, 0x17, 0x17, 0x8E, 0x94, 0x1F, 0x02, 0x0D, 0x35, 0x1E, 0x2F, 0x25, 0x4E, 0x8F, 0xD3, 0x2C, 0x60, 0x24, 0x20, 0xFE, 0xB0, 0xB8, 0xFB, 0x9A, 0xDC, 0xCE, 0xBB, 0x82, 0x46, 0x1E, 0x99, 0xC5, 0xA6, 0x78, 0xCC, 0x31, 0xE7, 0x99, 0x17, 0x6D, 0x38, 0x60, 0xE6, 0x11, 0x0C, 0x46, 0x52, 0x3E }, /* * HMAC-SHA-512 test vectors */ { 0x87, 0xAA, 0x7C, 0xDE, 0xA5, 0xEF, 0x61, 0x9D, 0x4F, 0xF0, 0xB4, 0x24, 0x1A, 0x1D, 0x6C, 0xB0, 0x23, 0x79, 0xF4, 0xE2, 0xCE, 0x4E, 0xC2, 0x78, 0x7A, 0xD0, 0xB3, 0x05, 0x45, 0xE1, 0x7C, 0xDE, 0xDA, 0xA8, 0x33, 0xB7, 0xD6, 0xB8, 0xA7, 0x02, 0x03, 0x8B, 0x27, 0x4E, 0xAE, 0xA3, 0xF4, 0xE4, 0xBE, 0x9D, 0x91, 0x4E, 0xEB, 0x61, 0xF1, 0x70, 0x2E, 0x69, 0x6C, 0x20, 0x3A, 0x12, 0x68, 0x54 }, { 0x16, 0x4B, 0x7A, 0x7B, 0xFC, 0xF8, 0x19, 0xE2, 0xE3, 0x95, 0xFB, 0xE7, 0x3B, 0x56, 0xE0, 0xA3, 0x87, 0xBD, 0x64, 0x22, 0x2E, 0x83, 0x1F, 0xD6, 0x10, 0x27, 0x0C, 0xD7, 0xEA, 0x25, 0x05, 0x54, 0x97, 0x58, 0xBF, 0x75, 0xC0, 0x5A, 0x99, 0x4A, 0x6D, 0x03, 0x4F, 0x65, 0xF8, 0xF0, 0xE6, 0xFD, 0xCA, 0xEA, 0xB1, 0xA3, 0x4D, 0x4A, 0x6B, 0x4B, 0x63, 0x6E, 0x07, 0x0A, 0x38, 0xBC, 0xE7, 0x37 }, { 0xFA, 0x73, 0xB0, 0x08, 0x9D, 0x56, 0xA2, 0x84, 0xEF, 0xB0, 0xF0, 0x75, 0x6C, 0x89, 0x0B, 0xE9, 0xB1, 0xB5, 0xDB, 0xDD, 0x8E, 0xE8, 0x1A, 0x36, 0x55, 0xF8, 0x3E, 0x33, 0xB2, 0x27, 0x9D, 0x39, 0xBF, 0x3E, 0x84, 0x82, 0x79, 0xA7, 0x22, 0xC8, 0x06, 0xB4, 0x85, 0xA4, 0x7E, 0x67, 0xC8, 0x07, 0xB9, 0x46, 0xA3, 0x37, 0xBE, 0xE8, 0x94, 0x26, 0x74, 0x27, 0x88, 0x59, 0xE1, 0x32, 0x92, 0xFB }, { 0xB0, 0xBA, 0x46, 0x56, 0x37, 0x45, 0x8C, 0x69, 0x90, 0xE5, 0xA8, 0xC5, 0xF6, 0x1D, 0x4A, 0xF7, 0xE5, 0x76, 0xD9, 0x7F, 0xF9, 0x4B, 0x87, 0x2D, 0xE7, 0x6F, 0x80, 0x50, 0x36, 0x1E, 0xE3, 0xDB, 0xA9, 0x1C, 0xA5, 0xC1, 0x1A, 0xA2, 0x5E, 0xB4, 0xD6, 0x79, 0x27, 0x5C, 0xC5, 0x78, 0x80, 0x63, 0xA5, 0xF1, 0x97, 0x41, 0x12, 0x0C, 0x4F, 0x2D, 0xE2, 0xAD, 0xEB, 0xEB, 0x10, 0xA2, 0x98, 0xDD }, { 0x41, 0x5F, 0xAD, 0x62, 0x71, 0x58, 0x0A, 0x53, 0x1D, 0x41, 0x79, 0xBC, 0x89, 0x1D, 0x87, 0xA6 }, { 0x80, 0xB2, 0x42, 0x63, 0xC7, 0xC1, 0xA3, 0xEB, 0xB7, 0x14, 0x93, 0xC1, 0xDD, 0x7B, 0xE8, 0xB4, 0x9B, 0x46, 0xD1, 0xF4, 0x1B, 0x4A, 0xEE, 0xC1, 0x12, 0x1B, 0x01, 0x37, 0x83, 0xF8, 0xF3, 0x52, 0x6B, 0x56, 0xD0, 0x37, 0xE0, 0x5F, 0x25, 0x98, 0xBD, 0x0F, 0xD2, 0x21, 0x5D, 0x6A, 0x1E, 0x52, 0x95, 0xE6, 0x4F, 0x73, 0xF6, 0x3F, 0x0A, 0xEC, 0x8B, 0x91, 0x5A, 0x98, 0x5D, 0x78, 0x65, 0x98 }, { 0xE3, 0x7B, 0x6A, 0x77, 0x5D, 0xC8, 0x7D, 0xBA, 0xA4, 0xDF, 0xA9, 0xF9, 0x6E, 0x5E, 0x3F, 0xFD, 0xDE, 0xBD, 0x71, 0xF8, 0x86, 0x72, 0x89, 0x86, 0x5D, 0xF5, 0xA3, 0x2D, 0x20, 0xCD, 0xC9, 0x44, 0xB6, 0x02, 0x2C, 0xAC, 0x3C, 0x49, 0x82, 0xB1, 0x0D, 0x5E, 0xEB, 0x55, 0xC3, 0xE4, 0xDE, 0x15, 0x13, 0x46, 0x76, 0xFB, 0x6D, 0xE0, 0x44, 0x60, 0x65, 0xC9, 0x74, 0x40, 0xFA, 0x8C, 0x6A, 0x58 } }; /* * Checkup routine */ int sha4_self_test( int verbose ) { int i, j, k, buflen; unsigned char buf[1024]; unsigned char sha4sum[64]; sha4_context ctx; for( i = 0; i < 6; i++ ) { j = i % 3; k = i < 3; if( verbose != 0 ) printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 ); sha4_starts( &ctx, k ); if( j == 2 ) { memset( buf, 'a', buflen = 1000 ); for( j = 0; j < 1000; j++ ) sha4_update( &ctx, buf, buflen ); } else sha4_update( &ctx, sha4_test_buf[j], sha4_test_buflen[j] ); sha4_finish( &ctx, sha4sum ); if( memcmp( sha4sum, sha4_test_sum[i], 64 - k * 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); for( i = 0; i < 14; i++ ) { j = i % 7; k = i < 7; if( verbose != 0 ) printf( " HMAC-SHA-%d test #%d: ", 512 - k * 128, j + 1 ); if( j == 5 || j == 6 ) { memset( buf, '\xAA', buflen = 131 ); sha4_hmac_starts( &ctx, buf, buflen, k ); } else sha4_hmac_starts( &ctx, sha4_hmac_test_key[j], sha4_hmac_test_keylen[j], k ); sha4_hmac_update( &ctx, sha4_hmac_test_buf[j], sha4_hmac_test_buflen[j] ); sha4_hmac_finish( &ctx, sha4sum ); buflen = ( j == 4 ) ? 16 : 64 - k * 16; if( memcmp( sha4sum, sha4_hmac_test_sum[i], buflen ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/md5.c0000644000014601777760000003676412165464055022150 0ustar00jenkinsnogroup00000000000000/* * RFC 1321 compliant MD5 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The MD5 algorithm was designed by Ron Rivest in 1991. * * http://www.ietf.org/rfc/rfc1321.txt */ #include "polarssl/config.h" #if defined(POLARSSL_MD5_C) #include "polarssl/md5.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif /* * 32-bit integer manipulation macros (little endian) */ #ifndef GET_ULONG_LE #define GET_ULONG_LE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] ) \ | ( (unsigned long) (b)[(i) + 1] << 8 ) \ | ( (unsigned long) (b)[(i) + 2] << 16 ) \ | ( (unsigned long) (b)[(i) + 3] << 24 ); \ } #endif #ifndef PUT_ULONG_LE #define PUT_ULONG_LE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ } #endif /* * MD5 context setup */ void md5_starts( md5_context *ctx ) { ctx->total[0] = 0; ctx->total[1] = 0; ctx->state[0] = 0x67452301; ctx->state[1] = 0xEFCDAB89; ctx->state[2] = 0x98BADCFE; ctx->state[3] = 0x10325476; } static void md5_process( md5_context *ctx, const unsigned char data[64] ) { unsigned long X[16], A, B, C, D; GET_ULONG_LE( X[ 0], data, 0 ); GET_ULONG_LE( X[ 1], data, 4 ); GET_ULONG_LE( X[ 2], data, 8 ); GET_ULONG_LE( X[ 3], data, 12 ); GET_ULONG_LE( X[ 4], data, 16 ); GET_ULONG_LE( X[ 5], data, 20 ); GET_ULONG_LE( X[ 6], data, 24 ); GET_ULONG_LE( X[ 7], data, 28 ); GET_ULONG_LE( X[ 8], data, 32 ); GET_ULONG_LE( X[ 9], data, 36 ); GET_ULONG_LE( X[10], data, 40 ); GET_ULONG_LE( X[11], data, 44 ); GET_ULONG_LE( X[12], data, 48 ); GET_ULONG_LE( X[13], data, 52 ); GET_ULONG_LE( X[14], data, 56 ); GET_ULONG_LE( X[15], data, 60 ); #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) #define P(a,b,c,d,k,s,t) \ { \ a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; #define F(x,y,z) (z ^ (x & (y ^ z))) P( A, B, C, D, 0, 7, 0xD76AA478 ); P( D, A, B, C, 1, 12, 0xE8C7B756 ); P( C, D, A, B, 2, 17, 0x242070DB ); P( B, C, D, A, 3, 22, 0xC1BDCEEE ); P( A, B, C, D, 4, 7, 0xF57C0FAF ); P( D, A, B, C, 5, 12, 0x4787C62A ); P( C, D, A, B, 6, 17, 0xA8304613 ); P( B, C, D, A, 7, 22, 0xFD469501 ); P( A, B, C, D, 8, 7, 0x698098D8 ); P( D, A, B, C, 9, 12, 0x8B44F7AF ); P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); P( B, C, D, A, 11, 22, 0x895CD7BE ); P( A, B, C, D, 12, 7, 0x6B901122 ); P( D, A, B, C, 13, 12, 0xFD987193 ); P( C, D, A, B, 14, 17, 0xA679438E ); P( B, C, D, A, 15, 22, 0x49B40821 ); #undef F #define F(x,y,z) (y ^ (z & (x ^ y))) P( A, B, C, D, 1, 5, 0xF61E2562 ); P( D, A, B, C, 6, 9, 0xC040B340 ); P( C, D, A, B, 11, 14, 0x265E5A51 ); P( B, C, D, A, 0, 20, 0xE9B6C7AA ); P( A, B, C, D, 5, 5, 0xD62F105D ); P( D, A, B, C, 10, 9, 0x02441453 ); P( C, D, A, B, 15, 14, 0xD8A1E681 ); P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); P( A, B, C, D, 9, 5, 0x21E1CDE6 ); P( D, A, B, C, 14, 9, 0xC33707D6 ); P( C, D, A, B, 3, 14, 0xF4D50D87 ); P( B, C, D, A, 8, 20, 0x455A14ED ); P( A, B, C, D, 13, 5, 0xA9E3E905 ); P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); P( C, D, A, B, 7, 14, 0x676F02D9 ); P( B, C, D, A, 12, 20, 0x8D2A4C8A ); #undef F #define F(x,y,z) (x ^ y ^ z) P( A, B, C, D, 5, 4, 0xFFFA3942 ); P( D, A, B, C, 8, 11, 0x8771F681 ); P( C, D, A, B, 11, 16, 0x6D9D6122 ); P( B, C, D, A, 14, 23, 0xFDE5380C ); P( A, B, C, D, 1, 4, 0xA4BEEA44 ); P( D, A, B, C, 4, 11, 0x4BDECFA9 ); P( C, D, A, B, 7, 16, 0xF6BB4B60 ); P( B, C, D, A, 10, 23, 0xBEBFBC70 ); P( A, B, C, D, 13, 4, 0x289B7EC6 ); P( D, A, B, C, 0, 11, 0xEAA127FA ); P( C, D, A, B, 3, 16, 0xD4EF3085 ); P( B, C, D, A, 6, 23, 0x04881D05 ); P( A, B, C, D, 9, 4, 0xD9D4D039 ); P( D, A, B, C, 12, 11, 0xE6DB99E5 ); P( C, D, A, B, 15, 16, 0x1FA27CF8 ); P( B, C, D, A, 2, 23, 0xC4AC5665 ); #undef F #define F(x,y,z) (y ^ (x | ~z)) P( A, B, C, D, 0, 6, 0xF4292244 ); P( D, A, B, C, 7, 10, 0x432AFF97 ); P( C, D, A, B, 14, 15, 0xAB9423A7 ); P( B, C, D, A, 5, 21, 0xFC93A039 ); P( A, B, C, D, 12, 6, 0x655B59C3 ); P( D, A, B, C, 3, 10, 0x8F0CCC92 ); P( C, D, A, B, 10, 15, 0xFFEFF47D ); P( B, C, D, A, 1, 21, 0x85845DD1 ); P( A, B, C, D, 8, 6, 0x6FA87E4F ); P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); P( C, D, A, B, 6, 15, 0xA3014314 ); P( B, C, D, A, 13, 21, 0x4E0811A1 ); P( A, B, C, D, 4, 6, 0xF7537E82 ); P( D, A, B, C, 11, 10, 0xBD3AF235 ); P( C, D, A, B, 2, 15, 0x2AD7D2BB ); P( B, C, D, A, 9, 21, 0xEB86D391 ); #undef F ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; } /* * MD5 process buffer */ void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; unsigned long left; if( ilen <= 0 ) return; left = ctx->total[0] & 0x3F; fill = 64 - left; ctx->total[0] += (unsigned long) ilen; ctx->total[0] &= 0xFFFFFFFF; if( ctx->total[0] < (unsigned long) ilen ) ctx->total[1]++; if( left && ilen >= fill ) { memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); md5_process( ctx, ctx->buffer ); input += fill; ilen -= fill; left = 0; } while( ilen >= 64 ) { md5_process( ctx, input ); input += 64; ilen -= 64; } if( ilen > 0 ) { memcpy( (void *) (ctx->buffer + left), (void *) input, ilen ); } } static const unsigned char md5_padding[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * MD5 final digest */ void md5_finish( md5_context *ctx, unsigned char output[16] ) { unsigned long last, padn; unsigned long high, low; unsigned char msglen[8]; high = ( ctx->total[0] >> 29 ) | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_ULONG_LE( low, msglen, 0 ); PUT_ULONG_LE( high, msglen, 4 ); last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); md5_update( ctx, (unsigned char *) md5_padding, padn ); md5_update( ctx, msglen, 8 ); PUT_ULONG_LE( ctx->state[0], output, 0 ); PUT_ULONG_LE( ctx->state[1], output, 4 ); PUT_ULONG_LE( ctx->state[2], output, 8 ); PUT_ULONG_LE( ctx->state[3], output, 12 ); } /* * output = MD5( input buffer ) */ void md5( const unsigned char *input, size_t ilen, unsigned char output[16] ) { md5_context ctx; md5_starts( &ctx ); md5_update( &ctx, input, ilen ); md5_finish( &ctx, output ); memset( &ctx, 0, sizeof( md5_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = MD5( file contents ) */ int md5_file( const char *path, unsigned char output[16] ) { FILE *f; size_t n; md5_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_MD5_FILE_IO_ERROR ); md5_starts( &ctx ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) md5_update( &ctx, buf, n ); md5_finish( &ctx, output ); memset( &ctx, 0, sizeof( md5_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_MD5_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * MD5 HMAC context setup */ void md5_hmac_starts( md5_context *ctx, const unsigned char *key, size_t keylen ) { size_t i; unsigned char sum[16]; if( keylen > 64 ) { md5( key, keylen, sum ); keylen = 16; key = sum; } memset( ctx->ipad, 0x36, 64 ); memset( ctx->opad, 0x5C, 64 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } md5_starts( ctx ); md5_update( ctx, ctx->ipad, 64 ); memset( sum, 0, sizeof( sum ) ); } /* * MD5 HMAC process buffer */ void md5_hmac_update( md5_context *ctx, const unsigned char *input, size_t ilen ) { md5_update( ctx, input, ilen ); } /* * MD5 HMAC final digest */ void md5_hmac_finish( md5_context *ctx, unsigned char output[16] ) { unsigned char tmpbuf[16]; md5_finish( ctx, tmpbuf ); md5_starts( ctx ); md5_update( ctx, ctx->opad, 64 ); md5_update( ctx, tmpbuf, 16 ); md5_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * MD5 HMAC context reset */ void md5_hmac_reset( md5_context *ctx ) { md5_starts( ctx ); md5_update( ctx, ctx->ipad, 64 ); } /* * output = HMAC-MD5( hmac key, input buffer ) */ void md5_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ) { md5_context ctx; md5_hmac_starts( &ctx, key, keylen ); md5_hmac_update( &ctx, input, ilen ); md5_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( md5_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * RFC 1321 test vectors */ static unsigned char md5_test_buf[7][81] = { { "" }, { "a" }, { "abc" }, { "message digest" }, { "abcdefghijklmnopqrstuvwxyz" }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, { "12345678901234567890123456789012345678901234567890123456789012" \ "345678901234567890" } }; static const int md5_test_buflen[7] = { 0, 1, 3, 14, 26, 62, 80 }; static const unsigned char md5_test_sum[7][16] = { { 0xD4, 0x1D, 0x8C, 0xD9, 0x8F, 0x00, 0xB2, 0x04, 0xE9, 0x80, 0x09, 0x98, 0xEC, 0xF8, 0x42, 0x7E }, { 0x0C, 0xC1, 0x75, 0xB9, 0xC0, 0xF1, 0xB6, 0xA8, 0x31, 0xC3, 0x99, 0xE2, 0x69, 0x77, 0x26, 0x61 }, { 0x90, 0x01, 0x50, 0x98, 0x3C, 0xD2, 0x4F, 0xB0, 0xD6, 0x96, 0x3F, 0x7D, 0x28, 0xE1, 0x7F, 0x72 }, { 0xF9, 0x6B, 0x69, 0x7D, 0x7C, 0xB7, 0x93, 0x8D, 0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0 }, { 0xC3, 0xFC, 0xD3, 0xD7, 0x61, 0x92, 0xE4, 0x00, 0x7D, 0xFB, 0x49, 0x6C, 0xCA, 0x67, 0xE1, 0x3B }, { 0xD1, 0x74, 0xAB, 0x98, 0xD2, 0x77, 0xD9, 0xF5, 0xA5, 0x61, 0x1C, 0x2C, 0x9F, 0x41, 0x9D, 0x9F }, { 0x57, 0xED, 0xF4, 0xA2, 0x2B, 0xE3, 0xC9, 0x55, 0xAC, 0x49, 0xDA, 0x2E, 0x21, 0x07, 0xB6, 0x7A } }; /* * RFC 2202 test vectors */ static unsigned char md5_hmac_test_key[7][26] = { { "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B" }, { "Jefe" }, { "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" }, { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10" "\x11\x12\x13\x14\x15\x16\x17\x18\x19" }, { "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C" }, { "" }, /* 0xAA 80 times */ { "" } }; static const int md5_hmac_test_keylen[7] = { 16, 4, 16, 25, 16, 80, 80 }; static unsigned char md5_hmac_test_buf[7][74] = { { "Hi There" }, { "what do ya want for nothing?" }, { "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD" }, { "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD" }, { "Test With Truncation" }, { "Test Using Larger Than Block-Size Key - Hash Key First" }, { "Test Using Larger Than Block-Size Key and Larger" " Than One Block-Size Data" } }; static const int md5_hmac_test_buflen[7] = { 8, 28, 50, 50, 20, 54, 73 }; static const unsigned char md5_hmac_test_sum[7][16] = { { 0x92, 0x94, 0x72, 0x7A, 0x36, 0x38, 0xBB, 0x1C, 0x13, 0xF4, 0x8E, 0xF8, 0x15, 0x8B, 0xFC, 0x9D }, { 0x75, 0x0C, 0x78, 0x3E, 0x6A, 0xB0, 0xB5, 0x03, 0xEA, 0xA8, 0x6E, 0x31, 0x0A, 0x5D, 0xB7, 0x38 }, { 0x56, 0xBE, 0x34, 0x52, 0x1D, 0x14, 0x4C, 0x88, 0xDB, 0xB8, 0xC7, 0x33, 0xF0, 0xE8, 0xB3, 0xF6 }, { 0x69, 0x7E, 0xAF, 0x0A, 0xCA, 0x3A, 0x3A, 0xEA, 0x3A, 0x75, 0x16, 0x47, 0x46, 0xFF, 0xAA, 0x79 }, { 0x56, 0x46, 0x1E, 0xF2, 0x34, 0x2E, 0xDC, 0x00, 0xF9, 0xBA, 0xB9, 0x95 }, { 0x6B, 0x1A, 0xB7, 0xFE, 0x4B, 0xD7, 0xBF, 0x8F, 0x0B, 0x62, 0xE6, 0xCE, 0x61, 0xB9, 0xD0, 0xCD }, { 0x6F, 0x63, 0x0F, 0xAD, 0x67, 0xCD, 0xA0, 0xEE, 0x1F, 0xB1, 0xF5, 0x62, 0xDB, 0x3A, 0xA5, 0x3E } }; /* * Checkup routine */ int md5_self_test( int verbose ) { int i, buflen; unsigned char buf[1024]; unsigned char md5sum[16]; md5_context ctx; for( i = 0; i < 7; i++ ) { if( verbose != 0 ) printf( " MD5 test #%d: ", i + 1 ); md5( md5_test_buf[i], md5_test_buflen[i], md5sum ); if( memcmp( md5sum, md5_test_sum[i], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); for( i = 0; i < 7; i++ ) { if( verbose != 0 ) printf( " HMAC-MD5 test #%d: ", i + 1 ); if( i == 5 || i == 6 ) { memset( buf, '\xAA', buflen = 80 ); md5_hmac_starts( &ctx, buf, buflen ); } else md5_hmac_starts( &ctx, md5_hmac_test_key[i], md5_hmac_test_keylen[i] ); md5_hmac_update( &ctx, md5_hmac_test_buf[i], md5_hmac_test_buflen[i] ); md5_hmac_finish( &ctx, md5sum ); buflen = ( i == 4 ) ? 12 : 16; if( memcmp( md5sum, md5_hmac_test_sum[i], buflen ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/asn1parse.c0000644000014601777760000001377412165464055023354 0ustar00jenkinsnogroup00000000000000/* * Generic ASN.1 parsing * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_ASN1_PARSE_C) #include "polarssl/asn1.h" #if defined(POLARSSL_BIGNUM_C) #include "polarssl/bignum.h" #endif #include #include #include /* * ASN.1 DER decoding routines */ int asn1_get_len( unsigned char **p, const unsigned char *end, size_t *len ) { if( ( end - *p ) < 1 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); if( ( **p & 0x80 ) == 0 ) *len = *(*p)++; else { switch( **p & 0x7F ) { case 1: if( ( end - *p ) < 2 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); *len = (*p)[1]; (*p) += 2; break; case 2: if( ( end - *p ) < 3 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); *len = ( (*p)[1] << 8 ) | (*p)[2]; (*p) += 3; break; case 3: if( ( end - *p ) < 4 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); *len = ( (*p)[1] << 16 ) | ( (*p)[2] << 8 ) | (*p)[3]; (*p) += 4; break; case 4: if( ( end - *p ) < 5 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); *len = ( (*p)[1] << 24 ) | ( (*p)[2] << 16 ) | ( (*p)[3] << 8 ) | (*p)[4]; (*p) += 5; break; default: return( POLARSSL_ERR_ASN1_INVALID_LENGTH ); } } if( *len > (size_t) ( end - *p ) ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); return( 0 ); } int asn1_get_tag( unsigned char **p, const unsigned char *end, size_t *len, int tag ) { if( ( end - *p ) < 1 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); if( **p != tag ) return( POLARSSL_ERR_ASN1_UNEXPECTED_TAG ); (*p)++; return( asn1_get_len( p, end, len ) ); } int asn1_get_bool( unsigned char **p, const unsigned char *end, int *val ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_BOOLEAN ) ) != 0 ) return( ret ); if( len != 1 ) return( POLARSSL_ERR_ASN1_INVALID_LENGTH ); *val = ( **p != 0 ) ? 1 : 0; (*p)++; return( 0 ); } int asn1_get_int( unsigned char **p, const unsigned char *end, int *val ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_INTEGER ) ) != 0 ) return( ret ); if( len > sizeof( int ) || ( **p & 0x80 ) != 0 ) return( POLARSSL_ERR_ASN1_INVALID_LENGTH ); *val = 0; while( len-- > 0 ) { *val = ( *val << 8 ) | **p; (*p)++; } return( 0 ); } #if defined(POLARSSL_BIGNUM_C) int asn1_get_mpi( unsigned char **p, const unsigned char *end, mpi *X ) { int ret; size_t len; if( ( ret = asn1_get_tag( p, end, &len, ASN1_INTEGER ) ) != 0 ) return( ret ); ret = mpi_read_binary( X, *p, len ); *p += len; return( ret ); } #endif /* POLARSSL_BIGNUM_C */ int asn1_get_bitstring( unsigned char **p, const unsigned char *end, asn1_bitstring *bs) { int ret; /* Certificate type is a single byte bitstring */ if( ( ret = asn1_get_tag( p, end, &bs->len, ASN1_BIT_STRING ) ) != 0 ) return( ret ); /* Check length, subtract one for actual bit string length */ if ( bs->len < 1 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); bs->len -= 1; /* Get number of unused bits, ensure unused bits <= 7 */ bs->unused_bits = **p; if( bs->unused_bits > 7 ) return( POLARSSL_ERR_ASN1_INVALID_LENGTH ); (*p)++; /* Get actual bitstring */ bs->p = *p; *p += bs->len; if( *p != end ) return( POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return 0; } /* * Parses and splits an ASN.1 "SEQUENCE OF " */ int asn1_get_sequence_of( unsigned char **p, const unsigned char *end, asn1_sequence *cur, int tag) { int ret; size_t len; asn1_buf *buf; /* Get main sequence tag */ if( ( ret = asn1_get_tag( p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ) != 0 ) return( ret ); if( *p + len != end ) return( POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); while( *p < end ) { buf = &(cur->buf); buf->tag = **p; if( ( ret = asn1_get_tag( p, end, &buf->len, tag ) ) != 0 ) return( ret ); buf->p = *p; *p += buf->len; /* Allocate and assign next pointer */ if (*p < end) { cur->next = (asn1_sequence *) malloc( sizeof( asn1_sequence ) ); if( cur->next == NULL ) return( POLARSSL_ERR_ASN1_MALLOC_FAILED ); cur = cur->next; } } /* Set final sequence entry's next pointer to NULL */ cur->next = NULL; if( *p != end ) return( POLARSSL_ERR_ASN1_LENGTH_MISMATCH ); return( 0 ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/arc4.c0000644000014601777760000000755012165464055022303 0ustar00jenkinsnogroup00000000000000/* * An implementation of the ARCFOUR algorithm * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The ARCFOUR algorithm was publicly disclosed on 94/09. * * http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0 */ #include "polarssl/config.h" #if defined(POLARSSL_ARC4_C) #include "polarssl/arc4.h" /* * ARC4 key schedule */ void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen ) { int i, j, a; unsigned int k; unsigned char *m; ctx->x = 0; ctx->y = 0; m = ctx->m; for( i = 0; i < 256; i++ ) m[i] = (unsigned char) i; j = k = 0; for( i = 0; i < 256; i++, k++ ) { if( k >= keylen ) k = 0; a = m[i]; j = ( j + a + key[k] ) & 0xFF; m[i] = m[j]; m[j] = (unsigned char) a; } } /* * ARC4 cipher function */ int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output ) { int x, y, a, b; size_t i; unsigned char *m; x = ctx->x; y = ctx->y; m = ctx->m; for( i = 0; i < length; i++ ) { x = ( x + 1 ) & 0xFF; a = m[x]; y = ( y + a ) & 0xFF; b = m[y]; m[x] = (unsigned char) b; m[y] = (unsigned char) a; output[i] = (unsigned char) ( input[i] ^ m[(unsigned char)( a + b )] ); } ctx->x = x; ctx->y = y; return( 0 ); } #if defined(POLARSSL_SELF_TEST) #include #include /* * ARC4 tests vectors as posted by Eric Rescorla in sep. 1994: * * http://groups.google.com/group/comp.security.misc/msg/10a300c9d21afca0 */ static const unsigned char arc4_test_key[3][8] = { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; static const unsigned char arc4_test_pt[3][8] = { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; static const unsigned char arc4_test_ct[3][8] = { { 0x75, 0xB7, 0x87, 0x80, 0x99, 0xE0, 0xC5, 0x96 }, { 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 }, { 0xDE, 0x18, 0x89, 0x41, 0xA3, 0x37, 0x5D, 0x3A } }; /* * Checkup routine */ int arc4_self_test( int verbose ) { int i; unsigned char ibuf[8]; unsigned char obuf[8]; arc4_context ctx; for( i = 0; i < 3; i++ ) { if( verbose != 0 ) printf( " ARC4 test #%d: ", i + 1 ); memcpy( ibuf, arc4_test_pt[i], 8 ); arc4_setup( &ctx, (unsigned char *) arc4_test_key[i], 8 ); arc4_crypt( &ctx, 8, ibuf, obuf ); if( memcmp( obuf, arc4_test_ct[i], 8 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/havege.c0000644000014601777760000002120312165464055022700 0ustar00jenkinsnogroup00000000000000/** * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The HAVEGE RNG was designed by Andre Seznec in 2002. * * http://www.irisa.fr/caps/projects/hipsor/publi.php * * Contact: seznec(at)irisa_dot_fr - orocheco(at)irisa_dot_fr */ #include "polarssl/config.h" #if defined(POLARSSL_HAVEGE_C) #include "polarssl/havege.h" #include "polarssl/timing.h" #include #include /* ------------------------------------------------------------------------ * On average, one iteration accesses two 8-word blocks in the havege WALK * table, and generates 16 words in the RES array. * * The data read in the WALK table is updated and permuted after each use. * The result of the hardware clock counter read is used for this update. * * 25 conditional tests are present. The conditional tests are grouped in * two nested groups of 12 conditional tests and 1 test that controls the * permutation; on average, there should be 6 tests executed and 3 of them * should be mispredicted. * ------------------------------------------------------------------------ */ #define SWAP(X,Y) { int *T = X; X = Y; Y = T; } #define TST1_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; #define TST2_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; #define TST1_LEAVE U1++; } #define TST2_LEAVE U2++; } #define ONE_ITERATION \ \ PTEST = PT1 >> 20; \ \ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ TST1_ENTER TST1_ENTER TST1_ENTER TST1_ENTER \ \ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ TST1_LEAVE TST1_LEAVE TST1_LEAVE TST1_LEAVE \ \ PTX = (PT1 >> 18) & 7; \ PT1 &= 0x1FFF; \ PT2 &= 0x1FFF; \ CLK = (int) hardclock(); \ \ i = 0; \ A = &WALK[PT1 ]; RES[i++] ^= *A; \ B = &WALK[PT2 ]; RES[i++] ^= *B; \ C = &WALK[PT1 ^ 1]; RES[i++] ^= *C; \ D = &WALK[PT2 ^ 4]; RES[i++] ^= *D; \ \ IN = (*A >> (1)) ^ (*A << (31)) ^ CLK; \ *A = (*B >> (2)) ^ (*B << (30)) ^ CLK; \ *B = IN ^ U1; \ *C = (*C >> (3)) ^ (*C << (29)) ^ CLK; \ *D = (*D >> (4)) ^ (*D << (28)) ^ CLK; \ \ A = &WALK[PT1 ^ 2]; RES[i++] ^= *A; \ B = &WALK[PT2 ^ 2]; RES[i++] ^= *B; \ C = &WALK[PT1 ^ 3]; RES[i++] ^= *C; \ D = &WALK[PT2 ^ 6]; RES[i++] ^= *D; \ \ if( PTEST & 1 ) SWAP( A, C ); \ \ IN = (*A >> (5)) ^ (*A << (27)) ^ CLK; \ *A = (*B >> (6)) ^ (*B << (26)) ^ CLK; \ *B = IN; CLK = (int) hardclock(); \ *C = (*C >> (7)) ^ (*C << (25)) ^ CLK; \ *D = (*D >> (8)) ^ (*D << (24)) ^ CLK; \ \ A = &WALK[PT1 ^ 4]; \ B = &WALK[PT2 ^ 1]; \ \ PTEST = PT2 >> 1; \ \ PT2 = (RES[(i - 8) ^ PTY] ^ WALK[PT2 ^ PTY ^ 7]); \ PT2 = ((PT2 & 0x1FFF) & (~8)) ^ ((PT1 ^ 8) & 0x8); \ PTY = (PT2 >> 10) & 7; \ \ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ TST2_ENTER TST2_ENTER TST2_ENTER TST2_ENTER \ \ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ TST2_LEAVE TST2_LEAVE TST2_LEAVE TST2_LEAVE \ \ C = &WALK[PT1 ^ 5]; \ D = &WALK[PT2 ^ 5]; \ \ RES[i++] ^= *A; \ RES[i++] ^= *B; \ RES[i++] ^= *C; \ RES[i++] ^= *D; \ \ IN = (*A >> ( 9)) ^ (*A << (23)) ^ CLK; \ *A = (*B >> (10)) ^ (*B << (22)) ^ CLK; \ *B = IN ^ U2; \ *C = (*C >> (11)) ^ (*C << (21)) ^ CLK; \ *D = (*D >> (12)) ^ (*D << (20)) ^ CLK; \ \ A = &WALK[PT1 ^ 6]; RES[i++] ^= *A; \ B = &WALK[PT2 ^ 3]; RES[i++] ^= *B; \ C = &WALK[PT1 ^ 7]; RES[i++] ^= *C; \ D = &WALK[PT2 ^ 7]; RES[i++] ^= *D; \ \ IN = (*A >> (13)) ^ (*A << (19)) ^ CLK; \ *A = (*B >> (14)) ^ (*B << (18)) ^ CLK; \ *B = IN; \ *C = (*C >> (15)) ^ (*C << (17)) ^ CLK; \ *D = (*D >> (16)) ^ (*D << (16)) ^ CLK; \ \ PT1 = ( RES[(i - 8) ^ PTX] ^ \ WALK[PT1 ^ PTX ^ 7] ) & (~1); \ PT1 ^= (PT2 ^ 0x10) & 0x10; \ \ for( n++, i = 0; i < 16; i++ ) \ hs->pool[n % COLLECT_SIZE] ^= RES[i]; /* * Entropy gathering function */ static void havege_fill( havege_state *hs ) { int i, n = 0; int U1, U2, *A, *B, *C, *D; int PT1, PT2, *WALK, RES[16]; int PTX, PTY, CLK, PTEST, IN; WALK = hs->WALK; PT1 = hs->PT1; PT2 = hs->PT2; PTX = U1 = 0; PTY = U2 = 0; memset( RES, 0, sizeof( RES ) ); while( n < COLLECT_SIZE * 4 ) { ONE_ITERATION ONE_ITERATION ONE_ITERATION ONE_ITERATION } hs->PT1 = PT1; hs->PT2 = PT2; hs->offset[0] = 0; hs->offset[1] = COLLECT_SIZE / 2; } /* * HAVEGE initialization */ void havege_init( havege_state *hs ) { memset( hs, 0, sizeof( havege_state ) ); havege_fill( hs ); } /* * HAVEGE rand function */ int havege_random( void *p_rng, unsigned char *buf, size_t len ) { int val; size_t use_len; havege_state *hs = (havege_state *) p_rng; unsigned char *p = buf; while( len > 0 ) { use_len = len; if( use_len > sizeof(int) ) use_len = sizeof(int); if( hs->offset[1] >= COLLECT_SIZE ) havege_fill( hs ); val = hs->pool[hs->offset[0]++]; val ^= hs->pool[hs->offset[1]++]; memcpy( p, &val, use_len ); len -= use_len; p += use_len; } return( 0 ); } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/rsa.c0000644000014601777760000010005012165464055022224 0ustar00jenkinsnogroup00000000000000/* * The RSA public-key cryptosystem * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * RSA was designed by Ron Rivest, Adi Shamir and Len Adleman. * * http://theory.lcs.mit.edu/~rivest/rsapaper.pdf * http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_RSA_C) #include "polarssl/rsa.h" #include "polarssl/md.h" #include #include /* * Initialize an RSA context */ void rsa_init( rsa_context *ctx, int padding, int hash_id ) { memset( ctx, 0, sizeof( rsa_context ) ); ctx->padding = padding; ctx->hash_id = hash_id; } #if defined(POLARSSL_GENPRIME) /* * Generate an RSA keypair */ int rsa_gen_key( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, unsigned int nbits, int exponent ) { int ret; mpi P1, Q1, H, G; if( f_rng == NULL || nbits < 128 || exponent < 3 ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); mpi_init( &P1 ); mpi_init( &Q1 ); mpi_init( &H ); mpi_init( &G ); /* * find primes P and Q with Q < P so that: * GCD( E, (P-1)*(Q-1) ) == 1 */ MPI_CHK( mpi_lset( &ctx->E, exponent ) ); do { MPI_CHK( mpi_gen_prime( &ctx->P, ( nbits + 1 ) >> 1, 0, f_rng, p_rng ) ); MPI_CHK( mpi_gen_prime( &ctx->Q, ( nbits + 1 ) >> 1, 0, f_rng, p_rng ) ); if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 ) mpi_swap( &ctx->P, &ctx->Q ); if( mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 ) continue; MPI_CHK( mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) ); if( mpi_msb( &ctx->N ) != nbits ) continue; MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) ); MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) ); MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) ); MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) ); } while( mpi_cmp_int( &G, 1 ) != 0 ); /* * D = E^-1 mod ((P-1)*(Q-1)) * DP = D mod (P - 1) * DQ = D mod (Q - 1) * QP = Q^-1 mod P */ MPI_CHK( mpi_inv_mod( &ctx->D , &ctx->E, &H ) ); MPI_CHK( mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) ); MPI_CHK( mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) ); MPI_CHK( mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) ); ctx->len = ( mpi_msb( &ctx->N ) + 7 ) >> 3; cleanup: mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G ); if( ret != 0 ) { rsa_free( ctx ); return( POLARSSL_ERR_RSA_KEY_GEN_FAILED + ret ); } return( 0 ); } #endif /* * Check a public RSA key */ int rsa_check_pubkey( const rsa_context *ctx ) { if( !ctx->N.p || !ctx->E.p ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); if( ( ctx->N.p[0] & 1 ) == 0 || ( ctx->E.p[0] & 1 ) == 0 ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); if( mpi_msb( &ctx->N ) < 128 || mpi_msb( &ctx->N ) > POLARSSL_MPI_MAX_BITS ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); if( mpi_msb( &ctx->E ) < 2 || mpi_msb( &ctx->E ) > 64 ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); return( 0 ); } /* * Check a private RSA key */ int rsa_check_privkey( const rsa_context *ctx ) { int ret; mpi PQ, DE, P1, Q1, H, I, G, G2, L1, L2; if( ( ret = rsa_check_pubkey( ctx ) ) != 0 ) return( ret ); if( !ctx->P.p || !ctx->Q.p || !ctx->D.p ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED ); mpi_init( &PQ ); mpi_init( &DE ); mpi_init( &P1 ); mpi_init( &Q1 ); mpi_init( &H ); mpi_init( &I ); mpi_init( &G ); mpi_init( &G2 ); mpi_init( &L1 ); mpi_init( &L2 ); MPI_CHK( mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) ); MPI_CHK( mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) ); MPI_CHK( mpi_sub_int( &P1, &ctx->P, 1 ) ); MPI_CHK( mpi_sub_int( &Q1, &ctx->Q, 1 ) ); MPI_CHK( mpi_mul_mpi( &H, &P1, &Q1 ) ); MPI_CHK( mpi_gcd( &G, &ctx->E, &H ) ); MPI_CHK( mpi_gcd( &G2, &P1, &Q1 ) ); MPI_CHK( mpi_div_mpi( &L1, &L2, &H, &G2 ) ); MPI_CHK( mpi_mod_mpi( &I, &DE, &L1 ) ); /* * Check for a valid PKCS1v2 private key */ if( mpi_cmp_mpi( &PQ, &ctx->N ) != 0 || mpi_cmp_int( &L2, 0 ) != 0 || mpi_cmp_int( &I, 1 ) != 0 || mpi_cmp_int( &G, 1 ) != 0 ) { ret = POLARSSL_ERR_RSA_KEY_CHECK_FAILED; } cleanup: mpi_free( &PQ ); mpi_free( &DE ); mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &I ); mpi_free( &G ); mpi_free( &G2 ); mpi_free( &L1 ); mpi_free( &L2 ); if( ret == POLARSSL_ERR_RSA_KEY_CHECK_FAILED ) return( ret ); if( ret != 0 ) return( POLARSSL_ERR_RSA_KEY_CHECK_FAILED + ret ); return( 0 ); } /* * Do an RSA public key operation */ int rsa_public( rsa_context *ctx, const unsigned char *input, unsigned char *output ) { int ret; size_t olen; mpi T; mpi_init( &T ); MPI_CHK( mpi_read_binary( &T, input, ctx->len ) ); if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 ) { mpi_free( &T ); return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } olen = ctx->len; MPI_CHK( mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) ); MPI_CHK( mpi_write_binary( &T, output, olen ) ); cleanup: mpi_free( &T ); if( ret != 0 ) return( POLARSSL_ERR_RSA_PUBLIC_FAILED + ret ); return( 0 ); } /* * Do an RSA private key operation */ int rsa_private( rsa_context *ctx, const unsigned char *input, unsigned char *output ) { int ret; size_t olen; mpi T, T1, T2; mpi_init( &T ); mpi_init( &T1 ); mpi_init( &T2 ); MPI_CHK( mpi_read_binary( &T, input, ctx->len ) ); if( mpi_cmp_mpi( &T, &ctx->N ) >= 0 ) { mpi_free( &T ); return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } #if defined(POLARSSL_RSA_NO_CRT) MPI_CHK( mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) ); #else /* * faster decryption using the CRT * * T1 = input ^ dP mod P * T2 = input ^ dQ mod Q */ MPI_CHK( mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) ); MPI_CHK( mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) ); /* * T = (T1 - T2) * (Q^-1 mod P) mod P */ MPI_CHK( mpi_sub_mpi( &T, &T1, &T2 ) ); MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->QP ) ); MPI_CHK( mpi_mod_mpi( &T, &T1, &ctx->P ) ); /* * output = T2 + T * Q */ MPI_CHK( mpi_mul_mpi( &T1, &T, &ctx->Q ) ); MPI_CHK( mpi_add_mpi( &T, &T2, &T1 ) ); #endif olen = ctx->len; MPI_CHK( mpi_write_binary( &T, output, olen ) ); cleanup: mpi_free( &T ); mpi_free( &T1 ); mpi_free( &T2 ); if( ret != 0 ) return( POLARSSL_ERR_RSA_PRIVATE_FAILED + ret ); return( 0 ); } #if defined(POLARSSL_PKCS1_V21) /** * Generate and apply the MGF1 operation (from PKCS#1 v2.1) to a buffer. * * \param dst buffer to mask * \param dlen length of destination buffer * \param src source of the mask generation * \param slen length of the source buffer * \param md_ctx message digest context to use */ static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src, size_t slen, md_context_t *md_ctx ) { unsigned char mask[POLARSSL_MD_MAX_SIZE]; unsigned char counter[4]; unsigned char *p; unsigned int hlen; size_t i, use_len; memset( mask, 0, POLARSSL_MD_MAX_SIZE ); memset( counter, 0, 4 ); hlen = md_ctx->md_info->size; // Generate and apply dbMask // p = dst; while( dlen > 0 ) { use_len = hlen; if( dlen < hlen ) use_len = dlen; md_starts( md_ctx ); md_update( md_ctx, src, slen ); md_update( md_ctx, counter, 4 ); md_finish( md_ctx, mask ); for( i = 0; i < use_len; ++i ) *p++ ^= mask[i]; counter[3]++; dlen -= use_len; } } #endif /* * Add the message padding, then do an RSA operation */ int rsa_pkcs1_encrypt( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output ) { size_t nb_pad, olen; int ret; unsigned char *p = output; #if defined(POLARSSL_PKCS1_V21) unsigned int hlen; const md_info_t *md_info; md_context_t md_ctx; #endif olen = ctx->len; if( f_rng == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); switch( ctx->padding ) { case RSA_PKCS_V15: if( olen < ilen + 11 ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); nb_pad = olen - 3 - ilen; *p++ = 0; *p++ = RSA_CRYPT; while( nb_pad-- > 0 ) { int rng_dl = 100; do { ret = f_rng( p_rng, p, 1 ); } while( *p == 0 && --rng_dl && ret == 0 ); // Check if RNG failed to generate data // if( rng_dl == 0 || ret != 0) return POLARSSL_ERR_RSA_RNG_FAILED + ret; p++; } *p++ = 0; memcpy( p, input, ilen ); break; #if defined(POLARSSL_PKCS1_V21) case RSA_PKCS_V21: md_info = md_info_from_type( ctx->hash_id ); if( md_info == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); hlen = md_get_size( md_info ); if( olen < ilen + 2 * hlen + 2 || f_rng == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); memset( output, 0, olen ); memset( &md_ctx, 0, sizeof( md_context_t ) ); md_init_ctx( &md_ctx, md_info ); *p++ = 0; // Generate a random octet string seed // if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 ) return( POLARSSL_ERR_RSA_RNG_FAILED + ret ); p += hlen; // Construct DB // md( md_info, p, 0, p ); p += hlen; p += olen - 2 * hlen - 2 - ilen; *p++ = 1; memcpy( p, input, ilen ); // maskedDB: Apply dbMask to DB // mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen, &md_ctx ); // maskedSeed: Apply seedMask to seed // mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1, &md_ctx ); break; #endif default: return( POLARSSL_ERR_RSA_INVALID_PADDING ); } return( ( mode == RSA_PUBLIC ) ? rsa_public( ctx, output, output ) : rsa_private( ctx, output, output ) ); } /* * Do an RSA operation, then remove the message padding */ int rsa_pkcs1_decrypt( rsa_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len) { int ret; size_t ilen; unsigned char *p; unsigned char buf[1024]; #if defined(POLARSSL_PKCS1_V21) unsigned char lhash[POLARSSL_MD_MAX_SIZE]; unsigned int hlen; const md_info_t *md_info; md_context_t md_ctx; #endif ilen = ctx->len; if( ilen < 16 || ilen > sizeof( buf ) ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); ret = ( mode == RSA_PUBLIC ) ? rsa_public( ctx, input, buf ) : rsa_private( ctx, input, buf ); if( ret != 0 ) return( ret ); p = buf; switch( ctx->padding ) { case RSA_PKCS_V15: if( *p++ != 0 || *p++ != RSA_CRYPT ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); while( *p != 0 ) { if( p >= buf + ilen - 1 ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); p++; } p++; break; #if defined(POLARSSL_PKCS1_V21) case RSA_PKCS_V21: if( *p++ != 0 ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); md_info = md_info_from_type( ctx->hash_id ); if( md_info == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); hlen = md_get_size( md_info ); memset( &md_ctx, 0, sizeof( md_context_t ) ); md_init_ctx( &md_ctx, md_info ); // Generate lHash // md( md_info, lhash, 0, lhash ); // seed: Apply seedMask to maskedSeed // mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1, &md_ctx ); // DB: Apply dbMask to maskedDB // mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen, &md_ctx ); p += hlen; // Check validity // if( memcmp( lhash, p, hlen ) != 0 ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); p += hlen; while( *p == 0 && p < buf + ilen ) p++; if( p == buf + ilen ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); if( *p++ != 0x01 ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); break; #endif default: return( POLARSSL_ERR_RSA_INVALID_PADDING ); } if (ilen - (p - buf) > output_max_len) return( POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE ); *olen = ilen - (p - buf); memcpy( output, p, *olen ); return( 0 ); } /* * Do an RSA operation to sign the message digest */ int rsa_pkcs1_sign( rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ) { size_t nb_pad, olen; unsigned char *p = sig; #if defined(POLARSSL_PKCS1_V21) unsigned char salt[POLARSSL_MD_MAX_SIZE]; unsigned int slen, hlen, offset = 0; int ret; size_t msb; const md_info_t *md_info; md_context_t md_ctx; #else (void) f_rng; (void) p_rng; #endif olen = ctx->len; switch( ctx->padding ) { case RSA_PKCS_V15: switch( hash_id ) { case SIG_RSA_RAW: nb_pad = olen - 3 - hashlen; break; case SIG_RSA_MD2: case SIG_RSA_MD4: case SIG_RSA_MD5: nb_pad = olen - 3 - 34; break; case SIG_RSA_SHA1: nb_pad = olen - 3 - 35; break; case SIG_RSA_SHA224: nb_pad = olen - 3 - 47; break; case SIG_RSA_SHA256: nb_pad = olen - 3 - 51; break; case SIG_RSA_SHA384: nb_pad = olen - 3 - 67; break; case SIG_RSA_SHA512: nb_pad = olen - 3 - 83; break; default: return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } if( nb_pad < 8 ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); *p++ = 0; *p++ = RSA_SIGN; memset( p, 0xFF, nb_pad ); p += nb_pad; *p++ = 0; switch( hash_id ) { case SIG_RSA_RAW: memcpy( p, hash, hashlen ); break; case SIG_RSA_MD2: memcpy( p, ASN1_HASH_MDX, 18 ); memcpy( p + 18, hash, 16 ); p[13] = 2; break; case SIG_RSA_MD4: memcpy( p, ASN1_HASH_MDX, 18 ); memcpy( p + 18, hash, 16 ); p[13] = 4; break; case SIG_RSA_MD5: memcpy( p, ASN1_HASH_MDX, 18 ); memcpy( p + 18, hash, 16 ); p[13] = 5; break; case SIG_RSA_SHA1: memcpy( p, ASN1_HASH_SHA1, 15 ); memcpy( p + 15, hash, 20 ); break; case SIG_RSA_SHA224: memcpy( p, ASN1_HASH_SHA2X, 19 ); memcpy( p + 19, hash, 28 ); p[1] += 28; p[14] = 4; p[18] += 28; break; case SIG_RSA_SHA256: memcpy( p, ASN1_HASH_SHA2X, 19 ); memcpy( p + 19, hash, 32 ); p[1] += 32; p[14] = 1; p[18] += 32; break; case SIG_RSA_SHA384: memcpy( p, ASN1_HASH_SHA2X, 19 ); memcpy( p + 19, hash, 48 ); p[1] += 48; p[14] = 2; p[18] += 48; break; case SIG_RSA_SHA512: memcpy( p, ASN1_HASH_SHA2X, 19 ); memcpy( p + 19, hash, 64 ); p[1] += 64; p[14] = 3; p[18] += 64; break; default: return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } break; #if defined(POLARSSL_PKCS1_V21) case RSA_PKCS_V21: if( f_rng == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); switch( hash_id ) { case SIG_RSA_MD2: case SIG_RSA_MD4: case SIG_RSA_MD5: hashlen = 16; break; case SIG_RSA_SHA1: hashlen = 20; break; case SIG_RSA_SHA224: hashlen = 28; break; case SIG_RSA_SHA256: hashlen = 32; break; case SIG_RSA_SHA384: hashlen = 48; break; case SIG_RSA_SHA512: hashlen = 64; break; default: return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } md_info = md_info_from_type( ctx->hash_id ); if( md_info == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); hlen = md_get_size( md_info ); slen = hlen; memset( sig, 0, olen ); memset( &md_ctx, 0, sizeof( md_context_t ) ); md_init_ctx( &md_ctx, md_info ); msb = mpi_msb( &ctx->N ) - 1; // Generate salt of length slen // if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 ) return( POLARSSL_ERR_RSA_RNG_FAILED + ret ); // Note: EMSA-PSS encoding is over the length of N - 1 bits // msb = mpi_msb( &ctx->N ) - 1; p += olen - hlen * 2 - 2; *p++ = 0x01; memcpy( p, salt, slen ); p += slen; // Generate H = Hash( M' ) // md_starts( &md_ctx ); md_update( &md_ctx, p, 8 ); md_update( &md_ctx, hash, hashlen ); md_update( &md_ctx, salt, slen ); md_finish( &md_ctx, p ); // Compensate for boundary condition when applying mask // if( msb % 8 == 0 ) offset = 1; // maskedDB: Apply dbMask to DB // mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx ); msb = mpi_msb( &ctx->N ) - 1; sig[0] &= 0xFF >> ( olen * 8 - msb ); p += hlen; *p++ = 0xBC; break; #endif default: return( POLARSSL_ERR_RSA_INVALID_PADDING ); } return( ( mode == RSA_PUBLIC ) ? rsa_public( ctx, sig, sig ) : rsa_private( ctx, sig, sig ) ); } /* * Do an RSA operation and check the message digest */ int rsa_pkcs1_verify( rsa_context *ctx, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ) { int ret; size_t len, siglen; unsigned char *p, c; unsigned char buf[1024]; #if defined(POLARSSL_PKCS1_V21) unsigned char result[POLARSSL_MD_MAX_SIZE]; unsigned char zeros[8]; unsigned int hlen; size_t slen, msb; const md_info_t *md_info; md_context_t md_ctx; #endif siglen = ctx->len; if( siglen < 16 || siglen > sizeof( buf ) ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); ret = ( mode == RSA_PUBLIC ) ? rsa_public( ctx, sig, buf ) : rsa_private( ctx, sig, buf ); if( ret != 0 ) return( ret ); p = buf; switch( ctx->padding ) { case RSA_PKCS_V15: if( *p++ != 0 || *p++ != RSA_SIGN ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); while( *p != 0 ) { if( p >= buf + siglen - 1 || *p != 0xFF ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); p++; } p++; len = siglen - ( p - buf ); if( len == 34 ) { c = p[13]; p[13] = 0; if( memcmp( p, ASN1_HASH_MDX, 18 ) != 0 ) return( POLARSSL_ERR_RSA_VERIFY_FAILED ); if( ( c == 2 && hash_id == SIG_RSA_MD2 ) || ( c == 4 && hash_id == SIG_RSA_MD4 ) || ( c == 5 && hash_id == SIG_RSA_MD5 ) ) { if( memcmp( p + 18, hash, 16 ) == 0 ) return( 0 ); else return( POLARSSL_ERR_RSA_VERIFY_FAILED ); } } if( len == 35 && hash_id == SIG_RSA_SHA1 ) { if( memcmp( p, ASN1_HASH_SHA1, 15 ) == 0 && memcmp( p + 15, hash, 20 ) == 0 ) return( 0 ); else return( POLARSSL_ERR_RSA_VERIFY_FAILED ); } if( ( len == 19 + 28 && p[14] == 4 && hash_id == SIG_RSA_SHA224 ) || ( len == 19 + 32 && p[14] == 1 && hash_id == SIG_RSA_SHA256 ) || ( len == 19 + 48 && p[14] == 2 && hash_id == SIG_RSA_SHA384 ) || ( len == 19 + 64 && p[14] == 3 && hash_id == SIG_RSA_SHA512 ) ) { c = p[1] - 17; p[1] = 17; p[14] = 0; if( p[18] == c && memcmp( p, ASN1_HASH_SHA2X, 18 ) == 0 && memcmp( p + 19, hash, c ) == 0 ) return( 0 ); else return( POLARSSL_ERR_RSA_VERIFY_FAILED ); } if( len == hashlen && hash_id == SIG_RSA_RAW ) { if( memcmp( p, hash, hashlen ) == 0 ) return( 0 ); else return( POLARSSL_ERR_RSA_VERIFY_FAILED ); } break; #if defined(POLARSSL_PKCS1_V21) case RSA_PKCS_V21: if( buf[siglen - 1] != 0xBC ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); switch( hash_id ) { case SIG_RSA_MD2: case SIG_RSA_MD4: case SIG_RSA_MD5: hashlen = 16; break; case SIG_RSA_SHA1: hashlen = 20; break; case SIG_RSA_SHA224: hashlen = 28; break; case SIG_RSA_SHA256: hashlen = 32; break; case SIG_RSA_SHA384: hashlen = 48; break; case SIG_RSA_SHA512: hashlen = 64; break; default: return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); } md_info = md_info_from_type( ctx->hash_id ); if( md_info == NULL ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); hlen = md_get_size( md_info ); slen = siglen - hlen - 1; memset( &md_ctx, 0, sizeof( md_context_t ) ); memset( zeros, 0, 8 ); md_init_ctx( &md_ctx, md_info ); // Note: EMSA-PSS verification is over the length of N - 1 bits // msb = mpi_msb( &ctx->N ) - 1; // Compensate for boundary condition when applying mask // if( msb % 8 == 0 ) { p++; siglen -= 1; } if( buf[0] >> ( 8 - siglen * 8 + msb ) ) return( POLARSSL_ERR_RSA_BAD_INPUT_DATA ); mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx ); buf[0] &= 0xFF >> ( siglen * 8 - msb ); while( *p == 0 && p < buf + siglen ) p++; if( p == buf + siglen ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); if( *p++ != 0x01 ) return( POLARSSL_ERR_RSA_INVALID_PADDING ); slen -= p - buf; // Generate H = Hash( M' ) // md_starts( &md_ctx ); md_update( &md_ctx, zeros, 8 ); md_update( &md_ctx, hash, hashlen ); md_update( &md_ctx, p, slen ); md_finish( &md_ctx, result ); if( memcmp( p + slen, result, hlen ) == 0 ) return( 0 ); else return( POLARSSL_ERR_RSA_VERIFY_FAILED ); #endif default: return( POLARSSL_ERR_RSA_INVALID_PADDING ); } return( POLARSSL_ERR_RSA_INVALID_PADDING ); } /* * Free the components of an RSA key */ void rsa_free( rsa_context *ctx ) { mpi_free( &ctx->RQ ); mpi_free( &ctx->RP ); mpi_free( &ctx->RN ); mpi_free( &ctx->QP ); mpi_free( &ctx->DQ ); mpi_free( &ctx->DP ); mpi_free( &ctx->Q ); mpi_free( &ctx->P ); mpi_free( &ctx->D ); mpi_free( &ctx->E ); mpi_free( &ctx->N ); } #if defined(POLARSSL_SELF_TEST) #include "polarssl/sha1.h" /* * Example RSA-1024 keypair, for test purposes */ #define KEY_LEN 128 #define RSA_N "9292758453063D803DD603D5E777D788" \ "8ED1D5BF35786190FA2F23EBC0848AEA" \ "DDA92CA6C3D80B32C4D109BE0F36D6AE" \ "7130B9CED7ACDF54CFC7555AC14EEBAB" \ "93A89813FBF3C4F8066D2D800F7C38A8" \ "1AE31942917403FF4946B0A83D3D3E05" \ "EE57C6F5F5606FB5D4BC6CD34EE0801A" \ "5E94BB77B07507233A0BC7BAC8F90F79" #define RSA_E "10001" #define RSA_D "24BF6185468786FDD303083D25E64EFC" \ "66CA472BC44D253102F8B4A9D3BFA750" \ "91386C0077937FE33FA3252D28855837" \ "AE1B484A8A9A45F7EE8C0C634F99E8CD" \ "DF79C5CE07EE72C7F123142198164234" \ "CABB724CF78B8173B9F880FC86322407" \ "AF1FEDFDDE2BEB674CA15F3E81A1521E" \ "071513A1E85B5DFA031F21ECAE91A34D" #define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \ "2C01CAD19EA484A87EA4377637E75500" \ "FCB2005C5C7DD6EC4AC023CDA285D796" \ "C3D9E75E1EFC42488BB4F1D13AC30A57" #define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \ "E211C2B9E5DB1ED0BF61D0D9899620F4" \ "910E4168387E3C30AA1E00C339A79508" \ "8452DD96A9A5EA5D9DCA68DA636032AF" #define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \ "3C94D22288ACD763FD8E5600ED4A702D" \ "F84198A5F06C2E72236AE490C93F07F8" \ "3CC559CD27BC2D1CA488811730BB5725" #define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \ "D8AAEA56749EA28623272E4F7D0592AF" \ "7C1F1313CAC9471B5C523BFE592F517B" \ "407A1BD76C164B93DA2D32A383E58357" #define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \ "F38D18D2B2F0E2DD275AA977E2BF4411" \ "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \ "A74206CEC169D74BF5A8C50D6F48EA08" #define PT_LEN 24 #define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \ "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD" static int myrand( void *rng_state, unsigned char *output, size_t len ) { size_t i; if( rng_state != NULL ) rng_state = NULL; for( i = 0; i < len; ++i ) output[i] = rand(); return( 0 ); } /* * Checkup routine */ int rsa_self_test( int verbose ) { size_t len; rsa_context rsa; unsigned char rsa_plaintext[PT_LEN]; unsigned char rsa_decrypted[PT_LEN]; unsigned char rsa_ciphertext[KEY_LEN]; #if defined(POLARSSL_SHA1_C) unsigned char sha1sum[20]; #endif rsa_init( &rsa, RSA_PKCS_V15, 0 ); rsa.len = KEY_LEN; mpi_read_string( &rsa.N , 16, RSA_N ); mpi_read_string( &rsa.E , 16, RSA_E ); mpi_read_string( &rsa.D , 16, RSA_D ); mpi_read_string( &rsa.P , 16, RSA_P ); mpi_read_string( &rsa.Q , 16, RSA_Q ); mpi_read_string( &rsa.DP, 16, RSA_DP ); mpi_read_string( &rsa.DQ, 16, RSA_DQ ); mpi_read_string( &rsa.QP, 16, RSA_QP ); if( verbose != 0 ) printf( " RSA key validation: " ); if( rsa_check_pubkey( &rsa ) != 0 || rsa_check_privkey( &rsa ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n PKCS#1 encryption : " ); memcpy( rsa_plaintext, RSA_PT, PT_LEN ); if( rsa_pkcs1_encrypt( &rsa, &myrand, NULL, RSA_PUBLIC, PT_LEN, rsa_plaintext, rsa_ciphertext ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n PKCS#1 decryption : " ); if( rsa_pkcs1_decrypt( &rsa, RSA_PRIVATE, &len, rsa_ciphertext, rsa_decrypted, sizeof(rsa_decrypted) ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } #if defined(POLARSSL_SHA1_C) if( verbose != 0 ) printf( "passed\n PKCS#1 data sign : " ); sha1( rsa_plaintext, PT_LEN, sha1sum ); if( rsa_pkcs1_sign( &rsa, NULL, NULL, RSA_PRIVATE, SIG_RSA_SHA1, 20, sha1sum, rsa_ciphertext ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n PKCS#1 sig. verify: " ); if( rsa_pkcs1_verify( &rsa, RSA_PUBLIC, SIG_RSA_SHA1, 20, sha1sum, rsa_ciphertext ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n\n" ); #endif /* POLARSSL_SHA1_C */ rsa_free( &rsa ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/base64.c0000644000014601777760000001475112165464055022537 0ustar00jenkinsnogroup00000000000000/* * RFC 1521 base64 encoding/decoding * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_BASE64_C) #include "polarssl/base64.h" static const unsigned char base64_enc_map[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; static const unsigned char base64_dec_map[128] = { 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, 127, 64, 127, 127, 127, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 127, 127, 127, 127, 127 }; /* * Encode a buffer into base64 format */ int base64_encode( unsigned char *dst, size_t *dlen, const unsigned char *src, size_t slen ) { size_t i, n; int C1, C2, C3; unsigned char *p; if( slen == 0 ) return( 0 ); n = (slen << 3) / 6; switch( (slen << 3) - (n * 6) ) { case 2: n += 3; break; case 4: n += 2; break; default: break; } if( *dlen < n + 1 ) { *dlen = n + 1; return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL ); } n = (slen / 3) * 3; for( i = 0, p = dst; i < n; i += 3 ) { C1 = *src++; C2 = *src++; C3 = *src++; *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F]; *p++ = base64_enc_map[C3 & 0x3F]; } if( i < slen ) { C1 = *src++; C2 = ((i + 1) < slen) ? *src++ : 0; *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; if( (i + 1) < slen ) *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F]; else *p++ = '='; *p++ = '='; } *dlen = p - dst; *p = 0; return( 0 ); } /* * Decode a base64-formatted buffer */ int base64_decode( unsigned char *dst, size_t *dlen, const unsigned char *src, size_t slen ) { size_t i, j, n; unsigned long x; unsigned char *p; for( i = j = n = 0; i < slen; i++ ) { if( ( slen - i ) >= 2 && src[i] == '\r' && src[i + 1] == '\n' ) continue; if( src[i] == '\n' ) continue; if( src[i] == '=' && ++j > 2 ) return( POLARSSL_ERR_BASE64_INVALID_CHARACTER ); if( src[i] > 127 || base64_dec_map[src[i]] == 127 ) return( POLARSSL_ERR_BASE64_INVALID_CHARACTER ); if( base64_dec_map[src[i]] < 64 && j != 0 ) return( POLARSSL_ERR_BASE64_INVALID_CHARACTER ); n++; } if( n == 0 ) return( 0 ); n = ((n * 6) + 7) >> 3; if( *dlen < n ) { *dlen = n; return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL ); } for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ ) { if( *src == '\r' || *src == '\n' ) continue; j -= ( base64_dec_map[*src] == 64 ); x = (x << 6) | ( base64_dec_map[*src] & 0x3F ); if( ++n == 4 ) { n = 0; if( j > 0 ) *p++ = (unsigned char)( x >> 16 ); if( j > 1 ) *p++ = (unsigned char)( x >> 8 ); if( j > 2 ) *p++ = (unsigned char)( x ); } } *dlen = p - dst; return( 0 ); } #if defined(POLARSSL_SELF_TEST) #include #include static const unsigned char base64_test_dec[64] = { 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD, 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01, 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09, 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13, 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31, 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38, 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B, 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97 }; static const unsigned char base64_test_enc[] = "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK" "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw=="; /* * Checkup routine */ int base64_self_test( int verbose ) { size_t len; unsigned char *src, buffer[128]; if( verbose != 0 ) printf( " Base64 encoding test: " ); len = sizeof( buffer ); src = (unsigned char *) base64_test_dec; if( base64_encode( buffer, &len, src, 64 ) != 0 || memcmp( base64_test_enc, buffer, 88 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n Base64 decoding test: " ); len = sizeof( buffer ); src = (unsigned char *) base64_test_enc; if( base64_decode( buffer, &len, src, 88 ) != 0 || memcmp( base64_test_dec, buffer, 64 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/md_wrap.c0000644000014601777760000003625412165464055023106 0ustar00jenkinsnogroup00000000000000/** * \file md_wrap.c * \brief Generic message digest wrapper for PolarSSL * * \author Adriaan de Jong * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_MD_C) #include "polarssl/md_wrap.h" #include "polarssl/md2.h" #include "polarssl/md4.h" #include "polarssl/md5.h" #include "polarssl/sha1.h" #include "polarssl/sha2.h" #include "polarssl/sha4.h" #include #if defined(POLARSSL_MD2_C) static void md2_starts_wrap( void *ctx ) { md2_starts( (md2_context *) ctx ); } static void md2_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md2_update( (md2_context *) ctx, input, ilen ); } static void md2_finish_wrap( void *ctx, unsigned char *output ) { md2_finish( (md2_context *) ctx, output ); } int md2_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return md2_file( path, output ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { md2_hmac_starts( (md2_context *) ctx, key, keylen ); } static void md2_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md2_hmac_update( (md2_context *) ctx, input, ilen ); } static void md2_hmac_finish_wrap( void *ctx, unsigned char *output ) { md2_hmac_finish( (md2_context *) ctx, output ); } static void md2_hmac_reset_wrap( void *ctx ) { md2_hmac_reset( (md2_context *) ctx ); } static void * md2_ctx_alloc( void ) { return malloc( sizeof( md2_context ) ); } static void md2_ctx_free( void *ctx ) { free( ctx ); } const md_info_t md2_info = { POLARSSL_MD_MD2, "MD2", 16, md2_starts_wrap, md2_update_wrap, md2_finish_wrap, md2, md2_file_wrap, md2_hmac_starts_wrap, md2_hmac_update_wrap, md2_hmac_finish_wrap, md2_hmac_reset_wrap, md2_hmac, md2_ctx_alloc, md2_ctx_free, }; #endif #if defined(POLARSSL_MD4_C) void md4_starts_wrap( void *ctx ) { md4_starts( (md4_context *) ctx ); } void md4_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md4_update( (md4_context *) ctx, input, ilen ); } void md4_finish_wrap( void *ctx, unsigned char *output ) { md4_finish( (md4_context *) ctx, output ); } int md4_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return md4_file( path, output ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void md4_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { md4_hmac_starts( (md4_context *) ctx, key, keylen ); } void md4_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md4_hmac_update( (md4_context *) ctx, input, ilen ); } void md4_hmac_finish_wrap( void *ctx, unsigned char *output ) { md4_hmac_finish( (md4_context *) ctx, output ); } void md4_hmac_reset_wrap( void *ctx ) { md4_hmac_reset( (md4_context *) ctx ); } void *md4_ctx_alloc( void ) { return malloc( sizeof( md4_context ) ); } void md4_ctx_free( void *ctx ) { free( ctx ); } const md_info_t md4_info = { POLARSSL_MD_MD4, "MD4", 16, md4_starts_wrap, md4_update_wrap, md4_finish_wrap, md4, md4_file_wrap, md4_hmac_starts_wrap, md4_hmac_update_wrap, md4_hmac_finish_wrap, md4_hmac_reset_wrap, md4_hmac, md4_ctx_alloc, md4_ctx_free, }; #endif #if defined(POLARSSL_MD5_C) static void md5_starts_wrap( void *ctx ) { md5_starts( (md5_context *) ctx ); } static void md5_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md5_update( (md5_context *) ctx, input, ilen ); } static void md5_finish_wrap( void *ctx, unsigned char *output ) { md5_finish( (md5_context *) ctx, output ); } int md5_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return md5_file( path, output ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { md5_hmac_starts( (md5_context *) ctx, key, keylen ); } static void md5_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { md5_hmac_update( (md5_context *) ctx, input, ilen ); } static void md5_hmac_finish_wrap( void *ctx, unsigned char *output ) { md5_hmac_finish( (md5_context *) ctx, output ); } static void md5_hmac_reset_wrap( void *ctx ) { md5_hmac_reset( (md5_context *) ctx ); } static void * md5_ctx_alloc( void ) { return malloc( sizeof( md5_context ) ); } static void md5_ctx_free( void *ctx ) { free( ctx ); } const md_info_t md5_info = { POLARSSL_MD_MD5, "MD5", 16, md5_starts_wrap, md5_update_wrap, md5_finish_wrap, md5, md5_file_wrap, md5_hmac_starts_wrap, md5_hmac_update_wrap, md5_hmac_finish_wrap, md5_hmac_reset_wrap, md5_hmac, md5_ctx_alloc, md5_ctx_free, }; #endif #if defined(POLARSSL_SHA1_C) void sha1_starts_wrap( void *ctx ) { sha1_starts( (sha1_context *) ctx ); } void sha1_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha1_update( (sha1_context *) ctx, input, ilen ); } void sha1_finish_wrap( void *ctx, unsigned char *output ) { sha1_finish( (sha1_context *) ctx, output ); } int sha1_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return sha1_file( path, output ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { sha1_hmac_starts( (sha1_context *) ctx, key, keylen ); } void sha1_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha1_hmac_update( (sha1_context *) ctx, input, ilen ); } void sha1_hmac_finish_wrap( void *ctx, unsigned char *output ) { sha1_hmac_finish( (sha1_context *) ctx, output ); } void sha1_hmac_reset_wrap( void *ctx ) { sha1_hmac_reset( (sha1_context *) ctx ); } void * sha1_ctx_alloc( void ) { return malloc( sizeof( sha1_context ) ); } void sha1_ctx_free( void *ctx ) { free( ctx ); } const md_info_t sha1_info = { POLARSSL_MD_SHA1, "SHA1", 20, sha1_starts_wrap, sha1_update_wrap, sha1_finish_wrap, sha1, sha1_file_wrap, sha1_hmac_starts_wrap, sha1_hmac_update_wrap, sha1_hmac_finish_wrap, sha1_hmac_reset_wrap, sha1_hmac, sha1_ctx_alloc, sha1_ctx_free, }; #endif /* * Wrappers for generic message digests */ #if defined(POLARSSL_SHA2_C) void sha224_starts_wrap( void *ctx ) { sha2_starts( (sha2_context *) ctx, 1 ); } void sha224_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha2_update( (sha2_context *) ctx, input, ilen ); } void sha224_finish_wrap( void *ctx, unsigned char *output ) { sha2_finish( (sha2_context *) ctx, output ); } void sha224_wrap( const unsigned char *input, size_t ilen, unsigned char *output ) { sha2( input, ilen, output, 1 ); } int sha224_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return sha2_file( path, output, 1 ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { sha2_hmac_starts( (sha2_context *) ctx, key, keylen, 1 ); } void sha224_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha2_hmac_update( (sha2_context *) ctx, input, ilen ); } void sha224_hmac_finish_wrap( void *ctx, unsigned char *output ) { sha2_hmac_finish( (sha2_context *) ctx, output ); } void sha224_hmac_reset_wrap( void *ctx ) { sha2_hmac_reset( (sha2_context *) ctx ); } void sha224_hmac_wrap( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ) { sha2_hmac( key, keylen, input, ilen, output, 1 ); } void * sha224_ctx_alloc( void ) { return malloc( sizeof( sha2_context ) ); } void sha224_ctx_free( void *ctx ) { free( ctx ); } const md_info_t sha224_info = { POLARSSL_MD_SHA224, "SHA224", 28, sha224_starts_wrap, sha224_update_wrap, sha224_finish_wrap, sha224_wrap, sha224_file_wrap, sha224_hmac_starts_wrap, sha224_hmac_update_wrap, sha224_hmac_finish_wrap, sha224_hmac_reset_wrap, sha224_hmac_wrap, sha224_ctx_alloc, sha224_ctx_free, }; void sha256_starts_wrap( void *ctx ) { sha2_starts( (sha2_context *) ctx, 0 ); } void sha256_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha2_update( (sha2_context *) ctx, input, ilen ); } void sha256_finish_wrap( void *ctx, unsigned char *output ) { sha2_finish( (sha2_context *) ctx, output ); } void sha256_wrap( const unsigned char *input, size_t ilen, unsigned char *output ) { sha2( input, ilen, output, 0 ); } int sha256_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return sha2_file( path, output, 0 ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { sha2_hmac_starts( (sha2_context *) ctx, key, keylen, 0 ); } void sha256_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha2_hmac_update( (sha2_context *) ctx, input, ilen ); } void sha256_hmac_finish_wrap( void *ctx, unsigned char *output ) { sha2_hmac_finish( (sha2_context *) ctx, output ); } void sha256_hmac_reset_wrap( void *ctx ) { sha2_hmac_reset( (sha2_context *) ctx ); } void sha256_hmac_wrap( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ) { sha2_hmac( key, keylen, input, ilen, output, 0 ); } void * sha256_ctx_alloc( void ) { return malloc( sizeof( sha2_context ) ); } void sha256_ctx_free( void *ctx ) { free( ctx ); } const md_info_t sha256_info = { POLARSSL_MD_SHA256, "SHA256", 32, sha256_starts_wrap, sha256_update_wrap, sha256_finish_wrap, sha256_wrap, sha256_file_wrap, sha256_hmac_starts_wrap, sha256_hmac_update_wrap, sha256_hmac_finish_wrap, sha256_hmac_reset_wrap, sha256_hmac_wrap, sha256_ctx_alloc, sha256_ctx_free, }; #endif #if defined(POLARSSL_SHA4_C) void sha384_starts_wrap( void *ctx ) { sha4_starts( (sha4_context *) ctx, 1 ); } void sha384_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha4_update( (sha4_context *) ctx, input, ilen ); } void sha384_finish_wrap( void *ctx, unsigned char *output ) { sha4_finish( (sha4_context *) ctx, output ); } void sha384_wrap( const unsigned char *input, size_t ilen, unsigned char *output ) { sha4( input, ilen, output, 1 ); } int sha384_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return sha4_file( path, output, 1 ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { sha4_hmac_starts( (sha4_context *) ctx, key, keylen, 1 ); } void sha384_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha4_hmac_update( (sha4_context *) ctx, input, ilen ); } void sha384_hmac_finish_wrap( void *ctx, unsigned char *output ) { sha4_hmac_finish( (sha4_context *) ctx, output ); } void sha384_hmac_reset_wrap( void *ctx ) { sha4_hmac_reset( (sha4_context *) ctx ); } void sha384_hmac_wrap( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ) { sha4_hmac( key, keylen, input, ilen, output, 1 ); } void * sha384_ctx_alloc( void ) { return malloc( sizeof( sha4_context ) ); } void sha384_ctx_free( void *ctx ) { free( ctx ); } const md_info_t sha384_info = { POLARSSL_MD_SHA384, "SHA384", 48, sha384_starts_wrap, sha384_update_wrap, sha384_finish_wrap, sha384_wrap, sha384_file_wrap, sha384_hmac_starts_wrap, sha384_hmac_update_wrap, sha384_hmac_finish_wrap, sha384_hmac_reset_wrap, sha384_hmac_wrap, sha384_ctx_alloc, sha384_ctx_free, }; void sha512_starts_wrap( void *ctx ) { sha4_starts( (sha4_context *) ctx, 0 ); } void sha512_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha4_update( (sha4_context *) ctx, input, ilen ); } void sha512_finish_wrap( void *ctx, unsigned char *output ) { sha4_finish( (sha4_context *) ctx, output ); } void sha512_wrap( const unsigned char *input, size_t ilen, unsigned char *output ) { sha4( input, ilen, output, 0 ); } int sha512_file_wrap( const char *path, unsigned char *output ) { #if defined(POLARSSL_FS_IO) return sha4_file( path, output, 0 ); #else ((void) path); ((void) output); return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE; #endif } void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) { sha4_hmac_starts( (sha4_context *) ctx, key, keylen, 0 ); } void sha512_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) { sha4_hmac_update( (sha4_context *) ctx, input, ilen ); } void sha512_hmac_finish_wrap( void *ctx, unsigned char *output ) { sha4_hmac_finish( (sha4_context *) ctx, output ); } void sha512_hmac_reset_wrap( void *ctx ) { sha4_hmac_reset( (sha4_context *) ctx ); } void sha512_hmac_wrap( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ) { sha4_hmac( key, keylen, input, ilen, output, 0 ); } void * sha512_ctx_alloc( void ) { return malloc( sizeof( sha4_context ) ); } void sha512_ctx_free( void *ctx ) { free( ctx ); } const md_info_t sha512_info = { POLARSSL_MD_SHA512, "SHA512", 64, sha512_starts_wrap, sha512_update_wrap, sha512_finish_wrap, sha512_wrap, sha512_file_wrap, sha512_hmac_starts_wrap, sha512_hmac_update_wrap, sha512_hmac_finish_wrap, sha512_hmac_reset_wrap, sha512_hmac_wrap, sha512_ctx_alloc, sha512_ctx_free, }; #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/cipher.c0000644000014601777760000003763312165464055022731 0ustar00jenkinsnogroup00000000000000/** * \file cipher.c * * \brief Generic cipher wrapper for PolarSSL * * \author Adriaan de Jong * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_CIPHER_C) #include "polarssl/cipher.h" #include "polarssl/cipher_wrap.h" #include #if defined _MSC_VER && !defined strcasecmp #define strcasecmp _stricmp #endif static const int supported_ciphers[] = { #if defined(POLARSSL_AES_C) POLARSSL_CIPHER_AES_128_CBC, POLARSSL_CIPHER_AES_192_CBC, POLARSSL_CIPHER_AES_256_CBC, #if defined(POLARSSL_CIPHER_MODE_CFB) POLARSSL_CIPHER_AES_128_CFB128, POLARSSL_CIPHER_AES_192_CFB128, POLARSSL_CIPHER_AES_256_CFB128, #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) POLARSSL_CIPHER_AES_128_CTR, POLARSSL_CIPHER_AES_192_CTR, POLARSSL_CIPHER_AES_256_CTR, #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif /* defined(POLARSSL_AES_C) */ #if defined(POLARSSL_CAMELLIA_C) POLARSSL_CIPHER_CAMELLIA_128_CBC, POLARSSL_CIPHER_CAMELLIA_192_CBC, POLARSSL_CIPHER_CAMELLIA_256_CBC, #if defined(POLARSSL_CIPHER_MODE_CFB) POLARSSL_CIPHER_CAMELLIA_128_CFB128, POLARSSL_CIPHER_CAMELLIA_192_CFB128, POLARSSL_CIPHER_CAMELLIA_256_CFB128, #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) POLARSSL_CIPHER_CAMELLIA_128_CTR, POLARSSL_CIPHER_CAMELLIA_192_CTR, POLARSSL_CIPHER_CAMELLIA_256_CTR, #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif /* defined(POLARSSL_CAMELLIA_C) */ #if defined(POLARSSL_DES_C) POLARSSL_CIPHER_DES_CBC, POLARSSL_CIPHER_DES_EDE_CBC, POLARSSL_CIPHER_DES_EDE3_CBC, #endif /* defined(POLARSSL_DES_C) */ 0 }; const int *cipher_list( void ) { return supported_ciphers; } const cipher_info_t *cipher_info_from_type( const cipher_type_t cipher_type ) { /* Find static cipher information */ switch ( cipher_type ) { #if defined(POLARSSL_AES_C) case POLARSSL_CIPHER_AES_128_CBC: return &aes_128_cbc_info; case POLARSSL_CIPHER_AES_192_CBC: return &aes_192_cbc_info; case POLARSSL_CIPHER_AES_256_CBC: return &aes_256_cbc_info; #if defined(POLARSSL_CIPHER_MODE_CFB) case POLARSSL_CIPHER_AES_128_CFB128: return &aes_128_cfb128_info; case POLARSSL_CIPHER_AES_192_CFB128: return &aes_192_cfb128_info; case POLARSSL_CIPHER_AES_256_CFB128: return &aes_256_cfb128_info; #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) case POLARSSL_CIPHER_AES_128_CTR: return &aes_128_ctr_info; case POLARSSL_CIPHER_AES_192_CTR: return &aes_192_ctr_info; case POLARSSL_CIPHER_AES_256_CTR: return &aes_256_ctr_info; #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif #if defined(POLARSSL_CAMELLIA_C) case POLARSSL_CIPHER_CAMELLIA_128_CBC: return &camellia_128_cbc_info; case POLARSSL_CIPHER_CAMELLIA_192_CBC: return &camellia_192_cbc_info; case POLARSSL_CIPHER_CAMELLIA_256_CBC: return &camellia_256_cbc_info; #if defined(POLARSSL_CIPHER_MODE_CFB) case POLARSSL_CIPHER_CAMELLIA_128_CFB128: return &camellia_128_cfb128_info; case POLARSSL_CIPHER_CAMELLIA_192_CFB128: return &camellia_192_cfb128_info; case POLARSSL_CIPHER_CAMELLIA_256_CFB128: return &camellia_256_cfb128_info; #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) case POLARSSL_CIPHER_CAMELLIA_128_CTR: return &camellia_128_ctr_info; case POLARSSL_CIPHER_CAMELLIA_192_CTR: return &camellia_192_ctr_info; case POLARSSL_CIPHER_CAMELLIA_256_CTR: return &camellia_256_ctr_info; #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif #if defined(POLARSSL_DES_C) case POLARSSL_CIPHER_DES_CBC: return &des_cbc_info; case POLARSSL_CIPHER_DES_EDE_CBC: return &des_ede_cbc_info; case POLARSSL_CIPHER_DES_EDE3_CBC: return &des_ede3_cbc_info; #endif default: return NULL; } } const cipher_info_t *cipher_info_from_string( const char *cipher_name ) { if( NULL == cipher_name ) return NULL; /* Get the appropriate cipher information */ #if defined(POLARSSL_CAMELLIA_C) if( !strcasecmp( "CAMELLIA-128-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CBC ); if( !strcasecmp( "CAMELLIA-192-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CBC ); if( !strcasecmp( "CAMELLIA-256-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CBC ); #if defined(POLARSSL_CIPHER_MODE_CFB) if( !strcasecmp( "CAMELLIA-128-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CFB128 ); if( !strcasecmp( "CAMELLIA-192-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CFB128 ); if( !strcasecmp( "CAMELLIA-256-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CFB128 ); #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) if( !strcasecmp( "CAMELLIA-128-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_128_CTR ); if( !strcasecmp( "CAMELLIA-192-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_192_CTR ); if( !strcasecmp( "CAMELLIA-256-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_CAMELLIA_256_CTR ); #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif #if defined(POLARSSL_AES_C) if( !strcasecmp( "AES-128-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CBC ); if( !strcasecmp( "AES-192-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CBC ); if( !strcasecmp( "AES-256-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CBC ); #if defined(POLARSSL_CIPHER_MODE_CFB) if( !strcasecmp( "AES-128-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CFB128 ); if( !strcasecmp( "AES-192-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CFB128 ); if( !strcasecmp( "AES-256-CFB128", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CFB128 ); #endif /* defined(POLARSSL_CIPHER_MODE_CFB) */ #if defined(POLARSSL_CIPHER_MODE_CTR) if( !strcasecmp( "AES-128-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_128_CTR ); if( !strcasecmp( "AES-192-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_192_CTR ); if( !strcasecmp( "AES-256-CTR", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_AES_256_CTR ); #endif /* defined(POLARSSL_CIPHER_MODE_CTR) */ #endif #if defined(POLARSSL_DES_C) if( !strcasecmp( "DES-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_DES_CBC ); if( !strcasecmp( "DES-EDE-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_DES_EDE_CBC ); if( !strcasecmp( "DES-EDE3-CBC", cipher_name ) ) return cipher_info_from_type( POLARSSL_CIPHER_DES_EDE3_CBC ); #endif return NULL; } int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info ) { if( NULL == cipher_info || NULL == ctx ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; memset( ctx, 0, sizeof( cipher_context_t ) ); if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) ) return POLARSSL_ERR_CIPHER_ALLOC_FAILED; ctx->cipher_info = cipher_info; return 0; } int cipher_free_ctx( cipher_context_t *ctx ) { if( ctx == NULL || ctx->cipher_info == NULL ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx ); return 0; } int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, int key_length, const operation_t operation ) { if( NULL == ctx || NULL == ctx->cipher_info ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; ctx->key_length = key_length; ctx->operation = operation; /* * For CFB128 and CTR mode always use the encryption key schedule */ if( POLARSSL_ENCRYPT == operation || POLARSSL_MODE_CFB128 == ctx->cipher_info->mode || POLARSSL_MODE_CTR == ctx->cipher_info->mode ) { return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key, ctx->key_length ); } if( POLARSSL_DECRYPT == operation ) return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key, ctx->key_length ); return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; } int cipher_reset( cipher_context_t *ctx, const unsigned char *iv ) { if( NULL == ctx || NULL == ctx->cipher_info || NULL == iv ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; ctx->unprocessed_len = 0; memcpy( ctx->iv, iv, cipher_get_iv_size( ctx ) ); return 0; } int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ) { int ret; size_t copy_len = 0; if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen || input == output ) { return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; } *olen = 0; if( ctx->cipher_info->mode == POLARSSL_MODE_CBC ) { /* * If there is not enough data for a full block, cache it. */ if( ( ctx->operation == POLARSSL_DECRYPT && ilen + ctx->unprocessed_len <= cipher_get_block_size( ctx ) ) || ( ctx->operation == POLARSSL_ENCRYPT && ilen + ctx->unprocessed_len < cipher_get_block_size( ctx ) ) ) { memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input, ilen ); ctx->unprocessed_len += ilen; return 0; } /* * Process cached data first */ if( ctx->unprocessed_len != 0 ) { copy_len = cipher_get_block_size( ctx ) - ctx->unprocessed_len; memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input, copy_len ); if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, ctx->operation, cipher_get_block_size( ctx ), ctx->iv, ctx->unprocessed_data, output ) ) ) { return ret; } *olen += cipher_get_block_size( ctx ); output += cipher_get_block_size( ctx ); ctx->unprocessed_len = 0; input += copy_len; ilen -= copy_len; } /* * Cache final, incomplete block */ if( 0 != ilen ) { copy_len = ilen % cipher_get_block_size( ctx ); if( copy_len == 0 && ctx->operation == POLARSSL_DECRYPT ) copy_len = cipher_get_block_size(ctx); memcpy( ctx->unprocessed_data, &( input[ilen - copy_len] ), copy_len ); ctx->unprocessed_len += copy_len; ilen -= copy_len; } /* * Process remaining full blocks */ if( ilen ) { if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, ctx->operation, ilen, ctx->iv, input, output ) ) ) { return ret; } *olen += ilen; } return 0; } if( ctx->cipher_info->mode == POLARSSL_MODE_CFB128 ) { if( 0 != ( ret = ctx->cipher_info->base->cfb128_func( ctx->cipher_ctx, ctx->operation, ilen, &ctx->unprocessed_len, ctx->iv, input, output ) ) ) { return ret; } *olen = ilen; return 0; } if( ctx->cipher_info->mode == POLARSSL_MODE_CTR ) { if( 0 != ( ret = ctx->cipher_info->base->ctr_func( ctx->cipher_ctx, ilen, &ctx->unprocessed_len, ctx->iv, ctx->unprocessed_data, input, output ) ) ) { return ret; } *olen = ilen; return 0; } return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } static void add_pkcs_padding( unsigned char *output, size_t output_len, size_t data_len ) { size_t padding_len = output_len - data_len; unsigned char i = 0; for( i = 0; i < padding_len; i++ ) output[data_len + i] = (unsigned char) padding_len; } static int get_pkcs_padding( unsigned char *input, unsigned int input_len, size_t *data_len) { unsigned int i, padding_len = 0; if( NULL == input || NULL == data_len ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; padding_len = input[input_len - 1]; if( padding_len > input_len ) return POLARSSL_ERR_CIPHER_INVALID_PADDING; for( i = input_len - padding_len; i < input_len; i++ ) if( input[i] != padding_len ) return POLARSSL_ERR_CIPHER_INVALID_PADDING; *data_len = input_len - padding_len; return 0; } int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen) { int ret = 0; if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ) return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA; *olen = 0; if( POLARSSL_MODE_CFB128 == ctx->cipher_info->mode || POLARSSL_MODE_CTR == ctx->cipher_info->mode ) { return 0; } if( POLARSSL_MODE_CBC == ctx->cipher_info->mode ) { if( POLARSSL_ENCRYPT == ctx->operation ) { add_pkcs_padding( ctx->unprocessed_data, cipher_get_iv_size( ctx ), ctx->unprocessed_len ); } else if ( cipher_get_block_size( ctx ) != ctx->unprocessed_len ) { /* For decrypt operations, expect a full block */ return POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED; } /* cipher block */ if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx, ctx->operation, cipher_get_block_size( ctx ), ctx->iv, ctx->unprocessed_data, output ) ) ) { return ret; } /* Set output size for decryption */ if( POLARSSL_DECRYPT == ctx->operation ) return get_pkcs_padding( output, cipher_get_block_size( ctx ), olen ); /* Set output size for encryption */ *olen = cipher_get_block_size( ctx ); return 0; } return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } #if defined(POLARSSL_SELF_TEST) #include #define ASSERT(x) if (!(x)) { \ printf( "failed with %i at %s\n", value, (#x) ); \ return( 1 ); \ } /* * Checkup routine */ int cipher_self_test( int verbose ) { ((void) verbose); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/version.c0000644000014601777760000000275012165464055023134 0ustar00jenkinsnogroup00000000000000/* * Version information * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_VERSION_C) #include "polarssl/version.h" #include const char version[] = POLARSSL_VERSION_STRING; unsigned int version_get_number() { return POLARSSL_VERSION_NUMBER; } void version_get_string( char *string ) { memcpy( string, POLARSSL_VERSION_STRING, sizeof( POLARSSL_VERSION_STRING ) ); } void version_get_string_full( char *string ) { memcpy( string, POLARSSL_VERSION_STRING_FULL, sizeof( POLARSSL_VERSION_STRING_FULL ) ); } #endif /* POLARSSL_VERSION_C */ pdns-3.3/pdns/ext/polarssl-1.1.2/library/Makefile0000644000014601777760000000245412165464055022744 0ustar00jenkinsnogroup00000000000000 # Also see "include/polarssl/config.h" CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement OFLAGS = -O # MicroBlaze specific options: # CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift # To compile on Plan9: # CFLAGS += -D_BSD_EXTENSION # To compile as a shared library: CFLAGS += -fPIC SONAME=libpolarssl.so.0 DLEXT=so # OSX shared library extension: # DLEXT=dylib # Windows shared library extension: # DLEXT=dll OBJS= aes.o arc4.o asn1parse.o \ base64.o bignum.o camellia.o \ certs.o cipher.o cipher_wrap.o \ ctr_drbg.o debug.o des.o \ dhm.o entropy.o entropy_poll.o \ error.o havege.o \ md.o md_wrap.o md2.o \ md4.o md5.o net.o \ padlock.o pem.o pkcs11.o \ rsa.o sha1.o sha2.o \ sha4.o ssl_cli.o ssl_srv.o \ ssl_tls.o timing.o version.o \ x509parse.o xtea.o all: static static: libpolarssl.a shared: libpolarssl.$(DLEXT) libpolarssl.a: $(OBJS) $(AR) r $@ $(OBJS) $(AR) s $@ libpolarssl.so: libpolarssl.a $(CC) ${LDFLAGS} -shared -Wl,-soname,$(SONAME) -o $@ $(OBJS) libpolarssl.dylib: libpolarssl.a $(CC) ${LDFLAGS} -dynamiclib -o $@ $(OBJS) libpolarssl.dll: libpolarssl.a $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 .c.o: $(CC) $(CFLAGS) $(OFLAGS) -c $< clean: rm -f *.o libpolarssl.* pdns-3.3/pdns/ext/polarssl-1.1.2/library/debug.c0000644000014601777760000001422712165464055022537 0ustar00jenkinsnogroup00000000000000/* * Debugging routines * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_DEBUG_C) #include "polarssl/debug.h" #include #include #if defined _MSC_VER && !defined snprintf #define snprintf _snprintf #endif #if defined _MSC_VER && !defined vsnprintf #define vsnprintf _vsnprintf #endif char *debug_fmt( const char *format, ... ) { va_list argp; static char str[512]; int maxlen = sizeof( str ) - 1; va_start( argp, format ); vsnprintf( str, maxlen, format, argp ); va_end( argp ); str[maxlen] = '\0'; return( str ); } void debug_print_msg( const ssl_context *ssl, int level, const char *file, int line, const char *text ) { char str[512]; int maxlen = sizeof( str ) - 1; if( ssl->f_dbg == NULL ) return; snprintf( str, maxlen, "%s(%04d): %s\n", file, line, text ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); } void debug_print_ret( const ssl_context *ssl, int level, const char *file, int line, const char *text, int ret ) { char str[512]; int maxlen = sizeof( str ) - 1; if( ssl->f_dbg == NULL ) return; snprintf( str, maxlen, "%s(%04d): %s() returned %d (0x%x)\n", file, line, text, ret, ret ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); } void debug_print_buf( const ssl_context *ssl, int level, const char *file, int line, const char *text, unsigned char *buf, size_t len ) { char str[512]; size_t i, maxlen = sizeof( str ) - 1; if( ssl->f_dbg == NULL ) return; snprintf( str, maxlen, "%s(%04d): dumping '%s' (%d bytes)\n", file, line, text, (unsigned int) len ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); for( i = 0; i < len; i++ ) { if( i >= 4096 ) break; if( i % 16 == 0 ) { if( i > 0 ) ssl->f_dbg( ssl->p_dbg, level, "\n" ); snprintf( str, maxlen, "%s(%04d): %04x: ", file, line, (unsigned int) i ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); } snprintf( str, maxlen, " %02x", (unsigned int) buf[i] ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); } if( len > 0 ) ssl->f_dbg( ssl->p_dbg, level, "\n" ); } void debug_print_mpi( const ssl_context *ssl, int level, const char *file, int line, const char *text, const mpi *X ) { char str[512]; int j, k, maxlen = sizeof( str ) - 1, zeros = 1; size_t i, n; if( ssl->f_dbg == NULL || X == NULL ) return; for( n = X->n - 1; n > 0; n-- ) if( X->p[n] != 0 ) break; for( j = ( sizeof(t_uint) << 3 ) - 1; j >= 0; j-- ) if( ( ( X->p[n] >> j ) & 1 ) != 0 ) break; snprintf( str, maxlen, "%s(%04d): value of '%s' (%lu bits) is:\n", file, line, text, (unsigned long) ( ( n * ( sizeof(t_uint) << 3 ) ) + j + 1 ) ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); for( i = n + 1, j = 0; i > 0; i-- ) { if( zeros && X->p[i - 1] == 0 ) continue; for( k = sizeof( t_uint ) - 1; k >= 0; k-- ) { if( zeros && ( ( X->p[i - 1] >> (k << 3) ) & 0xFF ) == 0 ) continue; else zeros = 0; if( j % 16 == 0 ) { if( j > 0 ) ssl->f_dbg( ssl->p_dbg, level, "\n" ); snprintf( str, maxlen, "%s(%04d): ", file, line ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); } snprintf( str, maxlen, " %02x", (unsigned int) ( X->p[i - 1] >> (k << 3) ) & 0xFF ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); j++; } } if( zeros == 1 ) { snprintf( str, maxlen, "%s(%04d): ", file, line ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); ssl->f_dbg( ssl->p_dbg, level, " 00" ); } ssl->f_dbg( ssl->p_dbg, level, "\n" ); } void debug_print_crt( const ssl_context *ssl, int level, const char *file, int line, const char *text, const x509_cert *crt ) { char str[1024], prefix[64]; int i = 0, maxlen = sizeof( prefix ) - 1; if( ssl->f_dbg == NULL || crt == NULL ) return; snprintf( prefix, maxlen, "%s(%04d): ", file, line ); prefix[maxlen] = '\0'; maxlen = sizeof( str ) - 1; while( crt != NULL ) { char buf[1024]; x509parse_cert_info( buf, sizeof( buf ) - 1, prefix, crt ); snprintf( str, maxlen, "%s(%04d): %s #%d:\n%s", file, line, text, ++i, buf ); str[maxlen] = '\0'; ssl->f_dbg( ssl->p_dbg, level, str ); debug_print_mpi( ssl, level, file, line, "crt->rsa.N", &crt->rsa.N ); debug_print_mpi( ssl, level, file, line, "crt->rsa.E", &crt->rsa.E ); crt = crt->next; } } #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/ctr_drbg.c0000644000014601777760000003517412165464055023243 0ustar00jenkinsnogroup00000000000000/* * CTR_DRBG implementation based on AES-256 (NIST SP 800-90) * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The NIST SP 800-90 DRBGs are described in the following publucation. * * http://csrc.nist.gov/publications/nistpubs/800-90/SP800-90revised_March2007.pdf */ #include "polarssl/config.h" #if defined(POLARSSL_CTR_DRBG_C) #include "polarssl/ctr_drbg.h" #if defined(POLARSSL_FS_IO) #include #endif /* * Non-public function wrapped by ctr_crbg_init(). Necessary to allow NIST * tests to succeed (which require known length fixed entropy) */ int ctr_drbg_init_entropy_len( ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len, size_t entropy_len ) { int ret; unsigned char key[CTR_DRBG_KEYSIZE]; memset( ctx, 0, sizeof(ctr_drbg_context) ); memset( key, 0, CTR_DRBG_KEYSIZE ); ctx->f_entropy = f_entropy; ctx->p_entropy = p_entropy; ctx->entropy_len = entropy_len; ctx->reseed_interval = CTR_DRBG_RESEED_INTERVAL; /* * Initialize with an empty key */ aes_setkey_enc( &ctx->aes_ctx, key, CTR_DRBG_KEYBITS ); if( ( ret = ctr_drbg_reseed( ctx, custom, len ) ) != 0 ) return( ret ); return( 0 ); } int ctr_drbg_init( ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len ) { return( ctr_drbg_init_entropy_len( ctx, f_entropy, p_entropy, custom, len, CTR_DRBG_ENTROPY_LEN ) ); } void ctr_drbg_set_prediction_resistance( ctr_drbg_context *ctx, int resistance ) { ctx->prediction_resistance = resistance; } void ctr_drbg_set_entropy_len( ctr_drbg_context *ctx, size_t len ) { ctx->entropy_len = len; } void ctr_drbg_set_reseed_interval( ctr_drbg_context *ctx, int interval ) { ctx->reseed_interval = interval; } int block_cipher_df( unsigned char *output, const unsigned char *data, size_t data_len ) { unsigned char buf[CTR_DRBG_MAX_SEED_INPUT + CTR_DRBG_BLOCKSIZE + 16]; unsigned char tmp[CTR_DRBG_SEEDLEN]; unsigned char key[CTR_DRBG_KEYSIZE]; unsigned char chain[CTR_DRBG_BLOCKSIZE]; unsigned char *p = buf, *iv; aes_context aes_ctx; int i, j, buf_len, use_len; memset( buf, 0, CTR_DRBG_MAX_SEED_INPUT + CTR_DRBG_BLOCKSIZE + 16 ); /* * Construct IV (16 bytes) and S in buffer * IV = Counter (in 32-bits) padded to 16 with zeroes * S = Length input string (in 32-bits) || Length of output (in 32-bits) || * data || 0x80 * (Total is padded to a multiple of 16-bytes with zeroes) */ p = buf + CTR_DRBG_BLOCKSIZE; *p++ = ( data_len >> 24 ) & 0xff; *p++ = ( data_len >> 16 ) & 0xff; *p++ = ( data_len >> 8 ) & 0xff; *p++ = ( data_len ) & 0xff; p += 3; *p++ = CTR_DRBG_SEEDLEN; memcpy( p, data, data_len ); p[data_len] = 0x80; buf_len = CTR_DRBG_BLOCKSIZE + 8 + data_len + 1; for( i = 0; i < CTR_DRBG_KEYSIZE; i++ ) key[i] = i; aes_setkey_enc( &aes_ctx, key, CTR_DRBG_KEYBITS ); /* * Reduce data to POLARSSL_CTR_DRBG_SEEDLEN bytes of data */ for( j = 0; j < CTR_DRBG_SEEDLEN; j += CTR_DRBG_BLOCKSIZE ) { p = buf; memset( chain, 0, CTR_DRBG_BLOCKSIZE ); use_len = buf_len; while( use_len > 0 ) { for( i = 0; i < CTR_DRBG_BLOCKSIZE; i++ ) chain[i] ^= p[i]; p += CTR_DRBG_BLOCKSIZE; use_len -= CTR_DRBG_BLOCKSIZE; aes_crypt_ecb( &aes_ctx, AES_ENCRYPT, chain, chain ); } memcpy( tmp + j, chain, CTR_DRBG_BLOCKSIZE ); /* * Update IV */ buf[3]++; } /* * Do final encryption with reduced data */ aes_setkey_enc( &aes_ctx, tmp, CTR_DRBG_KEYBITS ); iv = tmp + CTR_DRBG_KEYSIZE; p = output; for( j = 0; j < CTR_DRBG_SEEDLEN; j += CTR_DRBG_BLOCKSIZE ) { aes_crypt_ecb( &aes_ctx, AES_ENCRYPT, iv, iv ); memcpy( p, iv, CTR_DRBG_BLOCKSIZE ); p += CTR_DRBG_BLOCKSIZE; } return( 0 ); } int ctr_drbg_update_internal( ctr_drbg_context *ctx, const unsigned char data[CTR_DRBG_SEEDLEN] ) { unsigned char tmp[CTR_DRBG_SEEDLEN]; unsigned char *p = tmp; int cb, i, j; memset( tmp, 0, CTR_DRBG_SEEDLEN ); for( j = 0; j < CTR_DRBG_SEEDLEN; j += CTR_DRBG_BLOCKSIZE ) { /* * Increase counter */ i = CTR_DRBG_BLOCKSIZE - 1; do { ctx->counter[i]++; cb = ctx->counter[i] == 0; } while( i-- && cb ); /* * Crypt counter block */ aes_crypt_ecb( &ctx->aes_ctx, AES_ENCRYPT, ctx->counter, p ); p += CTR_DRBG_BLOCKSIZE; } for( i = 0; i < CTR_DRBG_SEEDLEN; i++ ) tmp[i] ^= data[i]; /* * Update key and counter */ aes_setkey_enc( &ctx->aes_ctx, tmp, CTR_DRBG_KEYBITS ); memcpy( ctx->counter, tmp + CTR_DRBG_KEYSIZE, CTR_DRBG_BLOCKSIZE ); return( 0 ); } void ctr_drbg_update( ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ) { unsigned char add_input[CTR_DRBG_SEEDLEN]; if( add_len > 0 ) { block_cipher_df( add_input, additional, add_len ); ctr_drbg_update_internal( ctx, add_input ); } } int ctr_drbg_reseed( ctr_drbg_context *ctx, const unsigned char *additional, size_t len ) { unsigned char seed[CTR_DRBG_MAX_SEED_INPUT]; size_t seedlen = 0; if( ctx->entropy_len + len > CTR_DRBG_MAX_SEED_INPUT ) return( POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG ); memset( seed, 0, CTR_DRBG_MAX_SEED_INPUT ); /* * Gather enropy_len bytes of entropy to seed state */ if( 0 != ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) ) { return( POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED ); } seedlen += ctx->entropy_len; /* * Add additional data */ if( additional && len ) { memcpy( seed + seedlen, additional, len ); seedlen += len; } /* * Reduce to 384 bits */ block_cipher_df( seed, seed, seedlen ); /* * Update state */ ctr_drbg_update_internal( ctx, seed ); ctx->reseed_counter = 1; return( 0 ); } int ctr_drbg_random_with_add( void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len ) { int ret = 0; ctr_drbg_context *ctx = (ctr_drbg_context *) p_rng; unsigned char add_input[CTR_DRBG_SEEDLEN]; unsigned char *p = output; unsigned char tmp[CTR_DRBG_BLOCKSIZE]; int cb, i; size_t use_len; if( output_len > CTR_DRBG_MAX_REQUEST ) return( POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG ); if( add_len > CTR_DRBG_MAX_INPUT ) return( POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG ); memset( add_input, 0, CTR_DRBG_SEEDLEN ); if( ctx->reseed_counter > ctx->reseed_interval || ctx->prediction_resistance ) { if( ( ret = ctr_drbg_reseed( ctx, additional, add_len ) ) != 0 ) return( ret ); add_len = 0; } if( add_len > 0 ) { block_cipher_df( add_input, additional, add_len ); ctr_drbg_update_internal( ctx, add_input ); } while( output_len > 0 ) { /* * Increase counter */ i = CTR_DRBG_BLOCKSIZE - 1; do { ctx->counter[i]++; cb = ctx->counter[i] == 0; } while( i-- && cb ); /* * Crypt counter block */ aes_crypt_ecb( &ctx->aes_ctx, AES_ENCRYPT, ctx->counter, tmp ); use_len = (output_len > CTR_DRBG_BLOCKSIZE ) ? CTR_DRBG_BLOCKSIZE : output_len; /* * Copy random block to destination */ memcpy( p, tmp, use_len ); p += use_len; output_len -= use_len; } ctr_drbg_update_internal( ctx, add_input ); ctx->reseed_counter++; return( 0 ); } int ctr_drbg_random( void *p_rng, unsigned char *output, size_t output_len ) { return ctr_drbg_random_with_add( p_rng, output, output_len, NULL, 0 ); } #if defined(POLARSSL_FS_IO) int ctr_drbg_write_seed_file( ctr_drbg_context *ctx, const char *path ) { int ret; FILE *f; unsigned char buf[ CTR_DRBG_MAX_INPUT ]; if( ( f = fopen( path, "wb" ) ) == NULL ) return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); if( ( ret = ctr_drbg_random( ctx, buf, CTR_DRBG_MAX_INPUT ) ) != 0 ) return( ret ); if( fwrite( buf, 1, CTR_DRBG_MAX_INPUT, f ) != CTR_DRBG_MAX_INPUT ) { fclose( f ); return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } int ctr_drbg_update_seed_file( ctr_drbg_context *ctx, const char *path ) { FILE *f; size_t n; unsigned char buf[ CTR_DRBG_MAX_INPUT ]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); fseek( f, 0, SEEK_END ); n = (size_t) ftell( f ); fseek( f, 0, SEEK_SET ); if( n > CTR_DRBG_MAX_INPUT ) return( POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG ); if( fread( buf, 1, n, f ) != n ) { fclose( f ); return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); } ctr_drbg_update( ctx, buf, n ); fclose( f ); return( ctr_drbg_write_seed_file( ctx, path ) ); } #endif /* POLARSSL_FS_IO */ #if defined(POLARSSL_SELF_TEST) #include unsigned char entropy_source_pr[96] = { 0xc1, 0x80, 0x81, 0xa6, 0x5d, 0x44, 0x02, 0x16, 0x19, 0xb3, 0xf1, 0x80, 0xb1, 0xc9, 0x20, 0x02, 0x6a, 0x54, 0x6f, 0x0c, 0x70, 0x81, 0x49, 0x8b, 0x6e, 0xa6, 0x62, 0x52, 0x6d, 0x51, 0xb1, 0xcb, 0x58, 0x3b, 0xfa, 0xd5, 0x37, 0x5f, 0xfb, 0xc9, 0xff, 0x46, 0xd2, 0x19, 0xc7, 0x22, 0x3e, 0x95, 0x45, 0x9d, 0x82, 0xe1, 0xe7, 0x22, 0x9f, 0x63, 0x31, 0x69, 0xd2, 0x6b, 0x57, 0x47, 0x4f, 0xa3, 0x37, 0xc9, 0x98, 0x1c, 0x0b, 0xfb, 0x91, 0x31, 0x4d, 0x55, 0xb9, 0xe9, 0x1c, 0x5a, 0x5e, 0xe4, 0x93, 0x92, 0xcf, 0xc5, 0x23, 0x12, 0xd5, 0x56, 0x2c, 0x4a, 0x6e, 0xff, 0xdc, 0x10, 0xd0, 0x68 }; unsigned char entropy_source_nopr[64] = { 0x5a, 0x19, 0x4d, 0x5e, 0x2b, 0x31, 0x58, 0x14, 0x54, 0xde, 0xf6, 0x75, 0xfb, 0x79, 0x58, 0xfe, 0xc7, 0xdb, 0x87, 0x3e, 0x56, 0x89, 0xfc, 0x9d, 0x03, 0x21, 0x7c, 0x68, 0xd8, 0x03, 0x38, 0x20, 0xf9, 0xe6, 0x5e, 0x04, 0xd8, 0x56, 0xf3, 0xa9, 0xc4, 0x4a, 0x4c, 0xbd, 0xc1, 0xd0, 0x08, 0x46, 0xf5, 0x98, 0x3d, 0x77, 0x1c, 0x1b, 0x13, 0x7e, 0x4e, 0x0f, 0x9d, 0x8e, 0xf4, 0x09, 0xf9, 0x2e }; unsigned char nonce_pers_pr[16] = { 0xd2, 0x54, 0xfc, 0xff, 0x02, 0x1e, 0x69, 0xd2, 0x29, 0xc9, 0xcf, 0xad, 0x85, 0xfa, 0x48, 0x6c }; unsigned char nonce_pers_nopr[16] = { 0x1b, 0x54, 0xb8, 0xff, 0x06, 0x42, 0xbf, 0xf5, 0x21, 0xf1, 0x5c, 0x1c, 0x0b, 0x66, 0x5f, 0x3f }; unsigned char result_pr[16] = { 0x34, 0x01, 0x16, 0x56, 0xb4, 0x29, 0x00, 0x8f, 0x35, 0x63, 0xec, 0xb5, 0xf2, 0x59, 0x07, 0x23 }; unsigned char result_nopr[16] = { 0xa0, 0x54, 0x30, 0x3d, 0x8a, 0x7e, 0xa9, 0x88, 0x9d, 0x90, 0x3e, 0x07, 0x7c, 0x6f, 0x21, 0x8f }; int test_offset; int ctr_drbg_self_test_entropy( void *data, unsigned char *buf, size_t len ) { unsigned char *p = data; memcpy( buf, p + test_offset, len ); test_offset += 32; return( 0 ); } /* * Checkup routine */ int ctr_drbg_self_test( int verbose ) { ctr_drbg_context ctx; unsigned char buf[16]; /* * Based on a NIST CTR_DRBG test vector (PR = True) */ if( verbose != 0 ) printf( " CTR_DRBG (PR = TRUE) : " ); test_offset = 0; if( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy, entropy_source_pr, nonce_pers_pr, 16, 32 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON ); if( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( memcmp( buf, result_pr, CTR_DRBG_BLOCKSIZE ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); /* * Based on a NIST CTR_DRBG test vector (PR = FALSE) */ if( verbose != 0 ) printf( " CTR_DRBG (PR = FALSE): " ); test_offset = 0; if( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy, entropy_source_nopr, nonce_pers_nopr, 16, 32 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( ctr_drbg_random( &ctx, buf, 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( ctr_drbg_reseed( &ctx, NULL, 0 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( ctr_drbg_random( &ctx, buf, 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( memcmp( buf, result_nopr, 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/xtea.c0000644000014601777760000001476112165464055022415 0ustar00jenkinsnogroup00000000000000/* * An 32-bit implementation of the XTEA algorithm * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_XTEA_C) #include "polarssl/xtea.h" /* * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE #define GET_ULONG_BE(n,b,i) \ { \ (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ | ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (unsigned long) (b)[(i) + 3] ); \ } #endif #ifndef PUT_ULONG_BE #define PUT_ULONG_BE(n,b,i) \ { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ } #endif /* * XTEA key schedule */ void xtea_setup( xtea_context *ctx, unsigned char key[16] ) { int i; memset(ctx, 0, sizeof(xtea_context)); for( i = 0; i < 4; i++ ) { GET_ULONG_BE( ctx->k[i], key, i << 2 ); } } /* * XTEA encrypt function */ int xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8], unsigned char output[8]) { uint32_t *k, v0, v1, i; k = ctx->k; GET_ULONG_BE( v0, input, 0 ); GET_ULONG_BE( v1, input, 4 ); if( mode == XTEA_ENCRYPT ) { uint32_t sum = 0, delta = 0x9E3779B9; for( i = 0; i < 32; i++ ) { v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]); sum += delta; v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]); } } else /* XTEA_DECRYPT */ { uint32_t delta = 0x9E3779B9, sum = delta * 32; for( i = 0; i < 32; i++ ) { v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]); sum -= delta; v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]); } } PUT_ULONG_BE( v0, output, 0 ); PUT_ULONG_BE( v1, output, 4 ); return( 0 ); } /* * XTEA-CBC buffer encryption/decryption */ int xtea_crypt_cbc( xtea_context *ctx, int mode, size_t length, unsigned char iv[8], unsigned char *input, unsigned char *output) { int i; unsigned char temp[8]; if(length % 8) return( POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH ); if( mode == XTEA_DECRYPT ) { while( length > 0 ) { memcpy( temp, input, 8 ); xtea_crypt_ecb( ctx, mode, input, output ); for(i = 0; i < 8; i++) output[i] = (unsigned char)( output[i] ^ iv[i] ); memcpy( iv, temp, 8 ); input += 8; output += 8; length -= 8; } } else { while( length > 0 ) { for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); xtea_crypt_ecb( ctx, mode, output, output ); memcpy( iv, output, 8 ); input += 8; output += 8; length -= 8; } } return( 0 ); } #if defined(POLARSSL_SELF_TEST) #include #include /* * XTEA tests vectors (non-official) */ static const unsigned char xtea_test_key[6][16] = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; static const unsigned char xtea_test_pt[6][8] = { { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 }, { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, { 0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f }, { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 }, { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, { 0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55 } }; static const unsigned char xtea_test_ct[6][8] = { { 0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5 }, { 0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8 }, { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }, { 0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5 }, { 0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d }, { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 } }; /* * Checkup routine */ int xtea_self_test( int verbose ) { int i; unsigned char buf[8]; xtea_context ctx; for( i = 0; i < 6; i++ ) { if( verbose != 0 ) printf( " XTEA test #%d: ", i + 1 ); memcpy( buf, xtea_test_pt[i], 8 ); xtea_setup( &ctx, (unsigned char *) xtea_test_key[i] ); xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, buf, buf ); if( memcmp( buf, xtea_test_ct[i], 8 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/md2.c0000644000014601777760000002207012165464055022126 0ustar00jenkinsnogroup00000000000000/* * RFC 1115/1319 compliant MD2 implementation * * Copyright (C) 2006-2010, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* * The MD2 algorithm was designed by Ron Rivest in 1989. * * http://www.ietf.org/rfc/rfc1115.txt * http://www.ietf.org/rfc/rfc1319.txt */ #include "polarssl/config.h" #if defined(POLARSSL_MD2_C) #include "polarssl/md2.h" #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include #endif static const unsigned char PI_SUBST[256] = { 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13, 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A, 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, 0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, 0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6, 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, 0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F, 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, 0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A, 0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, 0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14 }; /* * MD2 context setup */ void md2_starts( md2_context *ctx ) { memset( ctx->cksum, 0, 16 ); memset( ctx->state, 0, 46 ); memset( ctx->buffer, 0, 16 ); ctx->left = 0; } static void md2_process( md2_context *ctx ) { int i, j; unsigned char t = 0; for( i = 0; i < 16; i++ ) { ctx->state[i + 16] = ctx->buffer[i]; ctx->state[i + 32] = (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); } for( i = 0; i < 18; i++ ) { for( j = 0; j < 48; j++ ) { ctx->state[j] = (unsigned char) ( ctx->state[j] ^ PI_SUBST[t] ); t = ctx->state[j]; } t = (unsigned char)( t + i ); } t = ctx->cksum[15]; for( i = 0; i < 16; i++ ) { ctx->cksum[i] = (unsigned char) ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); t = ctx->cksum[i]; } } /* * MD2 process buffer */ void md2_update( md2_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; while( ilen > 0 ) { if( ctx->left + ilen > 16 ) fill = 16 - ctx->left; else fill = ilen; memcpy( ctx->buffer + ctx->left, input, fill ); ctx->left += fill; input += fill; ilen -= fill; if( ctx->left == 16 ) { ctx->left = 0; md2_process( ctx ); } } } /* * MD2 final digest */ void md2_finish( md2_context *ctx, unsigned char output[16] ) { size_t i; unsigned char x; x = (unsigned char)( 16 - ctx->left ); for( i = ctx->left; i < 16; i++ ) ctx->buffer[i] = x; md2_process( ctx ); memcpy( ctx->buffer, ctx->cksum, 16 ); md2_process( ctx ); memcpy( output, ctx->state, 16 ); } /* * output = MD2( input buffer ) */ void md2( const unsigned char *input, size_t ilen, unsigned char output[16] ) { md2_context ctx; md2_starts( &ctx ); md2_update( &ctx, input, ilen ); md2_finish( &ctx, output ); memset( &ctx, 0, sizeof( md2_context ) ); } #if defined(POLARSSL_FS_IO) /* * output = MD2( file contents ) */ int md2_file( const char *path, unsigned char output[16] ) { FILE *f; size_t n; md2_context ctx; unsigned char buf[1024]; if( ( f = fopen( path, "rb" ) ) == NULL ) return( POLARSSL_ERR_MD2_FILE_IO_ERROR ); md2_starts( &ctx ); while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) md2_update( &ctx, buf, n ); md2_finish( &ctx, output ); memset( &ctx, 0, sizeof( md2_context ) ); if( ferror( f ) != 0 ) { fclose( f ); return( POLARSSL_ERR_MD2_FILE_IO_ERROR ); } fclose( f ); return( 0 ); } #endif /* POLARSSL_FS_IO */ /* * MD2 HMAC context setup */ void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen ) { size_t i; unsigned char sum[16]; if( keylen > 16 ) { md2( key, keylen, sum ); keylen = 16; key = sum; } memset( ctx->ipad, 0x36, 16 ); memset( ctx->opad, 0x5C, 16 ); for( i = 0; i < keylen; i++ ) { ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } md2_starts( ctx ); md2_update( ctx, ctx->ipad, 16 ); memset( sum, 0, sizeof( sum ) ); } /* * MD2 HMAC process buffer */ void md2_hmac_update( md2_context *ctx, const unsigned char *input, size_t ilen ) { md2_update( ctx, input, ilen ); } /* * MD2 HMAC final digest */ void md2_hmac_finish( md2_context *ctx, unsigned char output[16] ) { unsigned char tmpbuf[16]; md2_finish( ctx, tmpbuf ); md2_starts( ctx ); md2_update( ctx, ctx->opad, 16 ); md2_update( ctx, tmpbuf, 16 ); md2_finish( ctx, output ); memset( tmpbuf, 0, sizeof( tmpbuf ) ); } /* * MD2 HMAC context reset */ void md2_hmac_reset( md2_context *ctx ) { md2_starts( ctx ); md2_update( ctx, ctx->ipad, 16 ); } /* * output = HMAC-MD2( hmac key, input buffer ) */ void md2_hmac( const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16] ) { md2_context ctx; md2_hmac_starts( &ctx, key, keylen ); md2_hmac_update( &ctx, input, ilen ); md2_hmac_finish( &ctx, output ); memset( &ctx, 0, sizeof( md2_context ) ); } #if defined(POLARSSL_SELF_TEST) /* * RFC 1319 test vectors */ static const char md2_test_str[7][81] = { { "" }, { "a" }, { "abc" }, { "message digest" }, { "abcdefghijklmnopqrstuvwxyz" }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" }, { "12345678901234567890123456789012345678901234567890123456789012" \ "345678901234567890" } }; static const unsigned char md2_test_sum[7][16] = { { 0x83, 0x50, 0xE5, 0xA3, 0xE2, 0x4C, 0x15, 0x3D, 0xF2, 0x27, 0x5C, 0x9F, 0x80, 0x69, 0x27, 0x73 }, { 0x32, 0xEC, 0x01, 0xEC, 0x4A, 0x6D, 0xAC, 0x72, 0xC0, 0xAB, 0x96, 0xFB, 0x34, 0xC0, 0xB5, 0xD1 }, { 0xDA, 0x85, 0x3B, 0x0D, 0x3F, 0x88, 0xD9, 0x9B, 0x30, 0x28, 0x3A, 0x69, 0xE6, 0xDE, 0xD6, 0xBB }, { 0xAB, 0x4F, 0x49, 0x6B, 0xFB, 0x2A, 0x53, 0x0B, 0x21, 0x9F, 0xF3, 0x30, 0x31, 0xFE, 0x06, 0xB0 }, { 0x4E, 0x8D, 0xDF, 0xF3, 0x65, 0x02, 0x92, 0xAB, 0x5A, 0x41, 0x08, 0xC3, 0xAA, 0x47, 0x94, 0x0B }, { 0xDA, 0x33, 0xDE, 0xF2, 0xA4, 0x2D, 0xF1, 0x39, 0x75, 0x35, 0x28, 0x46, 0xC3, 0x03, 0x38, 0xCD }, { 0xD5, 0x97, 0x6F, 0x79, 0xD8, 0x3D, 0x3A, 0x0D, 0xC9, 0x80, 0x6C, 0x3C, 0x66, 0xF3, 0xEF, 0xD8 } }; /* * Checkup routine */ int md2_self_test( int verbose ) { int i; unsigned char md2sum[16]; for( i = 0; i < 7; i++ ) { if( verbose != 0 ) printf( " MD2 test #%d: ", i + 1 ); md2( (unsigned char *) md2_test_str[i], strlen( md2_test_str[i] ), md2sum ); if( memcmp( md2sum, md2_test_sum[i], 16 ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( 1 ); } if( verbose != 0 ) printf( "passed\n" ); } if( verbose != 0 ) printf( "\n" ); return( 0 ); } #endif #endif pdns-3.3/pdns/ext/polarssl-1.1.2/library/entropy_poll.c0000644000014601777760000000635712165464055024204 0ustar00jenkinsnogroup00000000000000/* * Platform-specific and custom entropy polling functions * * Copyright (C) 2006-2011, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker * * All rights reserved. * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "polarssl/config.h" #if defined(POLARSSL_ENTROPY_C) #include "polarssl/entropy.h" #include "polarssl/entropy_poll.h" #if defined(POLARSSL_TIMING_C) #include "polarssl/timing.h" #endif #if defined(POLARSSL_HAVEGE_C) #include "polarssl/havege.h" #endif #if !defined(POLARSSL_NO_PLATFORM_ENTROPY) #if defined(_WIN32) #include #if !defined(_WIN32_WINNT) #define _WIN32_WINNT 0x0400 #endif #include int platform_entropy_poll( void *data, unsigned char *output, size_t len, size_t *olen ) { HCRYPTPROV provider; ((void) data); *olen = 0; if( CryptAcquireContext( &provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE ) { return POLARSSL_ERR_ENTROPY_SOURCE_FAILED; } if( CryptGenRandom( provider, len, output ) == FALSE ) return POLARSSL_ERR_ENTROPY_SOURCE_FAILED; CryptReleaseContext( provider, 0 ); *olen = len; return( 0 ); } #else #include int platform_entropy_poll( void *data, unsigned char *output, size_t len, size_t *olen ) { FILE *file; size_t ret; ((void) data); *olen = 0; file = fopen( "/dev/urandom", "rb" ); if( file == NULL ) return POLARSSL_ERR_ENTROPY_SOURCE_FAILED; ret = fread( output, 1, len, file ); if( ret != len ) { fclose( file ); return POLARSSL_ERR_ENTROPY_SOURCE_FAILED; } fclose( file ); *olen = len; return( 0 ); } #endif #endif #if defined(POLARSSL_TIMING_C) int hardclock_poll( void *data, unsigned char *output, size_t len, size_t *olen ) { unsigned long timer = hardclock(); ((void) data); *olen = 0; if( len < sizeof(unsigned long) ) return( 0 ); memcpy( output, &timer, sizeof(unsigned long) ); *olen = sizeof(unsigned long); return( 0 ); } #endif #if defined(POLARSSL_HAVEGE_C) int havege_poll( void *data, unsigned char *output, size_t len, size_t *olen ) { havege_state *hs = (havege_state *) data; *olen = 0; if( havege_random( hs, output, len ) != 0 ) return POLARSSL_ERR_ENTROPY_SOURCE_FAILED; *olen = len; return( 0 ); } #endif #endif /* POLARSSL_ENTROPY_C */ pdns-3.3/pdns/misc.hh0000644000014601777760000003053212165455411016012 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MISC_HH #define MISC_HH #include #include #include #include #include #include #include #include #include #include using namespace ::boost::multi_index; #if 0 #include using std::cout; using std::endl; struct TSCTimer { TSCTimer() { RDTSC(d_tsc1); } ~TSCTimer() { uint64_t tsc2; RDTSC(tsc2); cout<<"Timer: "<< (tsc2 - d_tsc1)/3000.0 << endl; } uint64_t d_tsc1; }; #endif #include "utility.hh" #include "dns.hh" #ifndef WIN32 # include # include # include # include # include #else # define WINDOWS_LEAN_AND_MEAN # include # include "utility.hh" #endif // WIN32 #include #include #include #include #include #include "namespaces.hh" bool chopOff(string &domain); bool chopOffDotted(string &domain); bool endsOn(const string &domain, const string &suffix); bool dottedEndsOn(const string &domain, const string &suffix); string nowTime(); const string unquotify(const string &item); string humanDuration(time_t passed); bool stripDomainSuffix(string *qname, const string &domain); void stripLine(string &line); string getHostname(); string urlEncode(const string &text); int waitForData(int fd, int seconds, int useconds=0); int waitFor2Data(int fd1, int fd2, int seconds, int useconds, int* fd); int waitForRWData(int fd, bool waitForRead, int seconds, int useconds); uint16_t getShort(const unsigned char *p); uint16_t getShort(const char *p); uint32_t getLong(const unsigned char *p); uint32_t getLong(const char *p); int logFacilityToLOG(unsigned int facility); struct ServiceTuple { string host; uint16_t port; }; void parseService(const string &descr, ServiceTuple &st); template void stringtok (Container &container, string const &in, const char * const delimiters = " \t\n") { const string::size_type len = in.length(); string::size_type i = 0; while (i void vstringtok (Container &container, string const &in, const char * const delimiters = " \t\n") { const string::size_type len = in.length(); string::size_type i = 0; while (i='A' && c<='Z') c+='a'-'A'; return c; } inline const string toLower(const string &upper) { string reply(upper); char c; for(unsigned int i = 0; i < reply.length(); i++) { c = dns_tolower(upper[i]); if( c != upper[i]) reply[i] = c; } return reply; } inline const string toLowerCanonic(const string &upper) { string reply(upper); if(!upper.empty()) { unsigned int i, limit= ( unsigned int ) reply.length(); char c; for(i = 0; i < limit ; i++) { c = dns_tolower(upper[i]); if(c != upper[i]) reply[i] = c; } if(upper[i-1]=='.') reply.resize(i-1); } return reply; } // Make s uppercase: inline string toUpper( const string& s ) { string r(s); for( unsigned int i = 0; i < s.length(); i++ ) { r[i] = toupper( r[i] ); } return r; } inline double getTime() { struct timeval now; Utility::gettimeofday(&now,0); return now.tv_sec+now.tv_usec/1000000.0; } inline void unixDie(const string &why) { throw runtime_error(why+": "+strerror(errno)); } string makeHexDump(const string& str); void shuffle(vector& rrs); void orderAndShuffle(vector& rrs); void normalizeTV(struct timeval& tv); const struct timeval operator+(const struct timeval& lhs, const struct timeval& rhs); const struct timeval operator-(const struct timeval& lhs, const struct timeval& rhs); inline float makeFloat(const struct timeval& tv) { return tv.tv_sec + tv.tv_usec/1000000.0f; } inline bool operator<(const struct timeval& lhs, const struct timeval& rhs) { return make_pair(lhs.tv_sec, lhs.tv_usec) < make_pair(rhs.tv_sec, rhs.tv_usec); } inline bool pdns_ilexicographical_compare(const std::string& a, const std::string& b) __attribute__((pure)); inline bool pdns_ilexicographical_compare(const std::string& a, const std::string& b) { string::size_type aLen = a.length(), bLen = b.length(), n; const unsigned char *aPtr = (const unsigned char*)a.c_str(), *bPtr = (const unsigned char*)b.c_str(); int result; for(n = 0 ; n < aLen && n < bLen ; ++n) { if((result = dns_tolower(*aPtr++) - dns_tolower(*bPtr++))) { return result < 0; } } if(n == aLen && n == bLen) // strings are equal (in length) return 0; if(n == aLen) // first string was shorter return true; return false; } inline bool pdns_iequals(const std::string& a, const std::string& b) __attribute__((pure)); inline bool pdns_iequals(const std::string& a, const std::string& b) { string::size_type aLen = a.length(), bLen = b.length(), n; const char *aPtr = a.c_str(), *bPtr = b.c_str(); for(n = 0 ; n < aLen && n < bLen ; ++n) { if(dns_tolower(*aPtr++) != dns_tolower(*bPtr++)) return false; } return aLen == bLen; // strings are equal (in length) } // lifted from boost, with thanks class AtomicCounter { public: explicit AtomicCounter( unsigned int v = 0) : value_( v ) {} unsigned int operator++() { return atomic_exchange_and_add( &value_, +1 ) + 1; } unsigned int operator++(int) { return atomic_exchange_and_add( &value_, +1 ); } unsigned int operator--() { return atomic_exchange_and_add( &value_, -1 ) - 1; } operator unsigned int() const { return atomic_exchange_and_add( &value_, 0); } private: AtomicCounter(AtomicCounter const &); AtomicCounter &operator=(AtomicCounter const &); mutable unsigned int value_; // the below is necessary because __sync_fetch_and_add is not universally available on i386.. I 3> RHEL5. #if defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) static int atomic_exchange_and_add( unsigned int * pw, int dv ) { // int r = *pw; // *pw += dv; // return r; int r; __asm__ __volatile__ ( "lock\n\t" "xadd %1, %0": "+m"( *pw ), "=r"( r ): // outputs (%0, %1) "1"( dv ): // inputs (%2 == %1) "memory", "cc" // clobbers ); return r; } #else static int atomic_exchange_and_add( unsigned int * pw, int dv ) { return __sync_fetch_and_add(pw, dv); } #endif }; struct CIStringCompare: public std::binary_function { bool operator()(const string& a, const string& b) const { return pdns_ilexicographical_compare(a, b); } }; struct CIStringPairCompare: public std::binary_function, pair, bool> { bool operator()(const pair& a, const pair& b) const { if(pdns_ilexicographical_compare(a.first, b.first)) return true; if(pdns_ilexicographical_compare(b.first, a.first)) return false; return a.second < b.second; } }; pair splitField(const string& inp, char sepa); inline bool isCanonical(const string& dom) { if(dom.empty()) return false; return dom[dom.size()-1]=='.'; } inline string toCanonic(const string& zone, const string& domain) { if(domain.length()==1 && domain[0]=='@') return zone; if(isCanonical(domain)) return domain; string ret=domain; ret.append(1,'.'); if(!zone.empty() && zone[0]!='.') ret.append(zone); return ret; } inline void setSocketReusable(int fd) { int tmp=1; setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&tmp, static_cast(sizeof tmp)); } string stripDot(const string& dom); void seedRandom(const string& source); string makeRelative(const std::string& fqdn, const std::string& zone); string labelReverse(const std::string& qname); std::string dotConcat(const std::string& a, const std::string &b); int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret); int makeIPv4sockaddr(const string &str, struct sockaddr_in* ret); bool stringfgets(FILE* fp, std::string& line); template std::pair replacing_insert(Index& i,const typename Index::value_type& x) { std::pair res=i.insert(x); if(!res.second)res.second=i.replace(res.first,x); return res; } /** very small regex wrapper */ class Regex { public: /** constructor that accepts the expression to regex */ Regex(const string &expr); ~Regex() { regfree(&d_preg); } /** call this to find out if 'line' matches your expression */ bool match(const string &line) { return regexec(&d_preg,line.c_str(),0,0,0)==0; } private: regex_t d_preg; }; #endif pdns-3.3/pdns/common_startup.cc0000644000014601777760000004155712156563632020135 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "common_startup.hh" bool g_anyToTcp; bool g_addSuperfluousNSEC3; typedef Distributor DNSDistributor; ArgvMap theArg; StatBag S; //!< Statistics are gathered across PDNS via the StatBag class S PacketCache PC; //!< This is the main PacketCache, shared accross all threads DNSProxy *DP; DynListener *dl; CommunicatorClass Communicator; UDPNameserver *N; int avg_latency; TCPNameserver *TN; ArgvMap &arg() { return theArg; } void declareArguments() { ::arg().set("local-port","The port on which we listen")="53"; ::arg().setSwitch("log-failed-updates","If PDNS should log failed update requests")=""; ::arg().setSwitch("log-dns-details","If PDNS should log DNS non-erroneous details")=""; ::arg().setSwitch("log-dns-queries","If PDNS should log all incoming DNS queries")="no"; ::arg().set("urlredirector","Where we send hosts to that need to be url redirected")="127.0.0.1"; ::arg().set("smtpredirector","Our smtpredir MX host")="a.misconfigured.powerdns.smtp.server"; ::arg().set("local-address","Local IP addresses to which we bind")="0.0.0.0"; ::arg().set("local-ipv6","Local IP address to which we bind")=""; ::arg().set("query-local-address","Source IP address for sending queries")="0.0.0.0"; ::arg().set("query-local-address6","Source IPv6 address for sending queries")="::"; ::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0"; ::arg().set("max-queue-length","Maximum queuelength before considering situation lost")="5000"; ::arg().set("soa-serial-offset","Make sure that no SOA serial is less than this number")="0"; ::arg().set("retrieval-threads", "Number of AXFR-retrieval threads for slave operation")="2"; ::arg().setSwitch("experimental-json-interface", "If the webserver should serve JSON data")="no"; ::arg().setCmd("help","Provide a helpful message"); ::arg().setCmd("version","Output version and compilation date"); ::arg().setCmd("config","Provide configuration file on standard output"); ::arg().setCmd("list-modules","Lists all modules available"); ::arg().setCmd("no-config","Don't parse configuration file"); ::arg().set("version-string","PowerDNS version in packets - full, anonymous, powerdns or custom")="full"; ::arg().set("control-console","Debugging switch - don't use")="no"; // but I know you will! ::arg().set("fancy-records","Process URL and MBOXFW records")="no"; ::arg().set("wildcard-url","Process URL and MBOXFW records")="no"; ::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="4"; ::arg().set("default-soa-name","name to insert in the SOA record if none set in the backend")="a.misconfigured.powerdns.server"; ::arg().set("default-soa-mail","mail address to insert in the SOA record if none set in the backend")=""; ::arg().set("distributor-threads","Default number of Distributor (backend) threads to start")="3"; ::arg().set("signing-threads","Default number of signer threads to start")="3"; ::arg().set("receiver-threads","Default number of receiver threads to start")="1"; ::arg().set("queue-limit","Maximum number of milliseconds to queue a query")="1500"; ::arg().set("recursor","If recursion is desired, IP address of a recursing nameserver")="no"; ::arg().set("allow-recursion","List of subnets that are allowed to recurse")="0.0.0.0/0"; ::arg().set("pipebackend-abi-version","Version of the pipe backend ABI")="1"; ::arg().set("disable-tcp","Do not listen to TCP queries")="no"; ::arg().set("disable-axfr","Do not allow zone transfers")="no"; ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")=""; ::arg().set("load-modules","Load this module - supply absolute or relative path")=""; ::arg().set("launch","Which backends to launch and order to query them in")=""; ::arg().setSwitch("disable-axfr","Disable zonetransfers but do allow TCP queries")="no"; ::arg().set("allow-axfr-ips","Allow zonetransfers only to these subnets")="0.0.0.0/0,::/0"; ::arg().set("slave-cycle-interval","Reschedule failed SOA serial checks once every .. seconds")="60"; ::arg().set("tcp-control-address","If set, PowerDNS can be controlled over TCP on this address")=""; ::arg().set("tcp-control-port","If set, PowerDNS can be controlled over TCP on this address")="53000"; ::arg().set("tcp-control-secret","If set, PowerDNS can be controlled over TCP after passing this secret")=""; ::arg().set("tcp-control-range","If set, remote control of PowerDNS is possible over these networks only")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; ::arg().setSwitch("slave","Act as a slave")="no"; ::arg().setSwitch("master","Act as a master")="no"; ::arg().setSwitch("guardian","Run within a guardian process")="no"; ::arg().setSwitch("send-root-referral","Send out old-fashioned root-referral instead of ServFail in case of no authority")="no"; ::arg().setSwitch("prevent-self-notification","Don't send notifications to what we think is ourself")="yes"; ::arg().setSwitch("webserver","Start a webserver for monitoring")="no"; ::arg().setSwitch("webserver-print-arguments","If the webserver should print arguments")="no"; ::arg().setSwitch("edns-subnet-processing","If we should act on EDNS Subnet options")="no"; ::arg().setSwitch("any-to-tcp","Answer ANY queries with tc=1, shunting to TCP")="no"; ::arg().set("edns-subnet-option-number","EDNS option number to use")="20730"; ::arg().set("webserver-address","IP Address of webserver to listen on")="127.0.0.1"; ::arg().set("webserver-port","Port of webserver to listen on")="8081"; ::arg().set("webserver-password","Password required for accessing the webserver")=""; ::arg().setSwitch("out-of-zone-additional-processing","Do out of zone additional processing")="yes"; ::arg().setSwitch("do-ipv6-additional-processing", "Do AAAA additional processing")="yes"; ::arg().setSwitch("query-logging","Hint backends that queries should be logged")="no"; ::arg().set("cache-ttl","Seconds to store packets in the PacketCache")="20"; ::arg().set("recursive-cache-ttl","Seconds to store packets for recursive queries in the PacketCache")="10"; ::arg().set("negquery-cache-ttl","Seconds to store negative query results in the QueryCache")="60"; ::arg().set("query-cache-ttl","Seconds to store query results in the QueryCache")="20"; ::arg().set("soa-minimum-ttl","Default SOA minimum ttl")="3600"; ::arg().set("server-id", "Returned when queried for 'server.id' TXT or NSID, defaults to hostname")=""; ::arg().set("soa-refresh-default","Default SOA refresh")="10800"; ::arg().set("soa-retry-default","Default SOA retry")="3600"; ::arg().set("soa-expire-default","Default SOA expire")="604800"; ::arg().set("trusted-notification-proxy", "IP address of incoming notification proxy")=""; ::arg().set("slave-renotify", "If we should send out notifications for slaved updates")="no"; ::arg().set("default-ttl","Seconds a result is valid if not set otherwise")="3600"; ::arg().set("max-tcp-connections","Maximum number of TCP connections")="10"; ::arg().setSwitch("no-shuffle","Set this to prevent random shuffling of answers - for regression testing")="off"; ::arg().set("experimental-logfile", "Filename of the log file for JSON parser" )= "/var/log/pdns.log"; ::arg().set("setuid","If set, change user id to this uid for more security")=""; ::arg().set("setgid","If set, change group id to this gid for more security")=""; ::arg().set("max-cache-entries", "Maximum number of cache entries")="1000000"; ::arg().set("max-ent-entries", "Maximum number of empty non-terminals in a zone")="100000"; ::arg().set("entropy-source", "If set, read entropy from this file")="/dev/urandom"; ::arg().set("lua-prequery-script", "Lua script with prequery handler")=""; ::arg().setSwitch("traceback-handler","Enable the traceback handler (Linux only)")="yes"; ::arg().setSwitch("experimental-direct-dnskey","EXPERIMENTAL: fetch DNSKEY RRs from backend during DNSKEY synthesis")="no"; ::arg().setSwitch("add-superfluous-nsec3-for-old-bind","Add superfluous NSEC3 record to positive wildcard response")="yes"; ::arg().set("default-ksk-algorithms","Default KSK algorithms")="rsasha256"; ::arg().set("default-ksk-size","Default KSK size (0 means default)")="0"; ::arg().set("default-zsk-algorithms","Default ZSK algorithms")="rsasha256"; ::arg().set("default-zsk-size","Default KSK size (0 means default)")="0"; ::arg().set("include-dir","Include *.conf files from this directory"); } void declareStats(void) { S.declare("udp-queries","Number of UDP queries received"); S.declare("udp-answers","Number of answers sent out over UDP"); S.declare("udp4-answers","Number of IPv4 answers sent out over UDP"); S.declare("udp4-queries","Number of IPv4UDP queries received"); S.declare("udp6-answers","Number of IPv6 answers sent out over UDP"); S.declare("udp6-queries","Number of IPv6 UDP queries received"); S.declare("recursing-answers","Number of recursive answers sent out"); S.declare("recursing-questions","Number of questions sent to recursor"); S.declare("corrupt-packets","Number of corrupt packets received"); S.declare("tcp-queries","Number of TCP queries received"); S.declare("tcp-answers","Number of answers sent out over TCP"); S.declare("qsize-q","Number of questions waiting for database attention"); S.declare("deferred-cache-inserts","Amount of cache inserts that were deferred because of maintenance"); S.declare("deferred-cache-lookup","Amount of cache lookups that were deferred because of maintenance"); S.declare("query-cache-hit","Number of hits on the query cache"); S.declare("query-cache-miss","Number of misses on the query cache"); S.declare("servfail-packets","Number of times a server-failed packet was sent out"); S.declare("latency","Average number of microseconds needed to answer a question"); S.declare("timedout-packets","Number of packets which weren't answered within timeout set"); S.declareRing("queries","UDP Queries Received"); S.declareRing("nxdomain-queries","Queries for non-existent records within existent domains"); S.declareRing("noerror-queries","Queries for existing records, but for type we don't have"); S.declareRing("servfail-queries","Queries that could not be answered due to backend errors"); S.declareRing("unauth-queries","Queries for domains that we are not authoritative for"); S.declareRing("logmessages","Log Messages"); S.declareRing("remotes","Remote server IP addresses"); S.declareRing("remotes-unauth","Remote hosts querying domains for which we are not auth"); S.declareRing("remotes-corrupt","Remote hosts sending corrupt packets"); } int isGuarded(char **argv) { char *p=strstr(argv[0],"-instance"); return !!p; } void sendout(const DNSDistributor::AnswerData &AD) { static unsigned int &numanswered=*S.getPointer("udp-answers"); static unsigned int &numanswered4=*S.getPointer("udp4-answers"); static unsigned int &numanswered6=*S.getPointer("udp6-answers"); if(!AD.A) return; N->send(AD.A); numanswered++; if(AD.A->d_remote.getSocklen()==sizeof(sockaddr_in)) numanswered4++; else numanswered6++; int diff=AD.A->d_dt.udiff(); avg_latency=(int)(1023*avg_latency/1024+diff/1024); delete AD.A; } //! The qthread receives questions over the internet via the Nameserver class, and hands them to the Distributor for further processing void *qthread(void *number) { DNSPacket *P; DNSDistributor *distributor = new DNSDistributor(::arg().asNum("distributor-threads")); // the big dispatcher! DNSPacket question; DNSPacket cached; unsigned int &numreceived=*S.getPointer("udp-queries"); unsigned int &numanswered=*S.getPointer("udp-answers"); unsigned int &numreceived4=*S.getPointer("udp4-queries"); unsigned int &numanswered4=*S.getPointer("udp4-answers"); unsigned int &numreceived6=*S.getPointer("udp6-queries"); unsigned int &numanswered6=*S.getPointer("udp6-answers"); int diff; bool logDNSQueries = ::arg().mustDo("log-dns-queries"); bool skipfirst=true; unsigned int maintcount = 0; for(;;) { if (skipfirst) skipfirst=false; else numreceived++; if(number==0) { // only run on main thread if(!((maintcount++)%250)) { // maintenance tasks S.set("latency",(int)avg_latency); int qcount, acount; distributor->getQueueSizes(qcount, acount); S.set("qsize-q",qcount); } } if(!(P=N->receive(&question))) { // receive a packet inline continue; // packet was broken, try again } if(P->d_remote.getSocklen()==sizeof(sockaddr_in)) numreceived4++; else numreceived6++; if(P->d.qr) continue; S.ringAccount("queries", P->qdomain+"/"+P->qtype.getName()); S.ringAccount("remotes",P->getRemote()); if(logDNSQueries) { string remote; if(P->hasEDNSSubnet()) remote = P->getRemote() + "<-" + P->getRealRemote().toString(); else remote = P->getRemote(); L << Logger::Notice<<"Remote "<< remote <<" wants '" << P->qdomain<<"|"<qtype.getName() << "', do = " <d_dnssecOk <<", bufsize = "<< P->getMaxReplyLen()<<": "; } if((P->d.opcode != Opcode::Notify) && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question? if(logDNSQueries) L<<"packetcache HIT"<d_remote); // inlined cached.setSocket(P->getSocket()); // inlined cached.d_anyLocal = P->d_anyLocal; cached.setMaxReplyLen(P->getMaxReplyLen()); cached.d.rd=P->d.rd; // copy in recursion desired bit cached.d.id=P->d.id; cached.commitD(); // commit d to the packet inlined N->send(&cached); // answer it then inlined diff=P->d_dt.udiff(); avg_latency=(int)(0.999*avg_latency+0.001*diff); // 'EWMA' numanswered++; if(P->d_remote.sin4.sin_family==AF_INET) numanswered4++; else numanswered6++; continue; } if(distributor->isOverloaded()) { if(logDNSQueries) L<<"Dropped query, db is overloaded"<question(P, &sendout); // otherwise, give to the distributor } return 0; } void mainthread() { Utility::srandom(time(0)); int newgid=0; if(!::arg()["setgid"].empty()) newgid=Utility::makeGidNumeric(::arg()["setgid"]); int newuid=0; if(!::arg()["setuid"].empty()) newuid=Utility::makeUidNumeric(::arg()["setuid"]); g_anyToTcp = ::arg().mustDo("any-to-tcp"); g_addSuperfluousNSEC3 = ::arg().mustDo("add-superfluous-nsec3-for-old-bind"); DNSPacket::s_doEDNSSubnetProcessing = ::arg().mustDo("edns-subnet-processing"); #ifndef WIN32 if(!::arg()["chroot"].empty()) { if(::arg().mustDo("master") || ::arg().mustDo("slave")) gethostbyname("a.root-servers.net"); // this forces all lookup libraries to be loaded if(chroot(::arg()["chroot"].c_str())<0 || chdir("/")<0) { L<onlyFrom(::arg()["allow-recursion"]); DP->go(); } // NOW SAFE TO CREATE THREADS! dl->go(); pthread_t qtid; if(::arg().mustDo("webserver")) sws.go(); if(::arg().mustDo("slave") || ::arg().mustDo("master")) Communicator.go(); if(TN) TN->go(); // tcp nameserver launch // fork(); (this worked :-)) unsigned int max_rthreads= ::arg().asNum("receiver-threads"); for(unsigned int n=0; n < max_rthreads; ++n) pthread_create(&qtid,0,qthread, reinterpret_cast(n)); // receives packets void *p; pthread_join(qtid, &p); L< #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "dns.hh" #include "dnsbackend.hh" #include "ueberbackend.hh" #include "dnspacket.hh" #include "nameserver.hh" #include "distributor.hh" #include "logger.hh" #include "arguments.hh" #include "packethandler.hh" #include "statbag.hh" #include "tcpreceiver.hh" #include "ws.hh" #include "misc.hh" #include "dynlistener.hh" #include "dynhandler.hh" #include "communicator.hh" #include "dnsproxy.hh" #include "utility.hh" #include "common_startup.hh" #include "dnsrecords.hh" #include "version.hh" time_t s_starttime; string s_programname="pdns"; // used in packethandler.cc const char *funnytext= "*****************************************************************************\n"\ "Ok, you just ran pdns_server through 'strings' hoping to find funny messages.\n"\ "Well, you found one. \n"\ "Two ions are flying through their particle accelerator, says the one to the\n" "other 'I think I've lost an electron!' \n"\ "So the other one says, 'Are you sure?'. 'YEAH! I'M POSITIVE!'\n"\ " the pdns crew - pdns@powerdns.com\n" "*****************************************************************************\n"; // start (sys)logging /** \var Logger L \brief All logging is done via L, a Logger instance */ /** \file receiver.cc \brief The main loop of powerdns This file is where it all happens - main is here, as are the two pivotal threads qthread() and athread() */ void daemonize(void) { if(fork()) exit(0); // bye bye setsid(); int i=open("/dev/null",O_RDWR); /* open stdin */ if(i < 0) L<&parts, pid_t ppid) { string line; for(vector::const_iterator i=parts.begin();i!=parts.end();++i) { if(i!=parts.begin()) line.append(1,' '); line.append(*i); } line.append(1,'\n'); Lock l(&g_guardian_lock); try { writen2(g_fd1[1],line.c_str(),line.size()+1); } catch(AhuException &ae) { return "Error communicating with instance: "+ae.reason; } char mesg[512]; string response; while(fgets(mesg,sizeof(mesg),g_fp)) { if(*mesg=='\n') break; response+=mesg; } boost::trim_right(response); return response; } static string DLCycleHandler(const vector&parts, pid_t ppid) { kill(cpid, SIGKILL); // why? kill(cpid, SIGKILL); // why? sleep(1); return "ok"; } static int guardian(int argc, char **argv) { if(isGuarded(argv)) return 0; int infd=0, outfd=1; DynListener dlg(s_programname); dlg.registerFunc("QUIT",&DLQuitHandler, "quit daemon"); dlg.registerFunc("CYCLE",&DLCycleHandler, "restart instance"); dlg.registerFunc("PING",&DLPingHandler, "ping guardian"); dlg.registerFunc("STATUS",&DLStatusHandler, "get instance status from guardian"); dlg.registerRestFunc(&DLRestHandler); dlg.go(); string progname=argv[0]; bool first=true; cpid=0; pthread_mutex_lock(&g_guardian_lock); for(;;) { int pid; setStatus("Launching child"); if(pipe(g_fd1)<0 || pipe(g_fd2)<0) { L<((progname+"-instance").c_str())); for(n=1;n0) { // parent close(g_fd1[0]); close(g_fd2[1]); if(first) { first=false; signal(SIGTERM, takedown); signal(SIGHUP, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); writePid(); } pthread_mutex_unlock(&g_guardian_lock); int status; cpid=pid; for(;;) { int ret=waitpid(pid,&status,WNOHANG); if(ret<0) { L<modules; stringtok(modules,::arg()["load-modules"],","); for(vector::const_iterator i=modules.begin();i!=modules.end();++i) { bool res; const string &module=*i; if(module.find(".")==string::npos) res=UeberBackend::loadmodule(::arg()["module-dir"]+"/lib"+module+"backend.so"); else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path res=UeberBackend::loadmodule(module); else res=UeberBackend::loadmodule(::arg()["module-dir"]+"/"+module); if(res==false) { L< static void tbhandler(int num) { L<= 3 std::ios_base::sync_with_stdio(false); #endif L.toConsole(Logger::Warning); try { declareArguments(); UNIX_declareArguments(); ::arg().laxParse(argc,argv); // do a lax parse if(::arg().mustDo("version")) { showProductVersion(); exit(99); } if(::arg()["config-name"]!="") s_programname+="-"+::arg()["config-name"]; (void)theL(s_programname); string configname=::arg()["config-dir"]+"/"+s_programname+".conf"; cleanSlashes(configname); if(!::arg().mustDo("config") && !::arg().mustDo("no-config")) // "config" == print a configuration file ::arg().laxFile(configname.c_str()); ::arg().laxParse(argc,argv); // reparse so the commandline still wins if(!::arg()["logging-facility"].empty()) { int val=logFacilityToLOG(::arg().asNum("logging-facility") ); if(val >= 0) theL().setFacility(val); else L<"); DynListener::registerFunc("RPING",&DLPingHandler, "ping instance"); DynListener::registerFunc("QUIT",&DLRQuitHandler, "quit daemon"); DynListener::registerFunc("UPTIME",&DLUptimeHandler, "get instance uptime"); DynListener::registerFunc("NOTIFY-HOST",&DLNotifyHostHandler, "notify host for specific domain", " "); DynListener::registerFunc("NOTIFY",&DLNotifyHandler, "queue a notification", ""); DynListener::registerFunc("RELOAD",&DLReloadHandler, "reload all zones"); DynListener::registerFunc("REDISCOVER",&DLRediscoverHandler, "discover any new zones"); DynListener::registerFunc("VERSION",&DLVersionHandler, "get instance version"); DynListener::registerFunc("PURGE",&DLPurgeHandler, "purge entries from packet cache", "[]"); DynListener::registerFunc("CCOUNTS",&DLCCHandler, "get cache statistics"); DynListener::registerFunc("SET",&DLSettingsHandler, "set config variables", " "); DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", ""); if(!::arg()["tcp-control-address"].empty()) { DynListener* dlTCP=new DynListener(ComboAddress(::arg()["tcp-control-address"], ::arg().asNum("tcp-control-port"))); dlTCP->go(); } // reparse, with error checking if(!::arg().mustDo("no-config")) ::arg().file(configname.c_str()); ::arg().parse(argc,argv); if(::arg()["server-id"].empty()) { char tmp[128]; gethostname(tmp, sizeof(tmp)-1); ::arg().set("server-id")=tmp; } UeberBackend::go(); N=new UDPNameserver; // this fails when we are not root, throws exception if(!::arg().mustDo("disable-tcp")) TN=new TCPNameserver; } catch(const ArgException &A) { L< #include "misc.hh" #include using std::string; BOOST_AUTO_TEST_SUITE(misc_hh) typedef pair typedns_t; BOOST_AUTO_TEST_CASE(test_CIStringCompare) { set nsset; nsset.insert("abc"); nsset.insert("ns.example.com"); nsset.insert(""); nsset.insert("def"); nsset.insert("aBc"); nsset.insert("ns.example.com"); BOOST_CHECK_EQUAL(nsset.size(), 4); ostringstream s; for(set::const_iterator i=nsset.begin();i!=nsset.end();++i) { s<<"("<<*i<<")"; } BOOST_CHECK_EQUAL(s.str(), "()(abc)(def)(ns.example.com)"); } BOOST_AUTO_TEST_CASE(test_CIStringPairCompare) { set nsset2; nsset2.insert(make_pair("ns.example.com", 1)); nsset2.insert(make_pair("abc", 1)); nsset2.insert(make_pair("", 1)); nsset2.insert(make_pair("def", 1)); nsset2.insert(make_pair("abc", 2)); nsset2.insert(make_pair("abc", 1)); nsset2.insert(make_pair("ns.example.com", 0)); nsset2.insert(make_pair("abc", 2)); nsset2.insert(make_pair("ABC", 2)); BOOST_CHECK_EQUAL(nsset2.size(), 6); ostringstream s; for(set::const_iterator i=nsset2.begin();i!=nsset2.end();++i) { s<<"("<first<<"|"<second<<")"; } BOOST_CHECK_EQUAL(s.str(), "(|1)(abc|1)(abc|2)(def|1)(ns.example.com|0)(ns.example.com|1)"); } BOOST_AUTO_TEST_CASE(test_stripDot) { BOOST_CHECK_EQUAL(stripDot("www.powerdns.com."), "www.powerdns.com"); } BOOST_AUTO_TEST_CASE(test_labelReverse) { BOOST_CHECK_EQUAL(labelReverse("www.powerdns.com"), "com powerdns www"); } BOOST_AUTO_TEST_CASE(test_makeRelative) { BOOST_CHECK_EQUAL(makeRelative("www.powerdns.com", "powerdns.com"), "www"); } BOOST_AUTO_TEST_CASE(test_AtomicCounter) { AtomicCounter ac; ++ac; ++ac; BOOST_CHECK_EQUAL(ac, 2); } BOOST_AUTO_TEST_CASE(test_parseService) { ServiceTuple tp; parseService("smtp.powerdns.com:25", tp); BOOST_CHECK_EQUAL(tp.host, "smtp.powerdns.com"); BOOST_CHECK_EQUAL(tp.port, 25); parseService("smtp.powerdns.com", tp); BOOST_CHECK_EQUAL(tp.port, 25); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/pdnssec.cc0000644000014601777760000013256412165343743016520 0ustar00jenkinsnogroup00000000000000#include "dnsseckeeper.hh" #include "dnssecinfra.hh" #include "statbag.hh" #include "base32.hh" #include "base64.hh" #include #include #include "dnsbackend.hh" #include "ueberbackend.hh" #include "arguments.hh" #include "packetcache.hh" #include "zoneparser-tng.hh" #include "signingpipe.hh" #include #include "bindbackend2.hh" StatBag S; PacketCache PC; using boost::scoped_ptr; namespace po = boost::program_options; po::variables_map g_vm; string s_programname="pdns"; namespace { bool g_verbose; // doesn't yet do anything though } ArgvMap &arg() { static ArgvMap arg; return arg; } string humanTime(time_t t) { char ret[256]; struct tm tm; localtime_r(&t, &tm); strftime(ret, sizeof(ret)-1, "%c", &tm); // %h:%M %Y-%m-%d return ret; } static void algorithm2name(uint8_t algo, string &name) { switch(algo) { case 0: name = "Reserved"; return; case 1: name = "RSAMD5"; return; case 2: name = "DH"; return; case 3: name = "DSA"; return; case 4: name = "ECC"; return; case 5: name = "RSASHA1"; return; case 6: name = "DSA-NSEC3-SHA1"; return; case 7: name = "RSASHA1-NSEC3-SHA1"; return; case 8: name = "RSASHA256"; return; case 9: name = "Reserved"; return; case 10: name = "RSASHA512"; return; case 11: name = "Reserved"; return; case 12: name = "ECC-GOST"; return; case 13: name = "ECDSAP256SHA256"; return; case 14: name = "ECDSAP384SHA384"; return; case 252: name = "INDIRECT"; return; case 253: name = "PRIVATEDNS"; return; case 254: name = "PRIVATEOID"; return; default: name = "Unallocated/Reserved"; return; } }; static int shorthand2algorithm(const string &algorithm) { if (!algorithm.compare("rsamd5")) return 1; if (!algorithm.compare("dh")) return 2; if (!algorithm.compare("dsa")) return 3; if (!algorithm.compare("ecc")) return 4; if (!algorithm.compare("rsasha1")) return 5; if (!algorithm.compare("rsasha256")) return 8; if (!algorithm.compare("rsasha512")) return 10; if (!algorithm.compare("gost")) return 12; if (!algorithm.compare("ecdsa256")) return 13; if (!algorithm.compare("ecdsa384")) return 14; if (!algorithm.compare("ed25519")) return 250; return -1; } void loadMainConfig(const std::string& configdir) { ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=configdir; ::arg().set("pipebackend-abi-version","Version of the pipe backend ABI")="1"; ::arg().set("default-ttl","Seconds a result is valid if not set otherwise")="3600"; ::arg().set("launch","Which backends to launch"); ::arg().set("dnssec","if we should do dnssec")="true"; ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")=g_vm["config-name"].as(); ::arg().setCmd("help","Provide a helpful message"); //::arg().laxParse(argc,argv); if(::arg().mustDo("help")) { cerr<<"syntax:"<list(zone, sd.domain_id); DNSResourceRecord rr; set qnames, nsset, dsnames, nonterm, insnonterm, delnonterm; bool doent=true; while(sd.db->get(rr)) { if (rr.qtype.getCode()) { qnames.insert(rr.qname); if(rr.qtype.getCode() == QType::NS && !pdns_iequals(rr.qname, zone)) nsset.insert(rr.qname); if(rr.qtype.getCode() == QType::DS) dsnames.insert(rr.qname); } else if(doent) delnonterm.insert(rr.qname); } NSEC3PARAMRecordContent ns3pr; bool narrow; bool haveNSEC3=dk.getNSEC3PARAM(zone, &ns3pr, &narrow); if(sd.db->doesDNSSEC()) { if(!haveNSEC3) cerr<<"Adding NSEC ordering information "<startTransaction("", -1); bool realrr=true; string hashed; uint32_t maxent = ::arg().asNum("max-ent-entries"); dononterm:; BOOST_FOREACH(const string& qname, qnames) { bool auth=true; string shorter(qname); if(realrr) { do { if(nsset.count(shorter)) { auth=false; break; } } while(chopOff(shorter)); } if(haveNSEC3) { if(!narrow) { hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, qname))); if(g_verbose) cerr<<"'"< '"<< hashed <<"'"<updateDNSSECOrderAndAuthAbsolute(sd.domain_id, qname, hashed, auth); } else sd.db->nullifyDNSSECOrderNameAndUpdateAuth(sd.domain_id, qname, auth); } else // NSEC { sd.db->updateDNSSECOrderAndAuth(sd.domain_id, zone, qname, auth); if (!realrr) sd.db->nullifyDNSSECOrderNameAndUpdateAuth(sd.domain_id, qname, auth); } if(realrr) { if (dsnames.count(qname)) sd.db->setDNSSECAuthOnDsRecord(sd.domain_id, qname); if (!auth || nsset.count(qname)) { if(haveNSEC3 && ns3pr.d_flags) sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "NS"); sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "A"); sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "AAAA"); } if(auth && doent) { shorter=qname; while(!pdns_iequals(shorter, zone) && chopOff(shorter)) { if(!qnames.count(shorter) && !nonterm.count(shorter)) { if(!(maxent)) { cerr<<"Zone '"<updateEmptyNonTerminals(sd.domain_id, zone, insnonterm, delnonterm, !doent); } if(doent) { realrr=false; qnames=nonterm; goto dononterm; } } if(doTransaction) sd.db->commitTransaction(); return true; } void rectifyAllZones(DNSSECKeeper &dk) { UeberBackend B("default"); vector domainInfo; B.getAllDomains(&domainInfo); BOOST_FOREACH(DomainInfo di, domainInfo) { cerr<<"Rectifying "<list(zone, sd.domain_id); DNSResourceRecord rr; uint64_t numrecords=0, numerrors=0, numwarnings=0; set cnames, noncnames; while(sd.db->get(rr)) { if(!endsOn(rr.qname, zone)) { cout<<"[Warning] The record "<(rr.priority)+" "+rr.content; if ( (rr.qtype.getCode() == QType::NS || rr.qtype.getCode() == QType::SRV || rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::CNAME) && rr.content[rr.content.size()-1] == '.') { cout<<"[Warning] The record "< drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); string tmp=drc->serialize(rr.qname); } catch(std::exception& e) { cout<<"[Error] Following record had a problem: "<::const_iterator i = cnames.begin(); i != cnames.end(); i++) { if (noncnames.find(*i) != noncnames.end()) { cout<<"[Error] CNAME "<<*i<<" found, but other records with same label exist."< domainInfo; B.getAllDomains(&domainInfo); int errors=0; BOOST_FOREACH(DomainInfo di, domainInfo) { if (checkZone(dk, B, di.zone) > 0) errors++; } cout<<"Checked "<lookup(QType(QType::SOA), zone); vector rrs; DNSResourceRecord rr; while (sd.db->get(rr)) { if (rr.qtype.getCode() == QType::SOA) rrs.push_back(rr); } if (rrs.size() > 1) { cerr<replaceRRSet(sd.domain_id, zone, rr.qtype, rrs)) { cerr<<"Backend did not replace SOA record. Backend might not support this operation."< signatures; uint32_t rnd; unsigned char* octets = (unsigned char*)&rnd; char tmp[25]; DTime dt; dt.set(); for(unsigned int n=0; n < 100000; ++n) { rnd = random(); snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d", octets[0], octets[1], octets[2], octets[3]); rr.content=tmp; snprintf(tmp, sizeof(tmp), "r-%u", rnd); rr.qname=string(tmp)+"."+zone; if(csp.submit(rr)) while(signatures = csp.getChunk(), !signatures.empty()) ; } cerr<<"Flushing the pipe, "< > toSign; string qname, apex; dsrc.d_digesttype=0; while(zpt.get(rr)) { if(rr.qtype.getCode() == QType::DNSKEY) { cerr<<"got DNSKEY!"<(DNSRecordContent::mastermake(QType::DNSKEY, 1, rr.content)); } else if(rr.qtype.getCode() == QType::RRSIG) { cerr<<"got RRSIG"<(DNSRecordContent::mastermake(QType::RRSIG, 1, rr.content)); } else if(rr.qtype.getCode() == QType::DS) { cerr<<"got DS"<(DNSRecordContent::mastermake(QType::DS, 1, rr.content)); } else { qname = rr.qname; toSign.push_back(shared_ptr(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content))); } } string msg = getMessageForRRSET(qname, rrc, toSign); cerr<<"Verify: "<verify(msg, rrc.d_signature)<sign(hash); cerr<verify(hash, resign)< k_algos; vector z_algos; int k_size; int z_size; stringtok(k_algos, ::arg()["default-ksk-algorithms"], " ,"); k_size = ::arg().asNum("default-ksk-size"); stringtok(z_algos, ::arg()["default-zsk-algorithms"], " ,"); z_size = ::arg().asNum("default-zsk-size"); if (k_size < 0) { throw runtime_error("KSK key size must be equal to or greater than 0"); } if (k_algos.size() < 1) { throw runtime_error("No algorithm(s) given for KSK"); } if (z_size < 0) { throw runtime_error("ZSK key size must be equal to or greater than 0"); } if (z_algos.size() < 1) { throw runtime_error("No algorithm(s) given for ZSK"); } if(dk.isSecuredZone(zone)) { cerr << "Zone '"<::iterator i = k_algos.begin()+1; i != k_algos.end(); i++) dk.addKey(zone, true, shorthand2algorithm(*i), k_size, true); // obvious errors will have been caught above BOOST_FOREACH(string z_algo, z_algos) { int algo = shorthand2algorithm(z_algo); dk.addKey(zone, false, algo, z_size); } // rectifyZone(dk, zone); // showZone(dk, zone); cout<<"Zone "<createSlaveDomain("127.0.0.1", zone, "_testschema"); cout<<"Slave domain created"<startTransaction(zone, di.id); rr.qtype=QType::SOA; rr.qname=zone; rr.ttl=86400; rr.domain_id=di.id; rr.auth=1; rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600"; cout<<"Feeding SOA"<feedRecord(rr); rr.qtype=QType::TXT; // 300 As rr.content="\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\""; cout<<"Feeding overlong TXT"<feedRecord(rr); cout<<"Committing"<commitTransaction(); cout<<"Querying TXT"<lookup(QType(QType::TXT), zone, NULL, di.id); if(db->get(rrget)) { DNSResourceRecord rrthrowaway; if(db->get(rrthrowaway)) // should not touch rr but don't assume anything { cout<<"Expected one record, got multiple, aborting"<startTransaction(zone, di.id); rr.qtype=QType::SOA; rr.qname=zone; rr.ttl=86400; rr.domain_id=di.id; rr.auth=1; rr.content="ns1.example.com. ahu.example.com. 2012081039 7200 3600 1209600 3600"; cout<<"Feeding SOA"<feedRecord(rr); rr.qtype=QType::A; rr.qname="_underscore."+zone; rr.content="127.0.0.1"; db->feedRecord(rr); rr.qname="bla."+zone; cout<<"Committing"<commitTransaction(); cout<<"Securing zone"<getBeforeAndAfterNames(di.id, zone, "z."+zone, before, after); cout<<"got '"<()->default_value(""), "virtual configuration name") ("config-dir", po::value()->default_value(SYSCONFDIR), "location of pdns.conf") ("commands", po::value >()); po::positional_options_description p; p.add("commands", -1); po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), g_vm); po::notify(g_vm); vector cmds; if(g_vm.count("commands")) cmds = g_vm["commands"].as >(); g_verbose = g_vm.count("verbose"); if(cmds.empty() || g_vm.count("help")) { cerr<<"Usage: \npdnssec [options] [params ..]\n\n"; cerr<<"Commands:\n"; cerr<<"activate-zone-key ZONE KEY-ID Activate the key with key id KEY-ID in ZONE\n"; cerr<<"add-zone-key ZONE zsk|ksk [bits] [active|passive]\n"; cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]\n"; cerr<<" Add a ZSK or KSK to zone and specify algo&bits\n"; cerr<<"check-zone ZONE Check a zone for correctness\n"; cerr<<"check-all-zones Check all zones for correctness\n"; cerr<<"create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)\n"; cerr<<"deactivate-zone-key ZONE KEY-ID Deactivate the key with key id KEY-ID in ZONE\n"; cerr<<"disable-dnssec ZONE Deactivate all keys and unset PRESIGNED in ZONE\n"; cerr<<"export-zone-dnskey ZONE KEY-ID Export to stdout the public DNSKEY described\n"; cerr<<"export-zone-key ZONE KEY-ID Export to stdout the private key described\n"; cerr<<"generate-zone-key zsk|ksk [bits] [algorithm]\n"; cerr<<" Generate a ZSK or KSK to stdout with specified algo&bits\n"; cerr<<"hash-zone-record ZONE RNAME Calculate the NSEC3 hash for RNAME in ZONE\n"; cerr<<"increase-serial ZONE Increases the SOA-serial by 1. Uses SOA-EDIT\n"; cerr<<"import-zone-key ZONE FILE Import from a file a private key, ZSK or KSK\n"; cerr<<" [active|passive][ksk|zsk] Defaults to KSK and active\n"; cerr<<"rectify-zone ZONE [ZONE ..] Fix up DNSSEC fields (order, auth)\n"; cerr<<"rectify-all-zones Rectify all zones.\n"; cerr<<"remove-zone-key ZONE KEY-ID Remove key with KEY-ID from ZONE\n"; cerr<<"secure-zone ZONE [ZONE ..] Add KSK and two ZSKs\n"; cerr<<"set-nsec3 ZONE ['params' [narrow]] Enable NSEC3 with PARAMs. Optionally narrow\n"; cerr<<"set-presigned ZONE Use presigned RRSIGs from storage\n"; cerr<<"show-zone ZONE Show DNSSEC (public) key details about a zone\n"; cerr<<"unset-nsec3 ZONE Switch back to NSEC\n"; cerr<<"unset-presigned ZONE No longer use presigned RRSIGs\n"; cerr<<"test-schema ZONE Test DB schema - will create ZONE\n\n"; cerr<(cmds[1])); return 0; } if(cmds[0] == "test-algorithms") { testAlgorithms(); return 0; } loadMainConfig(g_vm["config-dir"].as()); reportAllTypes(); if(cmds[0] == "create-bind-db") { if(cmds.size() != 2) { cerr << "Syntax: pdnssec create-bind-db fname"< 3) ? cmds[3] : "", atoi(cmds[2].c_str())); } else if(cmds[0] == "verify-crypto") { if(cmds.size() != 2) { cerr << "Syntax: pdnssec verify-crypto FILE"<0) { algorithm = tmp_algo; } else if(pdns_iequals(cmds[n], "active")) { active=true; } else if(pdns_iequals(cmds[n], "inactive") || pdns_iequals(cmds[n], "passive")) { active=false; } else if(atoi(cmds[n].c_str())) { bits = atoi(cmds[n].c_str()); } else { cerr<<"Unknown algorithm, key flag or size '"< mustRectify; dk.startTransaction(); unsigned int zoneErrors=0; for(unsigned int n = 1; n < cmds.size(); ++n) { const string& zone=cmds[n]; if(secureZone(dk, zone)) { mustRectify.push_back(zone); } else { zoneErrors++; } } dk.commitTransaction(); BOOST_FOREACH(string& zone, mustRectify) rectifyZone(dk, zone); if (zoneErrors) { return 1; } return 0; } else if(cmds[0]=="set-nsec3") { if(cmds.size() < 2) { cerr<<"Syntax: pdnssec set-nsec3 ZONE 'params' [narrow]"< 2 ? cmds[2] : "1 0 1 ab"; bool narrow = cmds.size() > 3 && cmds[3]=="narrow"; NSEC3PARAMRecordContent ns3pr(nsec3params); string zone=cmds[1]; if(!dk.isSecuredZone(zone)) { cerr<<"Zone '"<convertToISC() < key(DNSCryptoKeyEngine::makeFromPEMString(drc, raw)); dpk.setKey(key); dpk.d_algorithm = atoi(cmds[3].c_str()); if(dpk.d_algorithm == 7) dpk.d_algorithm = 5; cerr<<(int)dpk.d_algorithm< 4) { if(pdns_iequals(cmds[4], "ZSK")) dpk.d_flags = 256; else if(pdns_iequals(cmds[4], "KSK")) dpk.d_flags = 257; else { cerr<<"Unknown key flag '"< key(DNSCryptoKeyEngine::makeFromISCFile(drc, fname.c_str())); dpk.setKey(key); dpk.d_algorithm = drc.d_algorithm; if(dpk.d_algorithm == 7) dpk.d_algorithm = 5; dpk.d_flags = 257; bool active=true; for(unsigned int n = 3; n < cmds.size(); ++n) { if(pdns_iequals(cmds[n], "ZSK")) dpk.d_flags = 256; else if(pdns_iequals(cmds[n], "KSK")) dpk.d_flags = 257; else if(pdns_iequals(cmds[n], "active")) active = 1; else if(pdns_iequals(cmds[n], "passive") || pdns_iequals(cmds[n], "inactive")) active = 0; else { cerr<<"Unknown key flag '"<0) { algorithm = tmp_algo; } else if(atoi(cmds[n].c_str())) bits = atoi(cmds[n].c_str()); else { cerr<<"Unknown algorithm, key flag or size '"< dpk(DNSCryptoKeyEngine::make(algorithm)); // defaults to RSA for now, could be smart w/algorithm! XXX FIXME if(!bits) { if(algorithm <= 10) bits = keyOrZone ? 2048 : 1024; else { if(algorithm == 12 || algorithm == 13 || algorithm == 250) // ECDSA, GOST, ED25519 bits = 256; else if(algorithm == 14) bits = 384; else { throw runtime_error("Can't guess key size for algoritm "+lexical_cast(algorithm)); } } } dpk->create(bits); dspk.setKey(dpk); dspk.d_algorithm = algorithm; dspk.d_flags = keyOrZone ? 257 : 256; // print key to stdout cout << "Flags: " << dspk.d_flags << endl << dspk.getKey()->convertToISC() << endl; } else { cerr<<"Unknown command '"</dev/null) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign pdns/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign pdns/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): pdns: $(top_builddir)/config.status $(srcdir)/pdns.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ precursor: $(top_builddir)/config.status $(srcdir)/precursor.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list dnsbulktest$(EXEEXT): $(dnsbulktest_OBJECTS) $(dnsbulktest_DEPENDENCIES) @rm -f dnsbulktest$(EXEEXT) $(AM_V_CXXLD)$(dnsbulktest_LINK) $(dnsbulktest_OBJECTS) $(dnsbulktest_LDADD) $(LIBS) dnsdemog$(EXEEXT): $(dnsdemog_OBJECTS) $(dnsdemog_DEPENDENCIES) @rm -f dnsdemog$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(dnsdemog_OBJECTS) $(dnsdemog_LDADD) $(LIBS) dnsgram$(EXEEXT): $(dnsgram_OBJECTS) $(dnsgram_DEPENDENCIES) @rm -f dnsgram$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(dnsgram_OBJECTS) $(dnsgram_LDADD) $(LIBS) dnsreplay$(EXEEXT): $(dnsreplay_OBJECTS) $(dnsreplay_DEPENDENCIES) @rm -f dnsreplay$(EXEEXT) $(AM_V_CXXLD)$(dnsreplay_LINK) $(dnsreplay_OBJECTS) $(dnsreplay_LDADD) $(LIBS) dnsscan$(EXEEXT): $(dnsscan_OBJECTS) $(dnsscan_DEPENDENCIES) @rm -f dnsscan$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(dnsscan_OBJECTS) $(dnsscan_LDADD) $(LIBS) dnsscope$(EXEEXT): $(dnsscope_OBJECTS) $(dnsscope_DEPENDENCIES) @rm -f dnsscope$(EXEEXT) $(AM_V_CXXLD)$(dnsscope_LINK) $(dnsscope_OBJECTS) $(dnsscope_LDADD) $(LIBS) dnstcpbench$(EXEEXT): $(dnstcpbench_OBJECTS) $(dnstcpbench_DEPENDENCIES) @rm -f dnstcpbench$(EXEEXT) $(AM_V_CXXLD)$(dnstcpbench_LINK) $(dnstcpbench_OBJECTS) $(dnstcpbench_LDADD) $(LIBS) dnswasher$(EXEEXT): $(dnswasher_OBJECTS) $(dnswasher_DEPENDENCIES) @rm -f dnswasher$(EXEEXT) $(AM_V_CXXLD)$(dnswasher_LINK) $(dnswasher_OBJECTS) $(dnswasher_LDADD) $(LIBS) notify$(EXEEXT): $(notify_OBJECTS) $(notify_DEPENDENCIES) @rm -f notify$(EXEEXT) $(AM_V_CXXLD)$(notify_LINK) $(notify_OBJECTS) $(notify_LDADD) $(LIBS) nproxy$(EXEEXT): $(nproxy_OBJECTS) $(nproxy_DEPENDENCIES) @rm -f nproxy$(EXEEXT) $(AM_V_CXXLD)$(nproxy_LINK) $(nproxy_OBJECTS) $(nproxy_LDADD) $(LIBS) nsec3dig$(EXEEXT): $(nsec3dig_OBJECTS) $(nsec3dig_DEPENDENCIES) @rm -f nsec3dig$(EXEEXT) $(AM_V_CXXLD)$(nsec3dig_LINK) $(nsec3dig_OBJECTS) $(nsec3dig_LDADD) $(LIBS) pdns_control$(EXEEXT): $(pdns_control_OBJECTS) $(pdns_control_DEPENDENCIES) @rm -f pdns_control$(EXEEXT) $(AM_V_CXXLD)$(pdns_control_LINK) $(pdns_control_OBJECTS) $(pdns_control_LDADD) $(LIBS) pdns_recursor$(EXEEXT): $(pdns_recursor_OBJECTS) $(pdns_recursor_DEPENDENCIES) @rm -f pdns_recursor$(EXEEXT) $(AM_V_CXXLD)$(pdns_recursor_LINK) $(pdns_recursor_OBJECTS) $(pdns_recursor_LDADD) $(LIBS) pdns_server$(EXEEXT): $(pdns_server_OBJECTS) $(pdns_server_DEPENDENCIES) @rm -f pdns_server$(EXEEXT) $(AM_V_CXXLD)$(pdns_server_LINK) $(pdns_server_OBJECTS) $(pdns_server_LDADD) $(LIBS) pdnssec$(EXEEXT): $(pdnssec_OBJECTS) $(pdnssec_DEPENDENCIES) @rm -f pdnssec$(EXEEXT) $(AM_V_CXXLD)$(pdnssec_LINK) $(pdnssec_OBJECTS) $(pdnssec_LDADD) $(LIBS) rec_control$(EXEEXT): $(rec_control_OBJECTS) $(rec_control_DEPENDENCIES) @rm -f rec_control$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(rec_control_OBJECTS) $(rec_control_LDADD) $(LIBS) sdig$(EXEEXT): $(sdig_OBJECTS) $(sdig_DEPENDENCIES) @rm -f sdig$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(sdig_OBJECTS) $(sdig_LDADD) $(LIBS) speedtest$(EXEEXT): $(speedtest_OBJECTS) $(speedtest_DEPENDENCIES) @rm -f speedtest$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speedtest_OBJECTS) $(speedtest_LDADD) $(LIBS) testrunner$(EXEEXT): $(testrunner_OBJECTS) $(testrunner_DEPENDENCIES) @rm -f testrunner$(EXEEXT) $(AM_V_CXXLD)$(testrunner_LINK) $(testrunner_OBJECTS) $(testrunner_LDADD) $(LIBS) toysdig$(EXEEXT): $(toysdig_OBJECTS) $(toysdig_DEPENDENCIES) @rm -f toysdig$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(toysdig_OBJECTS) $(toysdig_LDADD) $(LIBS) tsig-tests$(EXEEXT): $(tsig_tests_OBJECTS) $(tsig_tests_DEPENDENCIES) @rm -f tsig-tests$(EXEEXT) $(AM_V_CXXLD)$(tsig_tests_LINK) $(tsig_tests_OBJECTS) $(tsig_tests_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes_modes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aescrypt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeskey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aestab.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arguments.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base32.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bindbackend2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binddnssec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bindlexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bindparser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/botan110signers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/botan18signers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/botansigners.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_startup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/communicator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cryptoppsigners.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbdnsseckeeper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns_random.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsbackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsbulktest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsdemog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsgram.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnslabeltext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnspacket.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsparser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnspcap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsproxy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsreplay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsscan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsscope.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnssecinfra.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnssecsigner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnstcpbench.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnswasher.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnswriter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynhandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlistener.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynloader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynmessenger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ednssubnet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epollmplexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gsqlbackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htimer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/json.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/json_ws.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lua-auth.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lua-pdns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lua-recursor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lwres.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mastercommunicator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nameserver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notify.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nproxy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsec3dig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsecrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packetcache.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packethandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdns_recursor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdnssec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polarrsakeyinfra.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randomhelper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcpgenerator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rec_channel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rec_channel_rec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rec_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/receiver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recpacketcache.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recursor_cache.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reczones.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/selectmplexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/serialtweaker.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/session.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signingpipe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sillyrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slavecommunicator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speedtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssqlite3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statbag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syncres.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreceiver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base32_cc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base64_cc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dns_random_hh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dnsrecords_cc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-iputils_hh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-md5_hh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-misc_hh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nameserver_cc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-rcpgenerator_cc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testrunner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/toysdig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsig-tests.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ueberbackend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix_semaphore.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix_utility.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webserver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ws.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoneparser-tng.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< aescrypt.o: aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aescrypt.o -MD -MP -MF $(DEPDIR)/aescrypt.Tpo -c -o aescrypt.o `test -f 'aes/aescrypt.c' || echo '$(srcdir)/'`aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aescrypt.Tpo $(DEPDIR)/aescrypt.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aescrypt.c' object='aescrypt.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aescrypt.o `test -f 'aes/aescrypt.c' || echo '$(srcdir)/'`aes/aescrypt.c aescrypt.obj: aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aescrypt.obj -MD -MP -MF $(DEPDIR)/aescrypt.Tpo -c -o aescrypt.obj `if test -f 'aes/aescrypt.c'; then $(CYGPATH_W) 'aes/aescrypt.c'; else $(CYGPATH_W) '$(srcdir)/aes/aescrypt.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aescrypt.Tpo $(DEPDIR)/aescrypt.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aescrypt.c' object='aescrypt.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aescrypt.obj `if test -f 'aes/aescrypt.c'; then $(CYGPATH_W) 'aes/aescrypt.c'; else $(CYGPATH_W) '$(srcdir)/aes/aescrypt.c'; fi` aeskey.o: aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aeskey.o -MD -MP -MF $(DEPDIR)/aeskey.Tpo -c -o aeskey.o `test -f 'aes/aeskey.c' || echo '$(srcdir)/'`aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeskey.Tpo $(DEPDIR)/aeskey.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aeskey.c' object='aeskey.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aeskey.o `test -f 'aes/aeskey.c' || echo '$(srcdir)/'`aes/aeskey.c aeskey.obj: aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aeskey.obj -MD -MP -MF $(DEPDIR)/aeskey.Tpo -c -o aeskey.obj `if test -f 'aes/aeskey.c'; then $(CYGPATH_W) 'aes/aeskey.c'; else $(CYGPATH_W) '$(srcdir)/aes/aeskey.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeskey.Tpo $(DEPDIR)/aeskey.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aeskey.c' object='aeskey.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aeskey.obj `if test -f 'aes/aeskey.c'; then $(CYGPATH_W) 'aes/aeskey.c'; else $(CYGPATH_W) '$(srcdir)/aes/aeskey.c'; fi` aestab.o: aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aestab.o -MD -MP -MF $(DEPDIR)/aestab.Tpo -c -o aestab.o `test -f 'aes/aestab.c' || echo '$(srcdir)/'`aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aestab.Tpo $(DEPDIR)/aestab.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aestab.c' object='aestab.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aestab.o `test -f 'aes/aestab.c' || echo '$(srcdir)/'`aes/aestab.c aestab.obj: aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aestab.obj -MD -MP -MF $(DEPDIR)/aestab.Tpo -c -o aestab.obj `if test -f 'aes/aestab.c'; then $(CYGPATH_W) 'aes/aestab.c'; else $(CYGPATH_W) '$(srcdir)/aes/aestab.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aestab.Tpo $(DEPDIR)/aestab.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aestab.c' object='aestab.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aestab.obj `if test -f 'aes/aestab.c'; then $(CYGPATH_W) 'aes/aestab.c'; else $(CYGPATH_W) '$(srcdir)/aes/aestab.c'; fi` aes_modes.o: aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes_modes.o -MD -MP -MF $(DEPDIR)/aes_modes.Tpo -c -o aes_modes.o `test -f 'aes/aes_modes.c' || echo '$(srcdir)/'`aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aes_modes.Tpo $(DEPDIR)/aes_modes.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aes_modes.c' object='aes_modes.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aes_modes.o `test -f 'aes/aes_modes.c' || echo '$(srcdir)/'`aes/aes_modes.c aes_modes.obj: aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes_modes.obj -MD -MP -MF $(DEPDIR)/aes_modes.Tpo -c -o aes_modes.obj `if test -f 'aes/aes_modes.c'; then $(CYGPATH_W) 'aes/aes_modes.c'; else $(CYGPATH_W) '$(srcdir)/aes/aes_modes.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aes_modes.Tpo $(DEPDIR)/aes_modes.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='aes/aes_modes.c' object='aes_modes.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aes_modes.obj `if test -f 'aes/aes_modes.c'; then $(CYGPATH_W) 'aes/aes_modes.c'; else $(CYGPATH_W) '$(srcdir)/aes/aes_modes.c'; fi` bindlexer.o: backends/bind/bindlexer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bindlexer.o -MD -MP -MF $(DEPDIR)/bindlexer.Tpo -c -o bindlexer.o `test -f 'backends/bind/bindlexer.c' || echo '$(srcdir)/'`backends/bind/bindlexer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindlexer.Tpo $(DEPDIR)/bindlexer.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='backends/bind/bindlexer.c' object='bindlexer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bindlexer.o `test -f 'backends/bind/bindlexer.c' || echo '$(srcdir)/'`backends/bind/bindlexer.c bindlexer.obj: backends/bind/bindlexer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bindlexer.obj -MD -MP -MF $(DEPDIR)/bindlexer.Tpo -c -o bindlexer.obj `if test -f 'backends/bind/bindlexer.c'; then $(CYGPATH_W) 'backends/bind/bindlexer.c'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindlexer.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindlexer.Tpo $(DEPDIR)/bindlexer.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='backends/bind/bindlexer.c' object='bindlexer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bindlexer.obj `if test -f 'backends/bind/bindlexer.c'; then $(CYGPATH_W) 'backends/bind/bindlexer.c'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindlexer.c'; fi` .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< dns_random.o: aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns_random.o -MD -MP -MF $(DEPDIR)/dns_random.Tpo -c -o dns_random.o `test -f 'aes/dns_random.cc' || echo '$(srcdir)/'`aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns_random.Tpo $(DEPDIR)/dns_random.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='aes/dns_random.cc' object='dns_random.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns_random.o `test -f 'aes/dns_random.cc' || echo '$(srcdir)/'`aes/dns_random.cc dns_random.obj: aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns_random.obj -MD -MP -MF $(DEPDIR)/dns_random.Tpo -c -o dns_random.obj `if test -f 'aes/dns_random.cc'; then $(CYGPATH_W) 'aes/dns_random.cc'; else $(CYGPATH_W) '$(srcdir)/aes/dns_random.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns_random.Tpo $(DEPDIR)/dns_random.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='aes/dns_random.cc' object='dns_random.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns_random.obj `if test -f 'aes/dns_random.cc'; then $(CYGPATH_W) 'aes/dns_random.cc'; else $(CYGPATH_W) '$(srcdir)/aes/dns_random.cc'; fi` bindbackend2.o: backends/bind/bindbackend2.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bindbackend2.o -MD -MP -MF $(DEPDIR)/bindbackend2.Tpo -c -o bindbackend2.o `test -f 'backends/bind/bindbackend2.cc' || echo '$(srcdir)/'`backends/bind/bindbackend2.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindbackend2.Tpo $(DEPDIR)/bindbackend2.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/bindbackend2.cc' object='bindbackend2.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bindbackend2.o `test -f 'backends/bind/bindbackend2.cc' || echo '$(srcdir)/'`backends/bind/bindbackend2.cc bindbackend2.obj: backends/bind/bindbackend2.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bindbackend2.obj -MD -MP -MF $(DEPDIR)/bindbackend2.Tpo -c -o bindbackend2.obj `if test -f 'backends/bind/bindbackend2.cc'; then $(CYGPATH_W) 'backends/bind/bindbackend2.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindbackend2.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindbackend2.Tpo $(DEPDIR)/bindbackend2.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/bindbackend2.cc' object='bindbackend2.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bindbackend2.obj `if test -f 'backends/bind/bindbackend2.cc'; then $(CYGPATH_W) 'backends/bind/bindbackend2.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindbackend2.cc'; fi` binddnssec.o: backends/bind/binddnssec.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT binddnssec.o -MD -MP -MF $(DEPDIR)/binddnssec.Tpo -c -o binddnssec.o `test -f 'backends/bind/binddnssec.cc' || echo '$(srcdir)/'`backends/bind/binddnssec.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/binddnssec.Tpo $(DEPDIR)/binddnssec.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/binddnssec.cc' object='binddnssec.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o binddnssec.o `test -f 'backends/bind/binddnssec.cc' || echo '$(srcdir)/'`backends/bind/binddnssec.cc binddnssec.obj: backends/bind/binddnssec.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT binddnssec.obj -MD -MP -MF $(DEPDIR)/binddnssec.Tpo -c -o binddnssec.obj `if test -f 'backends/bind/binddnssec.cc'; then $(CYGPATH_W) 'backends/bind/binddnssec.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/binddnssec.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/binddnssec.Tpo $(DEPDIR)/binddnssec.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/binddnssec.cc' object='binddnssec.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o binddnssec.obj `if test -f 'backends/bind/binddnssec.cc'; then $(CYGPATH_W) 'backends/bind/binddnssec.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/binddnssec.cc'; fi` bindparser.o: backends/bind/bindparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bindparser.o -MD -MP -MF $(DEPDIR)/bindparser.Tpo -c -o bindparser.o `test -f 'backends/bind/bindparser.cc' || echo '$(srcdir)/'`backends/bind/bindparser.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindparser.Tpo $(DEPDIR)/bindparser.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/bindparser.cc' object='bindparser.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bindparser.o `test -f 'backends/bind/bindparser.cc' || echo '$(srcdir)/'`backends/bind/bindparser.cc bindparser.obj: backends/bind/bindparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bindparser.obj -MD -MP -MF $(DEPDIR)/bindparser.Tpo -c -o bindparser.obj `if test -f 'backends/bind/bindparser.cc'; then $(CYGPATH_W) 'backends/bind/bindparser.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindparser.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bindparser.Tpo $(DEPDIR)/bindparser.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/bind/bindparser.cc' object='bindparser.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bindparser.obj `if test -f 'backends/bind/bindparser.cc'; then $(CYGPATH_W) 'backends/bind/bindparser.cc'; else $(CYGPATH_W) '$(srcdir)/backends/bind/bindparser.cc'; fi` gsqlbackend.o: backends/gsql/gsqlbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT gsqlbackend.o -MD -MP -MF $(DEPDIR)/gsqlbackend.Tpo -c -o gsqlbackend.o `test -f 'backends/gsql/gsqlbackend.cc' || echo '$(srcdir)/'`backends/gsql/gsqlbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/gsqlbackend.Tpo $(DEPDIR)/gsqlbackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/gsql/gsqlbackend.cc' object='gsqlbackend.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gsqlbackend.o `test -f 'backends/gsql/gsqlbackend.cc' || echo '$(srcdir)/'`backends/gsql/gsqlbackend.cc gsqlbackend.obj: backends/gsql/gsqlbackend.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT gsqlbackend.obj -MD -MP -MF $(DEPDIR)/gsqlbackend.Tpo -c -o gsqlbackend.obj `if test -f 'backends/gsql/gsqlbackend.cc'; then $(CYGPATH_W) 'backends/gsql/gsqlbackend.cc'; else $(CYGPATH_W) '$(srcdir)/backends/gsql/gsqlbackend.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/gsqlbackend.Tpo $(DEPDIR)/gsqlbackend.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='backends/gsql/gsqlbackend.cc' object='gsqlbackend.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gsqlbackend.obj `if test -f 'backends/gsql/gsqlbackend.cc'; then $(CYGPATH_W) 'backends/gsql/gsqlbackend.cc'; else $(CYGPATH_W) '$(srcdir)/backends/gsql/gsqlbackend.cc'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-sysconfDATA: $(sysconf_DATA) @$(NORMAL_INSTALL) test -z "$(sysconfdir)" || $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \ done uninstall-sysconfDATA: @$(NORMAL_UNINSTALL) @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(sysconfdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sysconfdir)" && rm -f $$files # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ echo "$$grn$$dashes"; \ else \ echo "$$red$$dashes"; \ fi; \ echo "$$banner"; \ test -z "$$skipped" || echo "$$skipped"; \ test -z "$$report" || echo "$$report"; \ echo "$$dashes$$std"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sysconfdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic clean-libtool \ clean-sbinPROGRAMS mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-sbinPROGRAMS \ install-sysconfDATA install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS \ uninstall-sysconfDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ check-am ctags-recursive install install-am install-strip \ tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-TESTS check-am clean clean-binPROGRAMS \ clean-generic clean-libtool clean-sbinPROGRAMS ctags \ ctags-recursive distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \ install-strip install-sysconfDATA installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-recursive uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-sbinPROGRAMS \ uninstall-sysconfDATA dnslabeltext.cc: dnslabeltext.rl ragel dnslabeltext.rl -o dnslabeltext.cc bind-dnssec.schema.sqlite3.sql.h: bind-dnssec.schema.sqlite3.sql ( echo 'static char sqlCreate[] __attribute__((unused))=' ; sed 's/$$/"/g' bind-dnssec.schema.sqlite3.sql | sed 's/^/"/g' ; echo ';' ) > $@ backends/bind/bindlexer.c: cd backends/bind && $(MAKE) bindlexer.c backends/bind/bindparser.cc: cd backends/bind && $(MAKE) bindparser.cc version.o: version_generated.h .PHONY: version_generated.h version_generated.h: echo '#ifndef VERSION_GENERATED_H' > $@ echo '#define VERSION_GENERATED_H' >> $@ echo '#define PDNS_VERSION "$(pdns_version)"' >> $@ echo '#define DIST_HOST "$(dist_host)"' >> $@ echo '#define BUILD_DATE "$(build_date)"' >> $@ echo '#define BUILD_HOST "$(build_host)"' >> $@ echo '#endif //!VERSION_GENERATED_H' >> $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/pdns/backends/0000755000014601777760000000000012165464055016311 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/backends/Makefile.in0000644000014601777760000004476412165464030020366 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = pdns/backends DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = bind all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign pdns/backends/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign pdns/backends/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic clean-libtool \ ctags ctags-recursive distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/pdns/backends/bind/0000755000014601777760000000000012165464055017225 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/backends/bind/bindparser.yy0000644000014601777760000001033412140444471021733 0ustar00jenkinsnogroup00000000000000%{ #include #include #include #include #include #include #include #include "misc.hh" #include "ahuexception.hh" #include "namespaces.hh" #define YYDEBUG 1 extern int yydebug; #include "bindparserclasses.hh" #define YYSTYPE char * #ifndef WIN32 extern "C" { #endif // WIN32 int yyparse(void); int yylex(void); void yyrestart(FILE *); int yywrap() { return 1; } #ifndef WIN32 } #endif // WIN32 extern int yydebug; const char *bind_directory; extern int linenumber; static void yyerror(const char *str) { extern char *current_filename; throw AhuException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str); } extern FILE *yyin; static BindParser *parent; BindDomainInfo s_di; void BindParser::parse(const string &fname) { yydebug=0; yyin=fopen(fname.c_str(),"r"); yyrestart(yyin); if(!yyin) throw AhuException("Unable to open '"+fname+"': "+strerror(errno)); linenumber=1; parent=this; extern char *current_filename; extern char *original_filename; current_filename=original_filename=(char*)fname.c_str(); yyparse(); // cerr<<"Need to parse "<& BindParser::getDomains() { return d_zonedomains; } void BindParser::setVerbose(bool verbose) { d_verbose=verbose; } void BindParser::commit(BindDomainInfo DI) { if(DI.filename[0]!='/') DI.filename=d_dir+"/"+DI.filename; if(d_verbose) cerr<<"Domain "<commit(s_di); s_di.clear(); } | ZONETOK quotedname AWORD zone_block { s_di.name=stripDot($2); free($2); parent->commit(s_di); s_di.clear(); } ; options_command: OPTIONSTOK OBRACE options_commands EBRACE | LOGGINGTOK OBRACE options_commands EBRACE ; acl_command: ACLTOK quotedname acl_block | ACLTOK filename acl_block ; acl_block: OBRACE acls EBRACE ; acls: | acl SEMICOLON acls ; acl: AWORD ; options_commands: | options_command SEMICOLON options_commands ; options_command: command | options_directory_command | also_notify_command ; options_directory_command: DIRECTORYTOK quotedname { parent->setDirectory($2); free($2); } ; also_notify_command: ALSONOTIFYTOK OBRACE also_notify_list EBRACE ; also_notify_list: | also_notify SEMICOLON also_notify_list ; also_notify: AWORD { parent->addAlsoNotify($1); free($1); } ; terms: /* empty */ | terms term ; term: AWORD | block | quotedname ; block: OBRACE commands EBRACE ; zone_block: OBRACE zone_commands EBRACE ; zone_commands: | zone_commands zone_command SEMICOLON ; zone_command: command | zone_file_command | zone_type_command | zone_masters_command | zone_also_notify_command ; zone_masters_command: MASTERTOK OBRACE masters EBRACE ; zone_also_notify_command: ALSONOTIFYTOK OBRACE zone_also_notify_list EBRACE ; zone_also_notify_list: | zone_also_notify SEMICOLON zone_also_notify_list ; zone_also_notify: AWORD { s_di.alsoNotify.insert($1); free($1); } ; masters: /* empty */ | masters master SEMICOLON ; master: AWORD { s_di.masters.push_back($1); free($1); } ; zone_file_command: FILETOK quotedname { // printf("Found a filename: '%s'\n",$2); s_di.filename=$2; free($2); } ; zone_type_command: TYPETOK AWORD { s_di.type=$2; free($2); } ; quotedname: QUOTEDWORD { $$=$1; } ; filename: AWORD ; pdns-3.3/pdns/backends/bind/zone2sql.cc0000644000014601777760000003205612156544154021316 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* accepts a named.conf or a zone as parameter and outputs heaps of sql */ #include #include #include #include #include #include "namespaces.hh" #include "dns.hh" #include "arguments.hh" #include "bindparserclasses.hh" #include "statbag.hh" #include "misc.hh" #include "dnspacket.hh" #include "zoneparser-tng.hh" #include "dnsrecords.hh" #include #include #include #include #include StatBag S; static bool g_doDNSSEC; enum dbmode_t {MYSQL, ORACLE, POSTGRES, SQLITE, MYDNS}; static dbmode_t g_mode; static bool g_intransaction; static int g_numRecords; /* this is an official wart. We don't terminate domains on a . in PowerDNS, which is fine as it goes, except for encoding the root, it would end up as '', which leads to ambiguities in the content field. Therefore, if we encounter the root as a . in a BIND zone, we leave it as a ., and don't replace it by an empty string. Back in 1999 we made the wrong choice. */ static string stripDotContent(const string& content) { if(boost::ends_with(content, " .") || content==".") return content; return stripDot(content); } static string sqlstr(const string &name) { if(g_mode == SQLITE) return "'"+boost::replace_all_copy(name, "'", "''")+"'"; string a; for(string::const_iterator i=name.begin();i!=name.end();++i) { if(*i=='\'' || *i=='\\'){ a+='\\'; a+=*i; } else a+=*i; } if(g_mode == POSTGRES) return "E'"+a+"'"; else return "'"+a+"'"; } static void startNewTransaction() { if(!::arg().mustDo("transactions")) return; if(g_intransaction) { if(g_mode==POSTGRES || g_mode==ORACLE) { cout<<"COMMIT WORK;"< *masters = 0) { if(!::arg().mustDo("slave")) { if(g_mode==POSTGRES || g_mode==MYSQL || g_mode==SQLITE) { cout<<"insert into domains (name,type) values ("<empty()) { BOOST_FOREACH(const string& mstr, *masters) { mstrs.append(mstr); mstrs.append(1, ' '); } } if (mstrs.empty()) cout<<"insert into domains (name,type) values ("< parts; stringtok(parts, content); cout<<"INSERT INTO soa(origin, ns, mbox, serial, refresh, retry, expire, minimum, ttl) VALUES("<< sqlstr(toLower(zoneNameDot))<<", "<= 3 std::ios_base::sync_with_stdio(false); #endif ::arg().setSwitch("gpgsql","Output in format suitable for default gpgsqlbackend")="no"; ::arg().setSwitch("gmysql","Output in format suitable for default gmysqlbackend")="no"; ::arg().setSwitch("mydns","Output in format suitable for default mydnsbackend")="no"; ::arg().setSwitch("oracle","Output in format suitable for the oraclebackend")="no"; ::arg().setSwitch("gsqlite","Output in format suitable for default gsqlitebackend")="no"; ::arg().setSwitch("verbose","Verbose comments on operation")="no"; ::arg().setSwitch("dnssec","Add DNSSEC related data")="no"; ::arg().setSwitch("slave","Keep BIND slaves as slaves. Only works with named-conf.")="no"; ::arg().setSwitch("transactions","If target SQL supports it, use transactions")="no"; ::arg().setSwitch("on-error-resume-next","Continue after errors")="no"; ::arg().set("zone","Zonefile to parse")=""; ::arg().set("zone-name","Specify an $ORIGIN in case it is not present")=""; ::arg().set("named-conf","Bind 8/9 named.conf to parse")=""; ::arg().set("soa-minimum-ttl","Do not change")="0"; ::arg().set("soa-refresh-default","Do not change")="0"; ::arg().set("soa-retry-default","Do not change")="0"; ::arg().set("soa-expire-default","Do not change")="0"; ::arg().setCmd("help","Provide a helpful message"); S.declare("logmessages"); string namedfile=""; string zonefile=""; ::arg().parse(argc, argv); if(argc<2 || ::arg().mustDo("help")) { cerr<<"syntax:"< domains=BP.getDomains(); struct stat st; for(vector::iterator i=domains.begin(); i!=domains.end(); ++i) { if(stat(i->filename.c_str(), &st) == 0) { i->d_dev = st.st_dev; i->d_ino = st.st_ino; } } sort(domains.begin(), domains.end()); // put stuff in inode order int numdomains=domains.size(); int tick=numdomains/100; for(vector::const_iterator i=domains.begin(); i!=domains.end(); ++i) { if(i->type!="master" && i->type!="slave") { cerr<<" Warning! Skipping '"<type<<"' zone '"<name<<"'"<name, &(i->masters)); ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); DNSResourceRecord rr; while(zpt.get(rr)) emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); num_domainsdone++; } catch(std::exception &ae) { if(!::arg().mustDo("on-error-resume-next")) throw; else cerr<filename<<")\033\133\113"; } cerr<<"\r100% done\033\133\113"< #include "config.h" #include "pdns/arguments.hh" #ifndef HAVE_SQLITE3 void Bind2Backend::setupDNSSEC() { if(!getArg("dnssec-db").empty()) throw runtime_error("bind-dnssec-db requires building PowerDNS with SQLite3"); } void Bind2Backend::createDNSSECDB(const string& fname) {} bool Bind2Backend::doesDNSSEC() { return false; } bool Bind2Backend::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p) { return false; } bool Bind2Backend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { return false; } bool Bind2Backend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { return false; } bool Bind2Backend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { return false; } bool Bind2Backend::removeDomainKey(const string& name, unsigned int id) { return false; } int Bind2Backend::addDomainKey(const string& name, const KeyData& key) { return false; } bool Bind2Backend::activateDomainKey(const string& name, unsigned int id) { return false; } bool Bind2Backend::deactivateDomainKey(const string& name, unsigned int id) { return false; } bool Bind2Backend::getTSIGKey(const string& name, string* algorithm, string* content) { return false; } #else #include "pdns/ssqlite3.hh" void Bind2Backend::setupDNSSEC() { // cerr<<"Settting up dnssec db.. "<(new SSQLite3(getArg("dnssec-db"))); } catch(SSqlException& se) { // this error is meant to kill the server dead - it makes no sense to continue.. throw runtime_error("Error opening DNSSEC database in BIND backend: "+se.txtReason()); } d_dnssecdb->setLog(::arg().mustDo("query-logging")); } void Bind2Backend::createDNSSECDB(const string& fname) { try { SSQLite3 db(fname, true); // create=ok vector statements; stringtok(statements, sqlCreate, ";"); BOOST_FOREACH(const string& statement, statements) db.doCommand(statement); } catch(SSqlException& se) { throw AhuException("Error creating database in BIND backend: "+se.txtReason()); } } bool Bind2Backend::doesDNSSEC() { return true; } bool Bind2Backend::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p) { string value; vector meta; getDomainMetadata(zname, "NSEC3PARAM", meta); if(!meta.empty()) value=*meta.begin(); if(value.empty()) { // "no NSEC3" return false; } if(ns3p) { NSEC3PARAMRecordContent* tmp=dynamic_cast(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value)); *ns3p = *tmp; delete tmp; } return true; } bool Bind2Backend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { if(!d_dnssecdb) return false; // cerr<<"Asked to get metadata for zone '"<doQuery((fmt % d_dnssecdb->escape(name) % d_dnssecdb->escape(kind)).str()); vector row; while(d_dnssecdb->getRow(row)) { meta.push_back(row[0]); } } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { if(!d_dnssecdb) return false; boost::format fmt("delete from domainmetadata where domain='%s' and kind='%s'"); boost::format fmt2("insert into domainmetadata (domain, kind, content) values ('%s','%s', '%s')"); try { d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % d_dnssecdb->escape(kind)).str()); if(!meta.empty()) d_dnssecdb->doCommand((fmt2 % d_dnssecdb->escape(name) % d_dnssecdb->escape(kind) % d_dnssecdb->escape(meta.begin()->c_str())).str()); } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { // cerr<<"Asked to get keys for zone '"<doQuery((fmt % d_dnssecdb->escape(name)).str()); KeyData kd; vector row; while(d_dnssecdb->getRow(row)) { kd.id = atoi(row[0].c_str()); kd.flags = atoi(row[1].c_str()); kd.active = atoi(row[2].c_str()); kd.content = row[3]; keys.push_back(kd); } } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::removeDomainKey(const string& name, unsigned int id) { if(!d_dnssecdb) return false; cerr<<"Asked to remove key "<doCommand((fmt % d_dnssecdb->escape(name) % id).str()); } catch(SSqlException& se) { cerr<doCommand((fmt % d_dnssecdb->escape(name) % key.flags % key.active % d_dnssecdb->escape(key.content)).str()); } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::activateDomainKey(const string& name, unsigned int id) { // cerr<<"Asked to activate key "<doCommand((fmt % d_dnssecdb->escape(name) % id).str()); } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::deactivateDomainKey(const string& name, unsigned int id) { // cerr<<"Asked to deactivate key "<doCommand((fmt % d_dnssecdb->escape(name) % id).str()); } catch(SSqlException& se) { throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } bool Bind2Backend::getTSIGKey(const string& name, string* algorithm, string* content) { if(!d_dnssecdb) return false; boost::format fmt("select algorithm, secret from tsigkeys where name='%s'"); try { d_dnssecdb->doQuery( (fmt % d_dnssecdb->escape(name)).str()); } catch (SSqlException &e) { throw AhuException("BindBackend unable to retrieve named TSIG key: "+e.txtReason()); } SSql::row_t row; content->clear(); while(d_dnssecdb->getRow(row)) { *algorithm = row[0]; *content=row[1]; } return !content->empty(); } #endif pdns-3.3/pdns/backends/bind/bindparser.cc0000644000014601777760000014276412165464054021702 0ustar00jenkinsnogroup00000000000000 /* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 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, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Using locations. */ #define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ /* Line 189 of yacc.c */ #line 1 "bindparser.yy" #include #include #include #include #include #include #include #include "misc.hh" #include "ahuexception.hh" #include "namespaces.hh" #define YYDEBUG 1 extern int yydebug; #include "bindparserclasses.hh" #define YYSTYPE char * #ifndef WIN32 extern "C" { #endif // WIN32 int yyparse(void); int yylex(void); void yyrestart(FILE *); int yywrap() { return 1; } #ifndef WIN32 } #endif // WIN32 extern int yydebug; const char *bind_directory; extern int linenumber; static void yyerror(const char *str) { extern char *current_filename; throw AhuException("Error in bind configuration '"+string(current_filename)+"' on line "+itoa(linenumber)+": "+str); } extern FILE *yyin; static BindParser *parent; BindDomainInfo s_di; void BindParser::parse(const string &fname) { yydebug=0; yyin=fopen(fname.c_str(),"r"); yyrestart(yyin); if(!yyin) throw AhuException("Unable to open '"+fname+"': "+strerror(errno)); linenumber=1; parent=this; extern char *current_filename; extern char *original_filename; current_filename=original_filename=(char*)fname.c_str(); yyparse(); // cerr<<"Need to parse "<& BindParser::getDomains() { return d_zonedomains; } void BindParser::setVerbose(bool verbose) { d_verbose=verbose; } void BindParser::commit(BindDomainInfo DI) { if(DI.filename[0]!='/') DI.filename=d_dir+"/"+DI.filename; if(d_verbose) cerr<<"Domain "< /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 78 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 18 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 31 /* YYNRULES -- Number of rules. */ #define YYNRULES 56 /* YYNRULES -- Number of states. */ #define YYNSTATES 94 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 272 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 8, 10, 12, 14, 16, 17, 21, 23, 27, 32, 37, 42, 46, 50, 54, 55, 59, 61, 62, 66, 68, 70, 72, 75, 80, 81, 85, 87, 88, 91, 93, 95, 97, 101, 105, 106, 110, 112, 114, 116, 118, 120, 125, 130, 131, 135, 137, 138, 142, 144, 147, 150, 152 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 19, 0, -1, -1, 19, 20, 7, -1, 22, -1, 25, -1, 23, -1, 24, -1, -1, 21, 22, 7, -1, 34, -1, 8, 47, 37, -1, 8, 47, 3, 37, -1, 10, 5, 29, 6, -1, 13, 5, 29, 6, -1, 12, 47, 26, -1, 12, 48, 26, -1, 5, 27, 6, -1, -1, 28, 7, 27, -1, 3, -1, -1, 24, 7, 29, -1, 22, -1, 30, -1, 31, -1, 11, 47, -1, 17, 5, 32, 6, -1, -1, 33, 7, 32, -1, 3, -1, -1, 34, 35, -1, 3, -1, 36, -1, 47, -1, 5, 21, 6, -1, 5, 38, 6, -1, -1, 38, 23, 7, -1, 22, -1, 45, -1, 46, -1, 39, -1, 40, -1, 16, 5, 43, 6, -1, 17, 5, 41, 6, -1, -1, 42, 7, 41, -1, 3, -1, -1, 43, 44, 7, -1, 3, -1, 9, 47, -1, 15, 3, -1, 4, -1, 3, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 113, 113, 115, 118, 118, 118, 118, 121, 123, 127, 131, 139, 150, 152, 157, 157, 160, 163, 165, 169, 172, 174, 177, 177, 177, 180, 187, 190, 192, 195, 201, 203, 206, 206, 206, 209, 213, 216, 218, 221, 221, 221, 221, 221, 224, 227, 230, 232, 235, 242, 244, 247, 255, 264, 273, 279 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "AWORD", "QUOTEDWORD", "OBRACE", "EBRACE", "SEMICOLON", "ZONETOK", "FILETOK", "OPTIONSTOK", "DIRECTORYTOK", "ACLTOK", "LOGGINGTOK", "CLASSTOK", "TYPETOK", "MASTERTOK", "ALSONOTIFYTOK", "$accept", "root_commands", "root_command", "commands", "command", "zone_command", "options_command", "acl_command", "acl_block", "acls", "acl", "options_commands", "options_directory_command", "also_notify_command", "also_notify_list", "also_notify", "terms", "term", "block", "zone_block", "zone_commands", "zone_masters_command", "zone_also_notify_command", "zone_also_notify_list", "zone_also_notify", "masters", "master", "zone_file_command", "zone_type_command", "quotedname", "filename", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 18, 19, 19, 20, 20, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 24, 24, 24, 30, 31, 32, 32, 33, 34, 34, 35, 35, 35, 36, 37, 38, 38, 23, 23, 23, 23, 23, 39, 40, 41, 41, 42, 43, 43, 44, 45, 46, 47, 48 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 3, 1, 1, 1, 1, 0, 3, 1, 3, 4, 4, 4, 3, 3, 3, 0, 3, 1, 0, 3, 1, 1, 1, 2, 4, 0, 3, 1, 0, 2, 1, 1, 1, 3, 3, 0, 3, 1, 1, 1, 1, 1, 4, 4, 0, 3, 1, 0, 3, 1, 2, 2, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 31, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 5, 24, 25, 10, 43, 44, 41, 42, 55, 0, 53, 31, 26, 56, 0, 0, 31, 54, 50, 28, 3, 33, 8, 32, 34, 35, 0, 38, 11, 0, 23, 0, 0, 18, 15, 16, 0, 0, 30, 0, 0, 0, 0, 31, 12, 31, 28, 31, 13, 20, 0, 0, 14, 52, 45, 0, 27, 28, 46, 47, 36, 0, 37, 0, 40, 0, 30, 22, 17, 18, 51, 29, 49, 48, 9, 47, 39, 19 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 1, 12, 59, 46, 14, 47, 16, 50, 66, 67, 48, 17, 18, 55, 56, 19, 39, 40, 44, 61, 20, 21, 57, 58, 53, 71, 22, 23, 25, 31 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -32 static const yytype_int8 yypact[] = { -32, 2, -32, 5, 5, 11, 5, 34, 16, 19, 26, 37, -3, -32, -32, -32, -32, -32, -32, 25, -32, -32, -32, -32, -32, 20, -32, 30, -32, -32, 39, 39, 30, -32, -32, 36, -32, -32, -32, -32, -32, -32, 40, -32, -32, 41, -32, 42, 44, 45, -32, -32, 46, 0, -32, 47, 48, 50, 52, 51, -32, 18, 58, 30, -32, -32, 56, 57, -32, -32, -32, 59, -32, 58, -32, 60, -32, 61, -32, 49, -32, 62, -32, -32, -32, 45, -32, -32, -32, -32, -32, 60, -32, -32 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -32, -32, -32, -32, -1, -10, 64, -32, 43, -18, -32, -31, -32, -32, -2, -32, -32, -32, -32, 28, -32, -32, -32, 3, -32, -32, -32, -32, -32, 1, -32 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -22 static const yytype_int8 yytable[] = { 13, 52, 2, 69, 36, 26, 70, 28, 30, 24, 3, 4, 5, 6, 7, 8, 27, 9, 10, 11, 41, 32, 33, 42, 78, 43, 3, 4, 37, 24, 38, 34, 83, 9, 10, 79, -21, 29, 24, 54, 5, 6, 35, 8, 49, 43, 62, 45, 65, 63, 64, 81, 68, 72, 91, 73, 74, 76, 77, 75, 80, 82, 84, 88, 85, 15, 86, 93, 90, 92, 60, 87, 0, 0, 51, 0, 0, 0, 89 }; static const yytype_int8 yycheck[] = { 1, 32, 0, 3, 7, 4, 6, 6, 7, 4, 8, 9, 10, 11, 12, 13, 5, 15, 16, 17, 19, 5, 3, 3, 6, 5, 8, 9, 3, 4, 5, 5, 63, 15, 16, 17, 6, 3, 4, 3, 10, 11, 5, 13, 5, 5, 5, 17, 3, 7, 6, 61, 6, 6, 5, 7, 6, 6, 59, 7, 61, 3, 6, 3, 7, 1, 7, 85, 7, 7, 42, 73, -1, -1, 31, -1, -1, -1, 75 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 19, 0, 8, 9, 10, 11, 12, 13, 15, 16, 17, 20, 22, 23, 24, 25, 30, 31, 34, 39, 40, 45, 46, 4, 47, 47, 5, 47, 3, 47, 48, 5, 3, 5, 5, 7, 3, 5, 35, 36, 47, 3, 5, 37, 17, 22, 24, 29, 5, 26, 26, 29, 43, 3, 32, 33, 41, 42, 21, 37, 38, 5, 7, 6, 3, 27, 28, 6, 3, 6, 44, 6, 7, 6, 7, 6, 22, 6, 17, 22, 23, 3, 29, 6, 7, 7, 32, 3, 41, 7, 5, 7, 27 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void yy_reduce_print (yyvsp, yyrule) YYSTYPE *yyvsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yymsg, yytype, yyvaluep) const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*-------------------------. | yyparse or yypush_parse. | `-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 11: /* Line 1455 of yacc.c */ #line 132 "bindparser.yy" { s_di.name=stripDot((yyvsp[(2) - (3)])); free((yyvsp[(2) - (3)])); parent->commit(s_di); s_di.clear(); } break; case 12: /* Line 1455 of yacc.c */ #line 140 "bindparser.yy" { s_di.name=stripDot((yyvsp[(2) - (4)])); free((yyvsp[(2) - (4)])); parent->commit(s_di); s_di.clear(); } break; case 26: /* Line 1455 of yacc.c */ #line 181 "bindparser.yy" { parent->setDirectory((yyvsp[(2) - (2)])); free((yyvsp[(2) - (2)])); } break; case 30: /* Line 1455 of yacc.c */ #line 196 "bindparser.yy" { parent->addAlsoNotify((yyvsp[(1) - (1)])); free((yyvsp[(1) - (1)])); } break; case 49: /* Line 1455 of yacc.c */ #line 236 "bindparser.yy" { s_di.alsoNotify.insert((yyvsp[(1) - (1)])); free((yyvsp[(1) - (1)])); } break; case 52: /* Line 1455 of yacc.c */ #line 248 "bindparser.yy" { s_di.masters.push_back((yyvsp[(1) - (1)])); free((yyvsp[(1) - (1)])); } break; case 53: /* Line 1455 of yacc.c */ #line 256 "bindparser.yy" { // printf("Found a filename: '%s'\n",$2); s_di.filename=(yyvsp[(2) - (2)]); free((yyvsp[(2) - (2)])); } break; case 54: /* Line 1455 of yacc.c */ #line 265 "bindparser.yy" { s_di.type=(yyvsp[(2) - (2)]); free((yyvsp[(2) - (2)])); } break; case 55: /* Line 1455 of yacc.c */ #line 274 "bindparser.yy" { (yyval)=(yyvsp[(1) - (1)]); } break; /* Line 1455 of yacc.c */ #line 1622 "bindparser.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } pdns-3.3/pdns/backends/bind/bindbackend2.cc0000644000014601777760000012455212155357305022051 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dnsseckeeper.hh" #include "dnssecinfra.hh" #include "base32.hh" #include "namespaces.hh" #include "dns.hh" #include "dnsbackend.hh" #include "bindbackend2.hh" #include "dnspacket.hh" #include "zoneparser-tng.hh" #include "bindparserclasses.hh" #include "logger.hh" #include "arguments.hh" #include "qtype.hh" #include "misc.hh" #include "dynlistener.hh" #include "lock.hh" #include "namespaces.hh" /** new scheme of things: we have zone-id map a zone-id has a vector of DNSResourceRecords on start of query, we find the best zone to answer from */ // this map contains BB2DomainInfo structs, each of which contains a *pointer* to domain data shared_ptr Bind2Backend::s_state; /* the model is that all our state hides in s_state. This State instance consists of the id_zone_map, which contains all our zone information, indexed by id. Then there is the name_id_map, which allows us to map a query to a zone id. The s_state is never written to, and it is a reference counted shared_ptr. Any function which needs to access the state should do so by making a shared_ptr copy of it, and do all its work on that copy. When I said s_state is never written to, I lied. No elements are ever added to it, or removed from it. Its values however may be changed, but not the keys. When it is necessary to change the State, a deep copy is made, which is changed. Afterwards, the s_state pointer is made to point to the new State. Anybody who is currently accessing the original holds a reference counted handle (shared_ptr) to it, which means it will stay around To save memory, we hold the records as a shared_ptr as well. Changes made to s_state directly should take the s_state_lock, so as to prevent writing to a stale copy. */ int Bind2Backend::s_first=1; pthread_mutex_t Bind2Backend::s_startup_lock=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t Bind2Backend::s_state_lock=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t Bind2Backend::s_state_swap_lock=PTHREAD_MUTEX_INITIALIZER; string Bind2Backend::s_binddirectory; /* when a query comes in, we find the most appropriate zone and answer from that */ BB2DomainInfo::BB2DomainInfo() { d_loaded=false; d_lastcheck=0; d_checknow=false; d_status="Unknown"; } void BB2DomainInfo::setCheckInterval(time_t seconds) { d_checkinterval=seconds; } bool BB2DomainInfo::current() { if(d_checknow) return false; if(!d_checkinterval) return true; if(time(0) - d_lastcheck < d_checkinterval) return true; if(d_filename.empty()) return true; return (getCtime()==d_ctime); } time_t BB2DomainInfo::getCtime() { struct stat buf; if(d_filename.empty() || stat(d_filename.c_str(),&buf)<0) return 0; d_lastcheck=time(0); return buf.st_ctime; } void BB2DomainInfo::setCtime() { struct stat buf; if(stat(d_filename.c_str(),&buf)<0) return; d_ctime=buf.st_ctime; } void Bind2Backend::setNotified(uint32_t id, uint32_t serial) { Lock l(&s_state_lock); s_state->id_zone_map[id].d_lastnotified=serial; } void Bind2Backend::setFresh(uint32_t domain_id) { Lock l(&s_state_lock); s_state->id_zone_map[domain_id].d_lastcheck=time(0); } shared_ptr Bind2Backend::getState() { shared_ptr ret; { Lock l(&s_state_swap_lock); ret = s_state; // is only read from } return ret; } bool Bind2Backend::startTransaction(const string &qname, int id) { if(id < 0) { d_transaction_tmpname.clear(); d_transaction_id=id; return true; } shared_ptr state = getState(); const BB2DomainInfo &bbd=state->id_zone_map[d_transaction_id=id]; d_transaction_tmpname=bbd.d_filename+"."+itoa(random()); d_of=new ofstream(d_transaction_tmpname.c_str()); if(!*d_of) { throw DBException("Unable to open temporary zonefile '"+d_transaction_tmpname+"': "+stringerror()); unlink(d_transaction_tmpname.c_str()); delete d_of; d_of=0; } *d_of<<"; Written by PowerDNS, don't edit!"< state = getState(); // this might fail if s_state was cycled during the AXFR if(rename(d_transaction_tmpname.c_str(), state->id_zone_map[d_transaction_id].d_filename.c_str())<0) throw DBException("Unable to commit (rename to: '" + state->id_zone_map[d_transaction_id].d_filename+"') AXFRed zone: "+stringerror()); queueReload(&state->id_zone_map[d_transaction_id]); d_transaction_id=0; return true; } bool Bind2Backend::abortTransaction() { if(d_transaction_id >= 0) { delete d_of; d_of=0; unlink(d_transaction_tmpname.c_str()); d_transaction_id=0; } return true; } bool Bind2Backend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) { #if 0 const shared_ptr state = getState(); BB2DomainInfo& bbd = state->id_zone_map[domain_id]; string sqname; if(bbd.d_name.empty()) sqname=qname; else if(strcasecmp(qname.c_str(), bbd.d_name.c_str())) sqname=qname.substr(0,qname.size() - bbd.d_name.length()-1); // strip domain name sqname = labelReverse(sqname); if(!auth) d_authDelayed[sqname] = auth; #endif return false; } bool Bind2Backend::feedRecord(const DNSResourceRecord &r, string *ordername) { string qname=r.qname; const shared_ptr state = getState(); string domain = state->id_zone_map[d_transaction_id].d_name; if(!stripDomainSuffix(&qname,domain)) throw DBException("out-of-zone data '"+qname+"' during AXFR of zone '"+domain+"'"); string content=r.content; // SOA needs stripping too! XXX FIXME - also, this should not be here I think switch(r.qtype.getCode()) { case QType::MX: if(!stripDomainSuffix(&content, domain)) content+="."; *d_of< *changedDomains) { SOAData soadata; shared_ptr state = getState(); for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { if(!i->second.d_masters.empty() && this->alsoNotify.empty() && i->second.d_also_notify.empty()) continue; soadata.serial=0; try { this->getSOA(i->second.d_name, soadata); // we might not *have* a SOA yet, but this might trigger a load of it } catch(...){} DomainInfo di; di.id=i->first; di.serial=soadata.serial; di.zone=i->second.d_name; di.last_check=i->second.d_lastcheck; di.backend=this; di.kind=DomainInfo::Master; if(!i->second.d_lastnotified) { // don't do notification storm on startup Lock l(&s_state_lock); s_state->id_zone_map[i->first].d_lastnotified=soadata.serial; } else if(soadata.serial!=i->second.d_lastnotified) changedDomains->push_back(di); } } void Bind2Backend::getAllDomains(vector *domains) { SOAData soadata; shared_ptr state = getState(); for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { soadata.db=(DNSBackend *)-1; // makes getSOA() skip the cache. this->getSOA(i->second.d_name, soadata); DomainInfo di; di.id=i->first; di.serial=soadata.serial; di.zone=i->second.d_name; di.last_check=i->second.d_lastcheck; di.backend=this; di.kind=i->second.d_masters.empty() ? DomainInfo::Master : DomainInfo::Slave; //TODO: what about Native? domains->push_back(di); } } void Bind2Backend::getUnfreshSlaveInfos(vector *unfreshDomains) { shared_ptr state = getState(); for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { if(i->second.d_masters.empty()) continue; DomainInfo sd; sd.id=i->first; sd.zone=i->second.d_name; sd.masters=i->second.d_masters; sd.last_check=i->second.d_lastcheck; sd.backend=this; sd.kind=DomainInfo::Slave; SOAData soadata; soadata.refresh=0; soadata.serial=0; soadata.db=(DNSBackend *)-1; // not sure if this is useful, inhibits any caches that might be around try { getSOA(i->second.d_name,soadata); // we might not *have* a SOA yet } catch(...){} sd.serial=soadata.serial; if(sd.last_check+soadata.refresh<(unsigned int)time(0)) unfreshDomains->push_back(sd); } } bool Bind2Backend::getDomainInfo(const string &domain, DomainInfo &di) { shared_ptr state = getState(); for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { // why is this a linear scan?? if(pdns_iequals(i->second.d_name,domain)) { di.id=i->first; di.zone=domain; di.masters=i->second.d_masters; di.last_check=i->second.d_lastcheck; di.backend=this; di.kind=i->second.d_masters.empty() ? DomainInfo::Master : DomainInfo::Slave; di.serial=0; try { SOAData sd; sd.serial=0; getSOA(i->second.d_name,sd); // we might not *have* a SOA yet di.serial=sd.serial; } catch(...){} return true; } } return false; } void Bind2Backend::alsoNotifies(const string &domain, set *ips) { shared_ptr state = getState(); // combine global list with local list for(set::iterator i = this->alsoNotify.begin(); i != this->alsoNotify.end(); i++) { (*ips).insert(*i); } for(id_zone_map_t::const_iterator i = state->id_zone_map.begin(); i != state->id_zone_map.end() ; ++i) { if(i->second.d_name==domain) { for(set::iterator it = i->second.d_also_notify.begin(); it != i->second.d_also_notify.end(); it++) { (*ips).insert(*it); } return; } } } //! lowercase, strip trailing . static string canonic(string ret) { string::iterator i; for(i=ret.begin(); i!=ret.end(); ++i) *i=tolower(*i); if(*(i-1)=='.') ret.resize(i-ret.begin()-1); return ret; } /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedence matching This function adds a record to a domain with a certain id. Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */ void Bind2Backend::insert(shared_ptr stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed) { BB2DomainInfo bb2 = stage->id_zone_map[id]; Bind2DNSRecord bdr; recordstorage_t& records=*bb2.d_records; bdr.qname=toLower(canonic(qnameu)); if(bb2.d_name.empty()) ; else if(bdr.qname==toLower(bb2.d_name)) bdr.qname.clear(); else if(bdr.qname.length() > bb2.d_name.length() && dottedEndsOn(bdr.qname, bb2.d_name)) bdr.qname.resize(bdr.qname.length() - (bb2.d_name.length() + 1)); else throw AhuException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'"); bdr.qname.swap(bdr.qname); if(!records.empty() && bdr.qname==boost::prior(records.end())->qname) bdr.qname=boost::prior(records.end())->qname; // cerr<<"Before reverse: '"<&parts, Utility::pid_t ppid) { shared_ptr state = getState(); ostringstream ret; for(vector::const_iterator i=parts.begin()+1;iname_id_map.count(*i)) { BB2DomainInfo& bbd=state->id_zone_map[state->name_id_map[*i]]; Bind2Backend bb2; bb2.queueReload(&bbd); ret<< *i << ": "<< (bbd.d_loaded ? "": "[rejected]") <<"\t"<&parts, Utility::pid_t ppid) { ostringstream ret; shared_ptr state = getState(); if(parts.size() > 1) { for(vector::const_iterator i=parts.begin()+1;iname_id_map.count(*i)) { BB2DomainInfo& bbd=state->id_zone_map[state->name_id_map[*i]]; // XXX s_name_id_map needs trick as well ret<< *i << ": "<< (bbd.d_loaded ? "": "[rejected]") <<"\t"<id_zone_map.begin(); i!=state->id_zone_map.end(); ++i) ret<< i->second.d_name << ": "<< (i->second.d_loaded ? "": "[rejected]") <<"\t"<second.d_status<<"\n"; if(ret.str().empty()) ret<<"no domains passed"; return ret.str(); } string Bind2Backend::DLListRejectsHandler(const vector&parts, Utility::pid_t ppid) { shared_ptr state = getState(); ostringstream ret; for(id_zone_map_t::iterator j = state->id_zone_map.begin(); j != state->id_zone_map.end(); ++j) if(!j->second.d_loaded) ret<second.d_name<<"\t"<second.d_status<(new State); if(loadZones) { loadConfig(); s_first=0; } extern DynListener *dl; dl->registerFunc("BIND-RELOAD-NOW", &DLReloadNowHandler, "bindbackend: reload domains", ""); dl->registerFunc("BIND-DOMAIN-STATUS", &DLDomStatusHandler, "bindbackend: list status of all domains", "[domains]"); dl->registerFunc("BIND-LIST-REJECTS", &DLListRejectsHandler, "bindbackend: list rejected domains"); } Bind2Backend::~Bind2Backend() { } void Bind2Backend::rediscover(string *status) { loadConfig(status); } void Bind2Backend::reload() { Lock l(&s_state_lock); for(id_zone_map_t::iterator i = s_state->id_zone_map.begin(); i != s_state->id_zone_map.end(); ++i) i->second.d_checknow=true; } void Bind2Backend::fixupAuth(shared_ptr records) { pair range; string sqname; recordstorage_t nssets; BOOST_FOREACH(const Bind2DNSRecord& bdr, *records) { if(bdr.qtype==QType::NS) nssets.insert(bdr); } BOOST_FOREACH(const Bind2DNSRecord& bdr, *records) { bdr.auth=true; if(bdr.qtype == QType::DS) // as are delegation signer records continue; sqname = labelReverse(bdr.qname); do { if(sqname.empty()) // this is auth of course! continue; if(bdr.qtype == QType::NS || nssets.count(sqname)) { // NS records which are not apex are unauth by definition bdr.auth=false; } } while(chopOff(sqname)); } } void Bind2Backend::doEmptyNonTerminals(shared_ptr stage, int id, bool nsec3zone, NSEC3PARAMRecordContent ns3pr) { BB2DomainInfo bb2 = stage->id_zone_map[id]; bool doent=true; set qnames, nonterm; string qname, shorter, hashed; uint32_t maxent = ::arg().asNum("max-ent-entries"); BOOST_FOREACH(const Bind2DNSRecord& bdr, *bb2.d_records) if (bdr.auth && (bdr.qtype != QType::RRSIG)) qnames.insert(labelReverse(bdr.qname)); BOOST_FOREACH(const string& qname, qnames) { shorter=qname; while(chopOff(shorter)) { if(!qnames.count(shorter) && !nonterm.count(shorter)) { if(!(maxent)) { L< staging = shared_ptr(new State); if(!getArg("config").empty()) { BindParser BP; try { BP.parse(getArg("config")); } catch(AhuException &ae) { L< domains=BP.getDomains(); this->alsoNotify = BP.getAlsoNotify(); s_binddirectory=BP.getDirectory(); // ZP.setDirectory(d_binddirectory); L<::iterator i=domains.begin(); i!=domains.end(); ++i) { if(stat(i->filename.c_str(), &st) == 0) { i->d_dev = st.st_dev; i->d_ino = st.st_ino; } } sort(domains.begin(), domains.end()); // put stuff in inode order for(vector::const_iterator i=domains.begin(); i!=domains.end(); ++i) { if(i->type!="master" && i->type!="slave") { L<type<<"' zone '"<name<<"'"<name_id_map.count(i->name)) { // is it fully new? bbd=&staging->id_zone_map[domain_id]; bbd->d_id=domain_id++; // this isn't necessary, we do this on the actual load // bbd->d_records=shared_ptr (new recordstorage_t); bbd->setCheckInterval(getArgAsNum("check-interval")); bbd->d_lastnotified=0; bbd->d_loaded=false; } else { // no, we knew about it already staging->id_zone_map[s_state->name_id_map[i->name]] = s_state->id_zone_map[s_state->name_id_map[i->name]]; // these should all be read-only on s_state bbd = &staging->id_zone_map[s_state->name_id_map[i->name]]; } staging->name_id_map[i->name]=bbd->d_id; // fill out name -> id map // overwrite what we knew about the domain bbd->d_name=toLower(canonic(i->name)); bool filenameChanged = (bbd->d_filename!=i->filename); bbd->d_filename=i->filename; bbd->d_masters=i->masters; bbd->d_also_notify=i->alsoNotify; if(filenameChanged || !bbd->d_loaded || !bbd->current()) { L<name<<"' from file '"<filename<<"'"<name, &ns3pr); try { // we need to allocate a new vector so we don't kill the original, which is still in use! bbd->d_records=shared_ptr (new recordstorage_t()); ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); DNSResourceRecord rr; string hashed; while(zpt.get(rr)) { // FIXME this code is duplicate if(rr.qtype.getCode() == QType::NSEC || rr.qtype.getCode() == QType::NSEC3) continue; // we synthesise NSECs on demand if(nsec3zone) { if(rr.qtype.getCode() != QType::NSEC3 && rr.qtype.getCode() != QType::RRSIG) hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); else hashed=""; } insert(staging, bbd->d_id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed); } // sort(staging->id_zone_map[bbd->d_id].d_records->begin(), staging->id_zone_map[bbd->d_id].d_records->end()); fixupAuth(staging->id_zone_map[bbd->d_id].d_records); doEmptyNonTerminals(staging, bbd->d_id, nsec3zone, ns3pr); staging->id_zone_map[bbd->d_id].setCtime(); staging->id_zone_map[bbd->d_id].d_loaded=true; staging->id_zone_map[bbd->d_id].d_status="parsed into memory at "+nowTime(); // s_stage->id_zone_map[bbd->d_id].d_records->swap(*s_staging_zone_map[bbd->d_id].d_records); } catch(AhuException &ae) { ostringstream msg; msg<<" error at "+nowTime()+" parsing '"<name<<"' from file '"<filename<<"': "<id_zone_map[bbd->d_id].d_status=msg.str(); L<name<<"' from file '"<filename<<"': "<id_zone_map[bbd->d_id].d_status=msg.str(); L< *>&tmp=d_zone_id_map[bbd.d_id]; // shrink trick vector *>(tmp).swap(tmp); */ } // figure out which domains were new and which vanished int remdomains=0; set oldnames, newnames; for(id_zone_map_t::const_iterator j=s_state->id_zone_map.begin();j != s_state->id_zone_map.end();++j) { oldnames.insert(j->second.d_name); } for(id_zone_map_t::const_iterator j=staging->id_zone_map.begin(); j!= staging->id_zone_map.end(); ++j) { newnames.insert(j->second.d_name); } vector diff; set_difference(oldnames.begin(), oldnames.end(), newnames.begin(), newnames.end(), back_inserter(diff)); remdomains=diff.size(); #if 0 // remove domains from the *name* map, delete their pointer for(vector::const_iterator k=diff.begin();k!=diff.end(); ++k) { L<name_id_map.erase(*k); } // now remove from the s_state->id_zone_map for(id_zone_map_t::iterator j=s_state->id_zone_map.begin();j!=s_state->id_zone_map.end();++j) { // O(N*M) for(vector::const_iterator k=diff.begin();k!=diff.end();++k) if(j->second.d_name==*k) { L<second.d_name<<"' from memory"<second.d_loaded=false; nukeZoneRecords(&j->second); break; } } #endif // count number of entirely new domains vector diff2; set_difference(newnames.begin(), newnames.end(), oldnames.begin(), oldnames.end(), back_inserter(diff2)); newdomains=diff2.size(); Lock l(&s_state_swap_lock); s_state.swap(staging); // report ostringstream msg; msg<<" Done parsing domains, "<d_loaded=0; // block further access bbd->d_records = shared_ptr (new recordstorage_t); } void Bind2Backend::queueReload(BB2DomainInfo *bbd) { Lock l(&s_state_lock); shared_ptr staging(new State); // we reload *now* for the time being try { // nukeZoneRecords(bbd); // ? do we need this? staging->id_zone_map[bbd->d_id]=s_state->id_zone_map[bbd->d_id]; shared_ptr newrecords(new recordstorage_t); staging->id_zone_map[bbd->d_id].d_records=newrecords; ZoneParserTNG zpt(bbd->d_filename, bbd->d_name, s_binddirectory); DNSResourceRecord rr; string hashed; NSEC3PARAMRecordContent ns3pr; bool nsec3zone=getNSEC3PARAM(bbd->d_name, &ns3pr); while(zpt.get(rr)) { if(rr.qtype.getCode() == QType::NSEC || rr.qtype.getCode() == QType::NSEC3) continue; // we synthesise NSECs on demand if(nsec3zone) { if(rr.qtype.getCode() != QType::NSEC3 && rr.qtype.getCode() != QType::RRSIG) hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); else hashed=""; } insert(staging, bbd->d_id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed); } // cerr<<"Start sort of "<id_zone_map[bbd->d_id].d_records->size()<<" records"<id_zone_map[bbd->d_id].d_records->begin(), staging->id_zone_map[bbd->d_id].d_records->end()); // cerr<<"Sorting done"<id_zone_map[bbd->d_id].d_records); doEmptyNonTerminals(staging, bbd->d_id, nsec3zone, ns3pr); staging->id_zone_map[bbd->d_id].setCtime(); s_state->id_zone_map[bbd->d_id]=staging->id_zone_map[bbd->d_id]; // move over bbd->setCtime(); // and raise d_loaded again! bbd->d_loaded=1; bbd->d_checknow=0; bbd->d_status="parsed into memory at "+nowTime(); L<d_name<<"' ("<d_filename<<") reloaded"<d_name<<"' from file '"<d_filename<<"': "<d_status=msg.str(); } catch(std::exception &ae) { ostringstream msg; msg<<" error at "+nowTime()+" parsing '"<d_name<<"' from file '"<d_filename<<"': "<d_status=msg.str(); } } bool Bind2Backend::findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { string domain=toLower(qname); recordstorage_t::const_iterator iter = bbd.d_records->upper_bound(domain); if (before.empty()){ //cout<<"starting before for: '"<upper_bound(domain); while(iter == bbd.d_records->end() || (iter->qname) > domain || (!(iter->auth) && (!(iter->qtype == QType::NS))) || (!(iter->qtype))) iter--; before=iter->qname; } else { before=domain; } //cerr<<"Now after"<upper_bound(domain); if(iter == bbd.d_records->end()) { //cerr<<"\tFound the end, begin storage: '"<begin()->qname<<"', '"<qname)<<"' (nsec3hash='"<<(iter->nsec3hash)<<"')"<auth) && (!(iter->qtype == QType::NS))) || (!(iter->qtype))) { iter++; if(iter == bbd.d_records->end()) { after.clear(); break; } } after = (iter)->qname; } //cerr<<"Before: '"< state = s_state; BB2DomainInfo& bbd = state->id_zone_map[id]; NSEC3PARAMRecordContent ns3pr; string auth=state->id_zone_map[id].d_name; if(!getNSEC3PARAM(auth, &ns3pr)) { //cerr<<"in bind2backend::getBeforeAndAfterAbsolute: no nsec3 for "<::type records_by_hashindex_t; records_by_hashindex_t& hashindex=boost::multi_index::get(*bbd.d_records); // BOOST_FOREACH(const Bind2DNSRecord& bdr, hashindex) { // cerr<<"Hash: "<nsec3hash > lqname)) { iter--; } if(iter == hashindex.begin() && (iter->nsec3hash > lqname)) { iter = hashindex.end(); } wraponce = false; while(iter == hashindex.end() || (!iter->auth && !(iter->qtype == QType::NS && !pdns_iequals(iter->qname, auth) && !ns3pr.d_flags)) || iter->nsec3hash.empty()) { iter--; if(iter == hashindex.begin()) { if (!wraponce) { iter = hashindex.end(); wraponce = true; } else { before.clear(); after.clear(); return false; } } } before = iter->nsec3hash; unhashed = dotConcat(labelReverse(iter->qname), auth); // cerr<<"before: "<<(iter->nsec3hash)<<"/"<<(iter->qname)<auth && !(iter->qtype == QType::NS && !pdns_iequals(iter->qname, auth) && !ns3pr.d_flags)) || iter->nsec3hash.empty()) { iter++; if(iter == hashindex.end()) { if (!wraponce) { iter = hashindex.begin(); wraponce = true; } else { before.clear(); after.clear(); return false; } } } after = iter->nsec3hash; // cerr<<"after: "<<(iter->nsec3hash)<<"/"<<(iter->qname)< state = s_state; name_id_map_t::const_iterator iditer; do { iditer=state->name_id_map.find(domain); } while ((iditer == state->name_id_map.end() || (zoneId != iditer->second && zoneId != -1)) && chopOff(domain)); if(iditer==state->name_id_map.end()) { if(mustlog) L<second<<") that might contain data "<second; DLOG(L<<"Bind2Backend constructing handle for search for "<id_zone_map[iditer->second]; if(!bbd.d_loaded) { d_handle.reset(); throw DBException("Zone for '"+bbd.d_name+"' in '"+bbd.d_filename+"' temporarily not available (file missing, or master dead)"); // fsck } if(!bbd.current()) { L<empty()) DLOG(L<<"Query with no results"< range; string lname=labelReverse(toLower(d_handle.qname)); //cout<<"starting equal range for: '"<equal_range(lname); //cout<<"End equal range"<size()<<" available in total!"<qtype==qtype.getCode())) { DLOG(L<qtype).getName()<<": '"<content<<"'"<qtype).getCode()<content; // r.domain_id=(d_iter)->domain_id; r.qtype=(d_iter)->qtype; r.ttl=(d_iter)->ttl; r.priority=(d_iter)->priority; //if(!d_iter->auth && r.qtype.getCode() != QType::A && r.qtype.getCode()!=QType::AAAA && r.qtype.getCode() != QType::NS) // cerr<<"Warning! Unauth response for qtype "<< r.qtype.getName() << " for '"<auth; d_iter++; return true; } bool Bind2Backend::list(const string &target, int id) { shared_ptr state = s_state; if(!state->id_zone_map.count(id)) return false; d_handle.reset(); DLOG(L<<"Bind2Backend constructing handle for list of "<id_zone_map[id].d_records; // give it a copy, which will stay around d_handle.d_qname_iter= d_handle.d_records->begin(); d_handle.d_qname_end=d_handle.d_records->end(); // iter now points to a vector of pointers to vector d_handle.id=id; d_handle.d_list=true; return true; } bool Bind2Backend::handle::get_list(DNSResourceRecord &r) { if(d_qname_iter!=d_qname_end) { r.qname=d_qname_iter->qname.empty() ? domain : (labelReverse(d_qname_iter->qname)+"."+domain); r.domain_id=id; r.content=(d_qname_iter)->content; r.qtype=(d_qname_iter)->qtype; r.ttl=(d_qname_iter)->ttl; r.priority=(d_qname_iter)->priority; r.auth = d_qname_iter->auth; d_qname_iter++; return true; } return false; } // this function really is too slow bool Bind2Backend::isMaster(const string &name, const string &ip) { shared_ptr state = getState(); for(id_zone_map_t::iterator j=state->id_zone_map.begin(); j!=state->id_zone_map.end();++j) { if(j->second.d_name==name) { for(vector::const_iterator iter = j->second.d_masters.begin(); iter != j->second.d_masters.end(); ++iter) if(*iter==ip) return true; } } return false; } bool Bind2Backend::superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db) { // Check whether we have a configfile available. if (getArg("supermaster-config").empty()) return false; ifstream c_if(getArg("supermasters").c_str(), std::ios::in); // this was nocreate? if (!c_if) { L << Logger::Error << "Unable to open supermasters file for read: " << stringerror() << endl; return false; } // Format: // string line, sip, saccount; while (getline(c_if, line)) { std::istringstream ii(line); ii >> sip; if (sip == ip) { ii >> saccount; break; } } c_if.close(); if (sip != ip) // ip not found in authorization list - reject return false; // ip authorized as supermaster - accept *db = this; if (saccount.length() > 0) *account = saccount.c_str(); return true; } bool Bind2Backend::createSlaveDomain(const string &ip, const string &domain, const string &account) { // Interference with loadConfig(), use locking Lock l(&s_state_lock); string filename = getArg("supermaster-destdir")+'/'+domain; L << Logger::Warning << d_logprefix << " Writing bind config zone statement for superslave zone '" << domain << "' from supermaster " << ip << endl; ofstream c_of(getArg("supermaster-config").c_str(), std::ios::app); if (!c_of) { L << Logger::Error << "Unable to open supermaster configfile for append: " << stringerror() << endl; throw DBException("Unable to open supermaster configfile for append: "+stringerror()); } c_of << endl; c_of << "# Superslave zone " << domain << " (added: " << nowTime() << ") (account: " << account << ')' << endl; c_of << "zone \"" << domain << "\" {" << endl; c_of << "\ttype slave;" << endl; c_of << "\tfile \"" << filename << "\";" << endl; c_of << "\tmasters { " << ip << "; };" << endl; c_of << "};" << endl; c_of.close(); int newid=1; // Find a free zone id nr. if (!s_state->id_zone_map.empty()) { id_zone_map_t::reverse_iterator i = s_state->id_zone_map.rbegin(); newid = i->second.d_id + 1; } BB2DomainInfo &bbd = s_state->id_zone_map[newid]; bbd.d_id = newid; bbd.d_records = shared_ptr(new recordstorage_t); bbd.d_name = domain; bbd.setCheckInterval(getArgAsNum("check-interval")); bbd.d_masters.push_back(ip); bbd.d_filename = filename; s_state->name_id_map[domain] = bbd.d_id; return true; } class Bind2Factory : public BackendFactory { public: Bind2Factory() : BackendFactory("bind") {} void declareArguments(const string &suffix="") { declare(suffix,"config","Location of named.conf",""); // declare(suffix,"example-zones","Install example zones","no"); declare(suffix,"check-interval","Interval for zonefile changes","0"); declare(suffix,"supermaster-config","Location of (part of) named.conf where pdns can write zone-statements to",""); declare(suffix,"supermasters","List of IP-addresses of supermasters",""); declare(suffix,"supermaster-destdir","Destination directory for newly added slave zones",::arg()["config-dir"]); declare(suffix,"dnssec-db","Filename to store & access our DNSSEC metadatabase, empty for none", ""); } DNSBackend *make(const string &suffix="") { return new Bind2Backend(suffix); } DNSBackend *makeMetadataOnly(const string &suffix="") { return new Bind2Backend(suffix, false); } }; //! Magic class that is activated when the dynamic library is loaded class Bind2Loader { public: Bind2Loader() { BackendMakers().report(new Bind2Factory); L< #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "misc.hh" #include "dnsbackend.hh" #include "namespaces.hh" using namespace ::boost::multi_index; /** This struct is used within the Bind2Backend to store DNS information. It is almost identical to a DNSResourceRecord, but then a bit smaller and with different sorting rules, which make sure that the SOA record comes up front. */ struct Bind2DNSRecord { string qname; string content; string nsec3hash; uint32_t ttl; uint16_t qtype; uint16_t priority; mutable bool auth; bool operator<(const Bind2DNSRecord& rhs) const { if(qname < rhs.qname) return true; if(qname > rhs.qname) return false; if(qtype==QType::SOA && rhs.qtype!=QType::SOA) return true; return tie(qtype,content, ttl) < tie(rhs.qtype, rhs.content, rhs.ttl); } }; struct Bind2DNSCompare : std::less { using std::less::operator(); // use operator< bool operator() (const std::string& a, const Bind2DNSRecord& b) const {return a < b.qname;} bool operator() (const Bind2DNSRecord& a, const std::string& b) const {return a.qname < b;} bool operator() (const Bind2DNSRecord& a, const Bind2DNSRecord& b) const { return a < b; } }; struct HashedTag{}; typedef multi_index_container< Bind2DNSRecord, indexed_by < ordered_non_unique, Bind2DNSCompare >, ordered_non_unique, member > > > recordstorage_t; /** Class which describes all metadata of a domain for storage by the Bind2Backend, and also contains a pointer to a vector of Bind2DNSRecord's */ class BB2DomainInfo { public: BB2DomainInfo(); void setCtime(); bool current(); //! configure how often this domain should be checked for changes (on disk) void setCheckInterval(time_t seconds); bool d_loaded; //!< if a domain is loaded string d_status; //!< message describing status of a domain, for human consumption bool d_checknow; //!< if this domain has been flagged for a check time_t d_ctime; //!< last known ctime of the file on disk string d_name; //!< actual name of the domain string d_filename; //!< full absolute filename of the zone on disk unsigned int d_id; //!< internal id of the domain time_t d_lastcheck; //!< last time domain was checked for freshness vector d_masters; //!< IP address of the master of this domain set d_also_notify; //!< IP list of hosts to also notify uint32_t d_lastnotified; //!< Last serial number we notified our slaves of shared_ptr d_records; //!< the actual records belonging to this domain private: time_t getCtime(); time_t d_checkinterval; }; class SSQLite3; class NSEC3PARAMRecordContent; class Bind2Backend : public DNSBackend { public: Bind2Backend(const string &suffix="", bool loadZones=true); ~Bind2Backend(); void getUnfreshSlaveInfos(vector *unfreshDomains); void getUpdatedMasters(vector *changedDomains); bool getDomainInfo(const string &domain, DomainInfo &di); time_t getCtime(const string &fname); // DNSSEC virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1); bool list(const string &target, int id); bool get(DNSResourceRecord &); void getAllDomains(vector *domains); static DNSBackend *maker(); static pthread_mutex_t s_startup_lock; void setFresh(uint32_t domain_id); void setNotified(uint32_t id, uint32_t serial); bool startTransaction(const string &qname, int id); // bool Bind2Backend::stopTransaction(const string &qname, int id); bool feedRecord(const DNSResourceRecord &r, string *ordername=0); bool commitTransaction(); bool abortTransaction(); bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth); void alsoNotifies(const string &domain, set *ips); // the DNSSEC related (getDomainMetadata has broader uses too) virtual bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); virtual bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys); virtual bool removeDomainKey(const string& name, unsigned int id); virtual int addDomainKey(const string& name, const KeyData& key); virtual bool activateDomainKey(const string& name, unsigned int id); virtual bool deactivateDomainKey(const string& name, unsigned int id); virtual bool getTSIGKey(const string& name, string* algorithm, string* content); static void createDNSSECDB(const string& fname); virtual bool doesDNSSEC(); // end of DNSSEC typedef map name_id_map_t; typedef map id_zone_map_t; struct State : public boost::noncopyable { name_id_map_t name_id_map; //!< convert a name to a domain id id_zone_map_t id_zone_map; }; static void insert(shared_ptr stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string()); void rediscover(string *status=0); bool isMaster(const string &name, const string &ip); // for supermaster support bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db); bool createSlaveDomain(const string &ip, const string &domain, const string &account); private: void setupDNSSEC(); shared_ptr d_dnssecdb; bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p); class handle { public: bool get(DNSResourceRecord &); void reset(); handle(); shared_ptr d_records; recordstorage_t::const_iterator d_iter, d_end_iter; recordstorage_t::const_iterator d_qname_iter; recordstorage_t::const_iterator d_qname_end; bool d_list; int id; string qname; string domain; QType qtype; bool mustlog; private: bool get_normal(DNSResourceRecord &); bool get_list(DNSResourceRecord &); void operator=(const handle& ); // don't go copying this handle(const handle &); }; static shared_ptr s_state; static pthread_mutex_t s_state_lock; //!< lock protecting ??? static pthread_mutex_t s_state_swap_lock; static shared_ptr getState(); static int s_first; //!< this is raised on construction to prevent multiple instances of us being generated static string s_binddirectory; //!< this is used to store the 'directory' setting of the bind configuration string d_logprefix; set alsoNotify; //!< this is used to store the also-notify list of interested peers. int d_transaction_id; string d_transaction_tmpname; ofstream *d_of; handle d_handle; void queueReload(BB2DomainInfo *bbd); bool findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); void reload(); static string DLDomStatusHandler(const vector&parts, Utility::pid_t ppid); static string DLListRejectsHandler(const vector&parts, Utility::pid_t ppid); static string DLReloadNowHandler(const vector&parts, Utility::pid_t ppid); static void fixupAuth(shared_ptr records); static void doEmptyNonTerminals(shared_ptr stage, int id, bool nsec3zone, NSEC3PARAMRecordContent ns3pr); void loadConfig(string *status=0); static void nukeZoneRecords(BB2DomainInfo *bbd); }; pdns-3.3/pdns/backends/bind/zone2json.cc0000644000014601777760000001542312140444471021461 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* accepts a named.conf or a zone as parameter and outputs heaps of sql */ #include #include #include #include #include #include "namespaces.hh" #include "dns.hh" #include "arguments.hh" #include "bindparserclasses.hh" #include "statbag.hh" #include "misc.hh" #include "dnspacket.hh" #include "zoneparser-tng.hh" #include "dnsrecords.hh" #include #include #include #include #include StatBag S; static int g_numRecords; static void quoteValue(string &value) { string tmp; size_t opos,pos; // no point doing it if there isn't anything to do if (value.find_first_of("\\\\\"") == string::npos) return; pos = opos = 0; while((pos = value.find_first_of("\\\\\"", opos)) != string::npos) { tmp += value.substr(opos, pos - opos); tmp += "\\"; tmp += value[pos]; opos = pos+1; } value = tmp; } static string emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio) { string retval; g_numRecords++; string content(ocontent); if(qtype == "MX" || qtype == "SRV") { prio=atoi(content.c_str()); string::size_type pos = content.find_first_not_of("0123456789"); if(pos != string::npos) boost::erase_head(content, pos); trim_left(content); } quoteValue(content); retval = "{"; retval += "\"name\":\""; retval += qname; retval += "\","; retval += "\"type\":\""; retval += qtype; retval += "\","; retval += "\"ttl\":"; retval += lexical_cast(ttl); retval += ","; retval += "\"prio\":"; retval += lexical_cast(prio); retval += ","; retval += "\"content\":\""; retval += content; retval += "\"}"; return retval; } static void emitJson(vector &data) { size_t l = data.size(); cout << "["; for(size_t i=0;i lines; try { reportAllTypes(); reportFancyTypes(); #if __GNUC__ >= 3 std::ios_base::sync_with_stdio(false); #endif ::arg().setSwitch("verbose","Verbose comments on operation")="no"; ::arg().setSwitch("on-error-resume-next","Continue after errors")="no"; ::arg().set("zone","Zonefile to parse")=""; ::arg().set("zone-name","Specify an $ORIGIN in case it is not present")=""; ::arg().set("named-conf","Bind 8/9 named.conf to parse")=""; ::arg().set("soa-minimum-ttl","Do not change")="0"; ::arg().set("soa-refresh-default","Do not change")="0"; ::arg().set("soa-retry-default","Do not change")="0"; ::arg().set("soa-expire-default","Do not change")="0"; ::arg().setCmd("help","Provide a helpful message"); S.declare("logmessages"); string namedfile=""; string zonefile=""; ::arg().parse(argc, argv); if(argc<2 || ::arg().mustDo("help")) { cerr<<"syntax:"< domains=BP.getDomains(); struct stat st; for(vector::iterator i=domains.begin(); i!=domains.end(); ++i) { if(stat(i->filename.c_str(), &st) == 0) { i->d_dev = st.st_dev; i->d_ino = st.st_ino; } } sort(domains.begin(), domains.end()); // put stuff in inode order int numdomains=domains.size(); int tick=numdomains/100; cout <<"["; for(vector::const_iterator i=domains.begin(); i!=domains.end(); ++i) { if(i->type!="master" && i->type!="slave") { cerr<<" Warning! Skipping '"<type<<"' zone '"<name<<"'"<filename, i->name, BP.getDirectory()); DNSResourceRecord rr; while(zpt.get(rr)) lines.push_back(emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority)); cout << "{\"name\":\"" << i->name << "\",\"records\": "; emitJson(lines); cout << "},"; num_domainsdone++; } catch(std::exception &ae) { if(!::arg().mustDo("on-error-resume-next")) throw; else cerr<filename<<")\033\133\113"; } cout << "]\n"; cerr<<"\r100% done\033\133\113"< #include #include #include #define YY_NO_INPUT 1 #define YYSTYPE char * #ifdef WIN32 #include "bindparser.tab.hh" extern "C" { int isatty( int ); int yywrap() { return 1; } } #else #include "bindparser.h" #endif // WIN32 int linenumber; #define MAX_INCLUDE_DEPTH 10 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ln[MAX_INCLUDE_DEPTH]; char *include_stack_name[MAX_INCLUDE_DEPTH]; char *current_filename; char *original_filename; int include_stack_ptr = 0; extern const char *bind_directory; %} %x comment %x incl %x quoted %option stack %option nounput %option noyy_top_state %option noinput %% "/*" BEGIN(comment); [^*\n]* /* eat anything that's not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ \n ++linenumber; "*"+"/" BEGIN(INITIAL); include BEGIN(incl); [ \t;]* /* eat the whitespace */ \"[^ \t\n";]+\"; { /* got the include file name */ char filename[1024]; if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) { fprintf( stderr, "Includes nested too deeply" ); exit( 1 ); } yytext[strlen(yytext)-2]=0; include_stack[include_stack_ptr]=YY_CURRENT_BUFFER; include_stack_name[include_stack_ptr]=current_filename=strdup(yytext+1); include_stack_ln[include_stack_ptr++]=linenumber; linenumber=1; if(*(yytext+1)=='/') strcpy(filename,yytext+1); else { strcpy(filename,bind_directory); strcat(filename,"/"); strcat(filename,yytext+1); } if (*yytext &&!(yyin=fopen(filename,"r"))) { fprintf( stderr, "Unable to open '%s': %s\n",filename,strerror(errno)); exit( 1 ); } BEGIN(INITIAL); yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); } <> { if ( --include_stack_ptr < 0 ) { yyterminate(); } else { fclose(yyin); yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(include_stack[include_stack_ptr]); linenumber=include_stack_ln[include_stack_ptr]; free(include_stack_name[include_stack_ptr]); if(include_stack_ptr) current_filename=include_stack_name[include_stack_ptr-1]; else current_filename=original_filename; } } zone return ZONETOK; file return FILETOK; options return OPTIONSTOK; also-notify return ALSONOTIFYTOK; acl return ACLTOK; logging return LOGGINGTOK; directory return DIRECTORYTOK; masters return MASTERTOK; type return TYPETOK; \" yy_push_state(quoted); [^\"]* yylval=strdup(yytext); return QUOTEDWORD; \" yy_pop_state(); [^\" \t\n{};]* yylval=strdup(yytext);return AWORD; \{ return OBRACE; \} return EBRACE; ; return SEMICOLON; \n linenumber++; [ \t]* ; \/\/.*$ ; \#.*$ ; . { fprintf(stderr,"Parsing '%s': unable to parse line %d at character '%s'\n",current_filename, linenumber, yytext); exit(1); } %% pdns-3.3/pdns/backends/bind/bind-dnssec.schema.sqlite3.sql.h0000644000014601777760000000143612165464055025213 0ustar00jenkinsnogroup00000000000000static char sqlCreate[] __attribute__((unused))= "create table domainmetadata (" " id INTEGER PRIMARY KEY," " domain VARCHAR(255) COLLATE NOCASE," " kind VARCHAR(16) COLLATE NOCASE," " content TEXT" ");" "" "create index domainmetanameindex on domainmetadata(domain);" "" "create table cryptokeys (" " id INTEGER PRIMARY KEY," " domain VARCHAR(255) COLLATE NOCASE," " flags INT NOT NULL," " active BOOL," " content TEXT" "); " "" "create index domainnameindex on cryptokeys(domain); " "" "create table tsigkeys (" " id INTEGER PRIMARY KEY," " name VARCHAR(255) COLLATE NOCASE," " algorithm VARCHAR(50) COLLATE NOCASE," " secret VARCHAR(255)" ");" "" "create unique index namealgoindex on tsigkeys(name, algorithm);" ; pdns-3.3/pdns/backends/bind/Makefile.in0000644000014601777760000023607112165464030021274 0ustar00jenkinsnogroup00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = zone2sql$(EXEEXT) zone2ldap$(EXEEXT) zone2json$(EXEEXT) subdir = pdns/backends/bind DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO \ bindlexer.c bindparser.cc bindparser.h ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libbind2backend_la_LIBADD = am_libbind2backend_la_OBJECTS = libbind2backend_la-bindbackend2.lo \ libbind2backend_la-bindparser.lo \ libbind2backend_la-bindlexer.lo \ libbind2backend_la-zoneparser-tng.lo \ libbind2backend_la-misc.lo libbind2backend_la-unix_utility.lo \ libbind2backend_la-binddnssec.lo libbind2backend_la_OBJECTS = $(am_libbind2backend_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent libbind2backend_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) \ $(libbind2backend_la_LDFLAGS) $(LDFLAGS) -o $@ am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_zone2json_OBJECTS = bindparser.$(OBJEXT) bindlexer.$(OBJEXT) \ arguments.$(OBJEXT) logger.$(OBJEXT) zone2json.$(OBJEXT) \ statbag.$(OBJEXT) misc.$(OBJEXT) unix_utility.$(OBJEXT) \ qtype.$(OBJEXT) zoneparser-tng.$(OBJEXT) dnsrecords.$(OBJEXT) \ dnswriter.$(OBJEXT) dnslabeltext.$(OBJEXT) \ rcpgenerator.$(OBJEXT) dnsparser.$(OBJEXT) base64.$(OBJEXT) \ sillyrecords.$(OBJEXT) nsecrecords.$(OBJEXT) \ dnssecinfra.$(OBJEXT) base32.$(OBJEXT) zone2json_OBJECTS = $(am_zone2json_OBJECTS) @HAVE_LIBPOLARSSL_FALSE@zone2json_DEPENDENCIES = ../../ext/polarssl-1.1.2/library/libpolarssl.a zone2json_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(zone2json_LDFLAGS) $(LDFLAGS) -o $@ am_zone2ldap_OBJECTS = bindparser.$(OBJEXT) bindlexer.$(OBJEXT) \ arguments.$(OBJEXT) logger.$(OBJEXT) zone2ldap.$(OBJEXT) \ statbag.$(OBJEXT) misc.$(OBJEXT) unix_utility.$(OBJEXT) \ qtype.$(OBJEXT) zoneparser-tng.$(OBJEXT) dnsrecords.$(OBJEXT) \ dnswriter.$(OBJEXT) dnslabeltext.$(OBJEXT) \ rcpgenerator.$(OBJEXT) dnsparser.$(OBJEXT) base64.$(OBJEXT) \ sillyrecords.$(OBJEXT) nsecrecords.$(OBJEXT) \ dnssecinfra.$(OBJEXT) base32.$(OBJEXT) dns_random.$(OBJEXT) \ aescrypt.$(OBJEXT) aeskey.$(OBJEXT) aes_modes.$(OBJEXT) \ aestab.$(OBJEXT) zone2ldap_OBJECTS = $(am_zone2ldap_OBJECTS) @HAVE_LIBPOLARSSL_FALSE@zone2ldap_DEPENDENCIES = ../../ext/polarssl-1.1.2/library/libpolarssl.a zone2ldap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(zone2ldap_LDFLAGS) $(LDFLAGS) -o $@ am_zone2sql_OBJECTS = bindparser.$(OBJEXT) bindlexer.$(OBJEXT) \ arguments.$(OBJEXT) logger.$(OBJEXT) zone2sql.$(OBJEXT) \ statbag.$(OBJEXT) misc.$(OBJEXT) unix_utility.$(OBJEXT) \ qtype.$(OBJEXT) dns.$(OBJEXT) zoneparser-tng.$(OBJEXT) \ dnsrecords.$(OBJEXT) sillyrecords.$(OBJEXT) \ dnswriter.$(OBJEXT) dnslabeltext.$(OBJEXT) \ rcpgenerator.$(OBJEXT) dnsparser.$(OBJEXT) base64.$(OBJEXT) \ nsecrecords.$(OBJEXT) dnssecinfra.$(OBJEXT) base32.$(OBJEXT) \ dns_random.$(OBJEXT) aescrypt.$(OBJEXT) aeskey.$(OBJEXT) \ aes_modes.$(OBJEXT) aestab.$(OBJEXT) zone2sql_OBJECTS = $(am_zone2sql_OBJECTS) @HAVE_LIBPOLARSSL_FALSE@zone2sql_DEPENDENCIES = ../../ext/polarssl-1.1.2/library/libpolarssl.a zone2sql_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(zone2sql_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) am__v_CCLD_0 = @echo " CCLD " $@; CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_$(V)) am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) am__v_CXX_0 = @echo " CXX " $@; CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_$(V)) am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) am__v_CXXLD_0 = @echo " CXXLD " $@; LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) LTLEXCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) AM_V_LEX = $(am__v_LEX_$(V)) am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY)) am__v_LEX_0 = @echo " LEX " $@; YLWRAP = $(top_srcdir)/ylwrap YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) AM_V_YACC = $(am__v_YACC_$(V)) am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY)) am__v_YACC_0 = @echo " YACC " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libbind2backend_la_SOURCES) $(zone2json_SOURCES) \ $(zone2ldap_SOURCES) $(zone2sql_SOURCES) DIST_SOURCES = $(libbind2backend_la_SOURCES) $(zone2json_SOURCES) \ $(zone2ldap_SOURCES) $(zone2sql_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ BOOST_LDPATH = @BOOST_LDPATH@ BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@ BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@ BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@ BOOST_ROOT = @BOOST_ROOT@ BOOST_SERIALIZATION_LDFLAGS = @BOOST_SERIALIZATION_LDFLAGS@ BOOST_SERIALIZATION_LDPATH = @BOOST_SERIALIZATION_LDPATH@ BOOST_SERIALIZATION_LIBS = @BOOST_SERIALIZATION_LIBS@ BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@ BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ BOTAN110_CFLAGS = @BOTAN110_CFLAGS@ BOTAN110_LIBS = @BOTAN110_LIBS@ BOTAN18_CFLAGS = @BOTAN18_CFLAGS@ BOTAN18_LIBS = @BOTAN18_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CDB_CFLAGS = @CDB_CFLAGS@ CDB_LIBS = @CDB_LIBS@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ DIST_HOST = @DIST_HOST@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DYNLINKFLAGS = @DYNLINKFLAGS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBCRYPT = @LIBCRYPT@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBDL = @LIBDL@ LIBLDAP = @LIBLDAP@ LIBOBJS = @LIBOBJS@ LIBOPENDBX = @LIBOPENDBX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LUA_CFLAGS = @LUA_CFLAGS@ LUA_LIBS = @LUA_LIBS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MYSQL_inc = @MYSQL_inc@ MYSQL_lib = @MYSQL_lib@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ORACLE_CFLAGS = @ORACLE_CFLAGS@ ORACLE_LIBS = @ORACLE_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PGSQL_incdir = @PGSQL_incdir@ PGSQL_lib = @PGSQL_lib@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ REMOTEBACKEND_HTTP = @REMOTEBACKEND_HTTP@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ THREADFLAGS = @THREADFLAGS@ UNIXODBC_incdir = @UNIXODBC_incdir@ UNIXODBC_lib = @UNIXODBC_lib@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledirs = @moduledirs@ modulelibs = @modulelibs@ moduleobjects = @moduleobjects@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ programdescend = @programdescend@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ socketdir = @socketdir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libbind2backend.la AM_CPPFLAGS = -I../.. $(BOOST_CPPFLAGS) @THREADFLAGS@ BUILT_SOURCES = bind-dnssec.schema.sqlite3.sql.h bindparser.h libbind2backend_la_SOURCES = bindbackend2.cc bindbackend2.hh bindparser.yy \ bindlexer.l ../../zoneparser-tng.cc ../../misc.cc \ bindparserclasses.hh ../../unix_utility.cc binddnssec.cc bind-dnssec.schema.sqlite3.sql.h libbind2backend_la_CXXFLAGS = $(AM_CXXFLAGS) libbind2backend_la_CFLAGS = $(AM_CFLAGS) libbind2backend_la_LDFLAGS = -module -avoid-version EXTRA_DIST = dnslabeltext.cc bindparser.cc bindparser.h bind-dnssec.schema.sqlite3.sql.h zone2sql_SOURCES = bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2sql.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../dns.cc \ ../../zoneparser-tng.cc ../../dnsrecords.cc ../../sillyrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc ../../aes/dns_random.cc \ ../../aes/aescpp.h ../../aes/aescrypt.c ../../aes/aes.h ../../aes/aeskey.c ../../aes/aes_modes.c ../../aes/aesopt.h \ ../../aes/aestab.c ../../aes/aestab.h ../../aes/brg_endian.h ../../aes/brg_types.h # ../../dbdnsseckeeper.cc zone2json_SOURCES = bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2json.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../zoneparser-tng.cc ../../dnsrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc ../../sillyrecords.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc zone2ldap_SOURCES = bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2ldap.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../zoneparser-tng.cc ../../dnsrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc ../../sillyrecords.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc ../../aes/dns_random.cc \ ../../aes/aescpp.h ../../aes/aescrypt.c ../../aes/aes.h ../../aes/aeskey.c ../../aes/aes_modes.c ../../aes/aesopt.h \ ../../aes/aestab.c ../../aes/aestab.h ../../aes/brg_endian.h ../../aes/brg_types.h # ../../dbdnsseckeeper.cc zone2ldap_LDFLAGS = @THREADFLAGS@ @HAVE_LIBPOLARSSL_FALSE@zone2ldap_LDADD = ../../ext/polarssl-1.1.2/library/libpolarssl.a @HAVE_LIBPOLARSSL_TRUE@zone2ldap_LDADD = zone2sql_LDFLAGS = @THREADFLAGS@ @HAVE_LIBPOLARSSL_FALSE@zone2sql_LDADD = ../../ext/polarssl-1.1.2/library/libpolarssl.a @HAVE_LIBPOLARSSL_TRUE@zone2sql_LDADD = zone2json_LDFLAGS = @THREADFLAGS@ @HAVE_LIBPOLARSSL_FALSE@zone2json_LDADD = ../../ext/polarssl-1.1.2/library/libpolarssl.a @HAVE_LIBPOLARSSL_TRUE@zone2json_LDADD = AM_LFLAGS = -s -i AM_YFLAGS = -d --verbose --debug all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .cc .h .hh .l .lo .o .obj .yy $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign pdns/backends/bind/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign pdns/backends/bind/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done bindparser.h: bindparser.cc @if test ! -f $@; then \ rm -f bindparser.cc; \ $(MAKE) $(AM_MAKEFLAGS) bindparser.cc; \ else :; fi libbind2backend.la: $(libbind2backend_la_OBJECTS) $(libbind2backend_la_DEPENDENCIES) $(AM_V_CXXLD)$(libbind2backend_la_LINK) $(libbind2backend_la_OBJECTS) $(libbind2backend_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list zone2json$(EXEEXT): $(zone2json_OBJECTS) $(zone2json_DEPENDENCIES) @rm -f zone2json$(EXEEXT) $(AM_V_CXXLD)$(zone2json_LINK) $(zone2json_OBJECTS) $(zone2json_LDADD) $(LIBS) zone2ldap$(EXEEXT): $(zone2ldap_OBJECTS) $(zone2ldap_DEPENDENCIES) @rm -f zone2ldap$(EXEEXT) $(AM_V_CXXLD)$(zone2ldap_LINK) $(zone2ldap_OBJECTS) $(zone2ldap_LDADD) $(LIBS) zone2sql$(EXEEXT): $(zone2sql_OBJECTS) $(zone2sql_DEPENDENCIES) @rm -f zone2sql$(EXEEXT) $(AM_V_CXXLD)$(zone2sql_LINK) $(zone2sql_OBJECTS) $(zone2sql_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes_modes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aescrypt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeskey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aestab.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arguments.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base32.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bindlexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bindparser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns_random.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnslabeltext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsparser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnsrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnssecinfra.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dnswriter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-bindbackend2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-binddnssec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-bindlexer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-bindparser.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-unix_utility.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbind2backend_la-zoneparser-tng.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nsecrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcpgenerator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sillyrecords.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statbag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix_utility.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zone2json.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zone2ldap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zone2sql.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoneparser-tng.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< libbind2backend_la-bindlexer.lo: bindlexer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CFLAGS) $(CFLAGS) -MT libbind2backend_la-bindlexer.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-bindlexer.Tpo -c -o libbind2backend_la-bindlexer.lo `test -f 'bindlexer.c' || echo '$(srcdir)/'`bindlexer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-bindlexer.Tpo $(DEPDIR)/libbind2backend_la-bindlexer.Plo @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bindlexer.c' object='libbind2backend_la-bindlexer.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CFLAGS) $(CFLAGS) -c -o libbind2backend_la-bindlexer.lo `test -f 'bindlexer.c' || echo '$(srcdir)/'`bindlexer.c aescrypt.o: ../../aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aescrypt.o -MD -MP -MF $(DEPDIR)/aescrypt.Tpo -c -o aescrypt.o `test -f '../../aes/aescrypt.c' || echo '$(srcdir)/'`../../aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aescrypt.Tpo $(DEPDIR)/aescrypt.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aescrypt.c' object='aescrypt.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aescrypt.o `test -f '../../aes/aescrypt.c' || echo '$(srcdir)/'`../../aes/aescrypt.c aescrypt.obj: ../../aes/aescrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aescrypt.obj -MD -MP -MF $(DEPDIR)/aescrypt.Tpo -c -o aescrypt.obj `if test -f '../../aes/aescrypt.c'; then $(CYGPATH_W) '../../aes/aescrypt.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aescrypt.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aescrypt.Tpo $(DEPDIR)/aescrypt.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aescrypt.c' object='aescrypt.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aescrypt.obj `if test -f '../../aes/aescrypt.c'; then $(CYGPATH_W) '../../aes/aescrypt.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aescrypt.c'; fi` aeskey.o: ../../aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aeskey.o -MD -MP -MF $(DEPDIR)/aeskey.Tpo -c -o aeskey.o `test -f '../../aes/aeskey.c' || echo '$(srcdir)/'`../../aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeskey.Tpo $(DEPDIR)/aeskey.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aeskey.c' object='aeskey.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aeskey.o `test -f '../../aes/aeskey.c' || echo '$(srcdir)/'`../../aes/aeskey.c aeskey.obj: ../../aes/aeskey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aeskey.obj -MD -MP -MF $(DEPDIR)/aeskey.Tpo -c -o aeskey.obj `if test -f '../../aes/aeskey.c'; then $(CYGPATH_W) '../../aes/aeskey.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aeskey.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeskey.Tpo $(DEPDIR)/aeskey.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aeskey.c' object='aeskey.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aeskey.obj `if test -f '../../aes/aeskey.c'; then $(CYGPATH_W) '../../aes/aeskey.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aeskey.c'; fi` aes_modes.o: ../../aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes_modes.o -MD -MP -MF $(DEPDIR)/aes_modes.Tpo -c -o aes_modes.o `test -f '../../aes/aes_modes.c' || echo '$(srcdir)/'`../../aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aes_modes.Tpo $(DEPDIR)/aes_modes.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aes_modes.c' object='aes_modes.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aes_modes.o `test -f '../../aes/aes_modes.c' || echo '$(srcdir)/'`../../aes/aes_modes.c aes_modes.obj: ../../aes/aes_modes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes_modes.obj -MD -MP -MF $(DEPDIR)/aes_modes.Tpo -c -o aes_modes.obj `if test -f '../../aes/aes_modes.c'; then $(CYGPATH_W) '../../aes/aes_modes.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aes_modes.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aes_modes.Tpo $(DEPDIR)/aes_modes.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aes_modes.c' object='aes_modes.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aes_modes.obj `if test -f '../../aes/aes_modes.c'; then $(CYGPATH_W) '../../aes/aes_modes.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aes_modes.c'; fi` aestab.o: ../../aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aestab.o -MD -MP -MF $(DEPDIR)/aestab.Tpo -c -o aestab.o `test -f '../../aes/aestab.c' || echo '$(srcdir)/'`../../aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aestab.Tpo $(DEPDIR)/aestab.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aestab.c' object='aestab.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aestab.o `test -f '../../aes/aestab.c' || echo '$(srcdir)/'`../../aes/aestab.c aestab.obj: ../../aes/aestab.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aestab.obj -MD -MP -MF $(DEPDIR)/aestab.Tpo -c -o aestab.obj `if test -f '../../aes/aestab.c'; then $(CYGPATH_W) '../../aes/aestab.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aestab.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aestab.Tpo $(DEPDIR)/aestab.Po @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../../aes/aestab.c' object='aestab.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o aestab.obj `if test -f '../../aes/aestab.c'; then $(CYGPATH_W) '../../aes/aestab.c'; else $(CYGPATH_W) '$(srcdir)/../../aes/aestab.c'; fi` .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cc.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< libbind2backend_la-bindbackend2.lo: bindbackend2.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-bindbackend2.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-bindbackend2.Tpo -c -o libbind2backend_la-bindbackend2.lo `test -f 'bindbackend2.cc' || echo '$(srcdir)/'`bindbackend2.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-bindbackend2.Tpo $(DEPDIR)/libbind2backend_la-bindbackend2.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='bindbackend2.cc' object='libbind2backend_la-bindbackend2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-bindbackend2.lo `test -f 'bindbackend2.cc' || echo '$(srcdir)/'`bindbackend2.cc libbind2backend_la-bindparser.lo: bindparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-bindparser.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-bindparser.Tpo -c -o libbind2backend_la-bindparser.lo `test -f 'bindparser.cc' || echo '$(srcdir)/'`bindparser.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-bindparser.Tpo $(DEPDIR)/libbind2backend_la-bindparser.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='bindparser.cc' object='libbind2backend_la-bindparser.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-bindparser.lo `test -f 'bindparser.cc' || echo '$(srcdir)/'`bindparser.cc libbind2backend_la-zoneparser-tng.lo: ../../zoneparser-tng.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-zoneparser-tng.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-zoneparser-tng.Tpo -c -o libbind2backend_la-zoneparser-tng.lo `test -f '../../zoneparser-tng.cc' || echo '$(srcdir)/'`../../zoneparser-tng.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-zoneparser-tng.Tpo $(DEPDIR)/libbind2backend_la-zoneparser-tng.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../zoneparser-tng.cc' object='libbind2backend_la-zoneparser-tng.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-zoneparser-tng.lo `test -f '../../zoneparser-tng.cc' || echo '$(srcdir)/'`../../zoneparser-tng.cc libbind2backend_la-misc.lo: ../../misc.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-misc.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-misc.Tpo -c -o libbind2backend_la-misc.lo `test -f '../../misc.cc' || echo '$(srcdir)/'`../../misc.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-misc.Tpo $(DEPDIR)/libbind2backend_la-misc.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../misc.cc' object='libbind2backend_la-misc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-misc.lo `test -f '../../misc.cc' || echo '$(srcdir)/'`../../misc.cc libbind2backend_la-unix_utility.lo: ../../unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-unix_utility.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-unix_utility.Tpo -c -o libbind2backend_la-unix_utility.lo `test -f '../../unix_utility.cc' || echo '$(srcdir)/'`../../unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-unix_utility.Tpo $(DEPDIR)/libbind2backend_la-unix_utility.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../unix_utility.cc' object='libbind2backend_la-unix_utility.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-unix_utility.lo `test -f '../../unix_utility.cc' || echo '$(srcdir)/'`../../unix_utility.cc libbind2backend_la-binddnssec.lo: binddnssec.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -MT libbind2backend_la-binddnssec.lo -MD -MP -MF $(DEPDIR)/libbind2backend_la-binddnssec.Tpo -c -o libbind2backend_la-binddnssec.lo `test -f 'binddnssec.cc' || echo '$(srcdir)/'`binddnssec.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbind2backend_la-binddnssec.Tpo $(DEPDIR)/libbind2backend_la-binddnssec.Plo @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='binddnssec.cc' object='libbind2backend_la-binddnssec.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbind2backend_la_CXXFLAGS) $(CXXFLAGS) -c -o libbind2backend_la-binddnssec.lo `test -f 'binddnssec.cc' || echo '$(srcdir)/'`binddnssec.cc arguments.o: ../../arguments.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arguments.o -MD -MP -MF $(DEPDIR)/arguments.Tpo -c -o arguments.o `test -f '../../arguments.cc' || echo '$(srcdir)/'`../../arguments.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/arguments.Tpo $(DEPDIR)/arguments.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../arguments.cc' object='arguments.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arguments.o `test -f '../../arguments.cc' || echo '$(srcdir)/'`../../arguments.cc arguments.obj: ../../arguments.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arguments.obj -MD -MP -MF $(DEPDIR)/arguments.Tpo -c -o arguments.obj `if test -f '../../arguments.cc'; then $(CYGPATH_W) '../../arguments.cc'; else $(CYGPATH_W) '$(srcdir)/../../arguments.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/arguments.Tpo $(DEPDIR)/arguments.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../arguments.cc' object='arguments.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arguments.obj `if test -f '../../arguments.cc'; then $(CYGPATH_W) '../../arguments.cc'; else $(CYGPATH_W) '$(srcdir)/../../arguments.cc'; fi` logger.o: ../../logger.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT logger.o -MD -MP -MF $(DEPDIR)/logger.Tpo -c -o logger.o `test -f '../../logger.cc' || echo '$(srcdir)/'`../../logger.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/logger.Tpo $(DEPDIR)/logger.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../logger.cc' object='logger.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o logger.o `test -f '../../logger.cc' || echo '$(srcdir)/'`../../logger.cc logger.obj: ../../logger.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT logger.obj -MD -MP -MF $(DEPDIR)/logger.Tpo -c -o logger.obj `if test -f '../../logger.cc'; then $(CYGPATH_W) '../../logger.cc'; else $(CYGPATH_W) '$(srcdir)/../../logger.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/logger.Tpo $(DEPDIR)/logger.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../logger.cc' object='logger.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o logger.obj `if test -f '../../logger.cc'; then $(CYGPATH_W) '../../logger.cc'; else $(CYGPATH_W) '$(srcdir)/../../logger.cc'; fi` statbag.o: ../../statbag.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT statbag.o -MD -MP -MF $(DEPDIR)/statbag.Tpo -c -o statbag.o `test -f '../../statbag.cc' || echo '$(srcdir)/'`../../statbag.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/statbag.Tpo $(DEPDIR)/statbag.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../statbag.cc' object='statbag.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o statbag.o `test -f '../../statbag.cc' || echo '$(srcdir)/'`../../statbag.cc statbag.obj: ../../statbag.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT statbag.obj -MD -MP -MF $(DEPDIR)/statbag.Tpo -c -o statbag.obj `if test -f '../../statbag.cc'; then $(CYGPATH_W) '../../statbag.cc'; else $(CYGPATH_W) '$(srcdir)/../../statbag.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/statbag.Tpo $(DEPDIR)/statbag.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../statbag.cc' object='statbag.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o statbag.obj `if test -f '../../statbag.cc'; then $(CYGPATH_W) '../../statbag.cc'; else $(CYGPATH_W) '$(srcdir)/../../statbag.cc'; fi` misc.o: ../../misc.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT misc.o -MD -MP -MF $(DEPDIR)/misc.Tpo -c -o misc.o `test -f '../../misc.cc' || echo '$(srcdir)/'`../../misc.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/misc.Tpo $(DEPDIR)/misc.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../misc.cc' object='misc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o misc.o `test -f '../../misc.cc' || echo '$(srcdir)/'`../../misc.cc misc.obj: ../../misc.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT misc.obj -MD -MP -MF $(DEPDIR)/misc.Tpo -c -o misc.obj `if test -f '../../misc.cc'; then $(CYGPATH_W) '../../misc.cc'; else $(CYGPATH_W) '$(srcdir)/../../misc.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/misc.Tpo $(DEPDIR)/misc.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../misc.cc' object='misc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o misc.obj `if test -f '../../misc.cc'; then $(CYGPATH_W) '../../misc.cc'; else $(CYGPATH_W) '$(srcdir)/../../misc.cc'; fi` unix_utility.o: ../../unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT unix_utility.o -MD -MP -MF $(DEPDIR)/unix_utility.Tpo -c -o unix_utility.o `test -f '../../unix_utility.cc' || echo '$(srcdir)/'`../../unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/unix_utility.Tpo $(DEPDIR)/unix_utility.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../unix_utility.cc' object='unix_utility.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o unix_utility.o `test -f '../../unix_utility.cc' || echo '$(srcdir)/'`../../unix_utility.cc unix_utility.obj: ../../unix_utility.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT unix_utility.obj -MD -MP -MF $(DEPDIR)/unix_utility.Tpo -c -o unix_utility.obj `if test -f '../../unix_utility.cc'; then $(CYGPATH_W) '../../unix_utility.cc'; else $(CYGPATH_W) '$(srcdir)/../../unix_utility.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/unix_utility.Tpo $(DEPDIR)/unix_utility.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../unix_utility.cc' object='unix_utility.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o unix_utility.obj `if test -f '../../unix_utility.cc'; then $(CYGPATH_W) '../../unix_utility.cc'; else $(CYGPATH_W) '$(srcdir)/../../unix_utility.cc'; fi` qtype.o: ../../qtype.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT qtype.o -MD -MP -MF $(DEPDIR)/qtype.Tpo -c -o qtype.o `test -f '../../qtype.cc' || echo '$(srcdir)/'`../../qtype.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/qtype.Tpo $(DEPDIR)/qtype.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../qtype.cc' object='qtype.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o qtype.o `test -f '../../qtype.cc' || echo '$(srcdir)/'`../../qtype.cc qtype.obj: ../../qtype.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT qtype.obj -MD -MP -MF $(DEPDIR)/qtype.Tpo -c -o qtype.obj `if test -f '../../qtype.cc'; then $(CYGPATH_W) '../../qtype.cc'; else $(CYGPATH_W) '$(srcdir)/../../qtype.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/qtype.Tpo $(DEPDIR)/qtype.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../qtype.cc' object='qtype.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o qtype.obj `if test -f '../../qtype.cc'; then $(CYGPATH_W) '../../qtype.cc'; else $(CYGPATH_W) '$(srcdir)/../../qtype.cc'; fi` zoneparser-tng.o: ../../zoneparser-tng.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoneparser-tng.o -MD -MP -MF $(DEPDIR)/zoneparser-tng.Tpo -c -o zoneparser-tng.o `test -f '../../zoneparser-tng.cc' || echo '$(srcdir)/'`../../zoneparser-tng.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/zoneparser-tng.Tpo $(DEPDIR)/zoneparser-tng.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../zoneparser-tng.cc' object='zoneparser-tng.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoneparser-tng.o `test -f '../../zoneparser-tng.cc' || echo '$(srcdir)/'`../../zoneparser-tng.cc zoneparser-tng.obj: ../../zoneparser-tng.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoneparser-tng.obj -MD -MP -MF $(DEPDIR)/zoneparser-tng.Tpo -c -o zoneparser-tng.obj `if test -f '../../zoneparser-tng.cc'; then $(CYGPATH_W) '../../zoneparser-tng.cc'; else $(CYGPATH_W) '$(srcdir)/../../zoneparser-tng.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/zoneparser-tng.Tpo $(DEPDIR)/zoneparser-tng.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../zoneparser-tng.cc' object='zoneparser-tng.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoneparser-tng.obj `if test -f '../../zoneparser-tng.cc'; then $(CYGPATH_W) '../../zoneparser-tng.cc'; else $(CYGPATH_W) '$(srcdir)/../../zoneparser-tng.cc'; fi` dnsrecords.o: ../../dnsrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnsrecords.o -MD -MP -MF $(DEPDIR)/dnsrecords.Tpo -c -o dnsrecords.o `test -f '../../dnsrecords.cc' || echo '$(srcdir)/'`../../dnsrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnsrecords.Tpo $(DEPDIR)/dnsrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnsrecords.cc' object='dnsrecords.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnsrecords.o `test -f '../../dnsrecords.cc' || echo '$(srcdir)/'`../../dnsrecords.cc dnsrecords.obj: ../../dnsrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnsrecords.obj -MD -MP -MF $(DEPDIR)/dnsrecords.Tpo -c -o dnsrecords.obj `if test -f '../../dnsrecords.cc'; then $(CYGPATH_W) '../../dnsrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnsrecords.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnsrecords.Tpo $(DEPDIR)/dnsrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnsrecords.cc' object='dnsrecords.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnsrecords.obj `if test -f '../../dnsrecords.cc'; then $(CYGPATH_W) '../../dnsrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnsrecords.cc'; fi` dnswriter.o: ../../dnswriter.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnswriter.o -MD -MP -MF $(DEPDIR)/dnswriter.Tpo -c -o dnswriter.o `test -f '../../dnswriter.cc' || echo '$(srcdir)/'`../../dnswriter.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnswriter.Tpo $(DEPDIR)/dnswriter.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnswriter.cc' object='dnswriter.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnswriter.o `test -f '../../dnswriter.cc' || echo '$(srcdir)/'`../../dnswriter.cc dnswriter.obj: ../../dnswriter.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnswriter.obj -MD -MP -MF $(DEPDIR)/dnswriter.Tpo -c -o dnswriter.obj `if test -f '../../dnswriter.cc'; then $(CYGPATH_W) '../../dnswriter.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnswriter.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnswriter.Tpo $(DEPDIR)/dnswriter.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnswriter.cc' object='dnswriter.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnswriter.obj `if test -f '../../dnswriter.cc'; then $(CYGPATH_W) '../../dnswriter.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnswriter.cc'; fi` rcpgenerator.o: ../../rcpgenerator.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rcpgenerator.o -MD -MP -MF $(DEPDIR)/rcpgenerator.Tpo -c -o rcpgenerator.o `test -f '../../rcpgenerator.cc' || echo '$(srcdir)/'`../../rcpgenerator.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rcpgenerator.Tpo $(DEPDIR)/rcpgenerator.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../rcpgenerator.cc' object='rcpgenerator.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rcpgenerator.o `test -f '../../rcpgenerator.cc' || echo '$(srcdir)/'`../../rcpgenerator.cc rcpgenerator.obj: ../../rcpgenerator.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rcpgenerator.obj -MD -MP -MF $(DEPDIR)/rcpgenerator.Tpo -c -o rcpgenerator.obj `if test -f '../../rcpgenerator.cc'; then $(CYGPATH_W) '../../rcpgenerator.cc'; else $(CYGPATH_W) '$(srcdir)/../../rcpgenerator.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rcpgenerator.Tpo $(DEPDIR)/rcpgenerator.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../rcpgenerator.cc' object='rcpgenerator.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rcpgenerator.obj `if test -f '../../rcpgenerator.cc'; then $(CYGPATH_W) '../../rcpgenerator.cc'; else $(CYGPATH_W) '$(srcdir)/../../rcpgenerator.cc'; fi` dnsparser.o: ../../dnsparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnsparser.o -MD -MP -MF $(DEPDIR)/dnsparser.Tpo -c -o dnsparser.o `test -f '../../dnsparser.cc' || echo '$(srcdir)/'`../../dnsparser.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnsparser.Tpo $(DEPDIR)/dnsparser.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnsparser.cc' object='dnsparser.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnsparser.o `test -f '../../dnsparser.cc' || echo '$(srcdir)/'`../../dnsparser.cc dnsparser.obj: ../../dnsparser.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnsparser.obj -MD -MP -MF $(DEPDIR)/dnsparser.Tpo -c -o dnsparser.obj `if test -f '../../dnsparser.cc'; then $(CYGPATH_W) '../../dnsparser.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnsparser.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnsparser.Tpo $(DEPDIR)/dnsparser.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnsparser.cc' object='dnsparser.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnsparser.obj `if test -f '../../dnsparser.cc'; then $(CYGPATH_W) '../../dnsparser.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnsparser.cc'; fi` base64.o: ../../base64.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base64.o -MD -MP -MF $(DEPDIR)/base64.Tpo -c -o base64.o `test -f '../../base64.cc' || echo '$(srcdir)/'`../../base64.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/base64.Tpo $(DEPDIR)/base64.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../base64.cc' object='base64.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base64.o `test -f '../../base64.cc' || echo '$(srcdir)/'`../../base64.cc base64.obj: ../../base64.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base64.obj -MD -MP -MF $(DEPDIR)/base64.Tpo -c -o base64.obj `if test -f '../../base64.cc'; then $(CYGPATH_W) '../../base64.cc'; else $(CYGPATH_W) '$(srcdir)/../../base64.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/base64.Tpo $(DEPDIR)/base64.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../base64.cc' object='base64.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base64.obj `if test -f '../../base64.cc'; then $(CYGPATH_W) '../../base64.cc'; else $(CYGPATH_W) '$(srcdir)/../../base64.cc'; fi` sillyrecords.o: ../../sillyrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sillyrecords.o -MD -MP -MF $(DEPDIR)/sillyrecords.Tpo -c -o sillyrecords.o `test -f '../../sillyrecords.cc' || echo '$(srcdir)/'`../../sillyrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sillyrecords.Tpo $(DEPDIR)/sillyrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../sillyrecords.cc' object='sillyrecords.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sillyrecords.o `test -f '../../sillyrecords.cc' || echo '$(srcdir)/'`../../sillyrecords.cc sillyrecords.obj: ../../sillyrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sillyrecords.obj -MD -MP -MF $(DEPDIR)/sillyrecords.Tpo -c -o sillyrecords.obj `if test -f '../../sillyrecords.cc'; then $(CYGPATH_W) '../../sillyrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../sillyrecords.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sillyrecords.Tpo $(DEPDIR)/sillyrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../sillyrecords.cc' object='sillyrecords.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sillyrecords.obj `if test -f '../../sillyrecords.cc'; then $(CYGPATH_W) '../../sillyrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../sillyrecords.cc'; fi` nsecrecords.o: ../../nsecrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT nsecrecords.o -MD -MP -MF $(DEPDIR)/nsecrecords.Tpo -c -o nsecrecords.o `test -f '../../nsecrecords.cc' || echo '$(srcdir)/'`../../nsecrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nsecrecords.Tpo $(DEPDIR)/nsecrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../nsecrecords.cc' object='nsecrecords.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o nsecrecords.o `test -f '../../nsecrecords.cc' || echo '$(srcdir)/'`../../nsecrecords.cc nsecrecords.obj: ../../nsecrecords.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT nsecrecords.obj -MD -MP -MF $(DEPDIR)/nsecrecords.Tpo -c -o nsecrecords.obj `if test -f '../../nsecrecords.cc'; then $(CYGPATH_W) '../../nsecrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../nsecrecords.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/nsecrecords.Tpo $(DEPDIR)/nsecrecords.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../nsecrecords.cc' object='nsecrecords.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o nsecrecords.obj `if test -f '../../nsecrecords.cc'; then $(CYGPATH_W) '../../nsecrecords.cc'; else $(CYGPATH_W) '$(srcdir)/../../nsecrecords.cc'; fi` dnssecinfra.o: ../../dnssecinfra.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnssecinfra.o -MD -MP -MF $(DEPDIR)/dnssecinfra.Tpo -c -o dnssecinfra.o `test -f '../../dnssecinfra.cc' || echo '$(srcdir)/'`../../dnssecinfra.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnssecinfra.Tpo $(DEPDIR)/dnssecinfra.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnssecinfra.cc' object='dnssecinfra.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnssecinfra.o `test -f '../../dnssecinfra.cc' || echo '$(srcdir)/'`../../dnssecinfra.cc dnssecinfra.obj: ../../dnssecinfra.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dnssecinfra.obj -MD -MP -MF $(DEPDIR)/dnssecinfra.Tpo -c -o dnssecinfra.obj `if test -f '../../dnssecinfra.cc'; then $(CYGPATH_W) '../../dnssecinfra.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnssecinfra.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dnssecinfra.Tpo $(DEPDIR)/dnssecinfra.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dnssecinfra.cc' object='dnssecinfra.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dnssecinfra.obj `if test -f '../../dnssecinfra.cc'; then $(CYGPATH_W) '../../dnssecinfra.cc'; else $(CYGPATH_W) '$(srcdir)/../../dnssecinfra.cc'; fi` base32.o: ../../base32.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base32.o -MD -MP -MF $(DEPDIR)/base32.Tpo -c -o base32.o `test -f '../../base32.cc' || echo '$(srcdir)/'`../../base32.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/base32.Tpo $(DEPDIR)/base32.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../base32.cc' object='base32.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base32.o `test -f '../../base32.cc' || echo '$(srcdir)/'`../../base32.cc base32.obj: ../../base32.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base32.obj -MD -MP -MF $(DEPDIR)/base32.Tpo -c -o base32.obj `if test -f '../../base32.cc'; then $(CYGPATH_W) '../../base32.cc'; else $(CYGPATH_W) '$(srcdir)/../../base32.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/base32.Tpo $(DEPDIR)/base32.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../base32.cc' object='base32.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base32.obj `if test -f '../../base32.cc'; then $(CYGPATH_W) '../../base32.cc'; else $(CYGPATH_W) '$(srcdir)/../../base32.cc'; fi` dns_random.o: ../../aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns_random.o -MD -MP -MF $(DEPDIR)/dns_random.Tpo -c -o dns_random.o `test -f '../../aes/dns_random.cc' || echo '$(srcdir)/'`../../aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns_random.Tpo $(DEPDIR)/dns_random.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../aes/dns_random.cc' object='dns_random.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns_random.o `test -f '../../aes/dns_random.cc' || echo '$(srcdir)/'`../../aes/dns_random.cc dns_random.obj: ../../aes/dns_random.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns_random.obj -MD -MP -MF $(DEPDIR)/dns_random.Tpo -c -o dns_random.obj `if test -f '../../aes/dns_random.cc'; then $(CYGPATH_W) '../../aes/dns_random.cc'; else $(CYGPATH_W) '$(srcdir)/../../aes/dns_random.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns_random.Tpo $(DEPDIR)/dns_random.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../aes/dns_random.cc' object='dns_random.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns_random.obj `if test -f '../../aes/dns_random.cc'; then $(CYGPATH_W) '../../aes/dns_random.cc'; else $(CYGPATH_W) '$(srcdir)/../../aes/dns_random.cc'; fi` dns.o: ../../dns.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns.o -MD -MP -MF $(DEPDIR)/dns.Tpo -c -o dns.o `test -f '../../dns.cc' || echo '$(srcdir)/'`../../dns.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns.Tpo $(DEPDIR)/dns.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dns.cc' object='dns.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns.o `test -f '../../dns.cc' || echo '$(srcdir)/'`../../dns.cc dns.obj: ../../dns.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT dns.obj -MD -MP -MF $(DEPDIR)/dns.Tpo -c -o dns.obj `if test -f '../../dns.cc'; then $(CYGPATH_W) '../../dns.cc'; else $(CYGPATH_W) '$(srcdir)/../../dns.cc'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dns.Tpo $(DEPDIR)/dns.Po @am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../../dns.cc' object='dns.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o dns.obj `if test -f '../../dns.cc'; then $(CYGPATH_W) '../../dns.cc'; else $(CYGPATH_W) '$(srcdir)/../../dns.cc'; fi` .l.c: $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) .yy.cc: $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f bindlexer.c -rm -f bindparser.cc -rm -f bindparser.h -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool clean-noinstLTLIBRARIES ctags \ distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS bind-dnssec.schema.sqlite3.sql.h: ../../bind-dnssec.schema.sqlite3.sql ( echo 'static char sqlCreate[] __attribute__((unused))=' ; sed 's/$$/"/g' ../../bind-dnssec.schema.sqlite3.sql | sed 's/^/"/g' ; echo ';' ) > $@ dnslabeltext.cc: ../../dnslabeltext.rl ragel ../../dnslabeltext.rl -o dnslabeltext.cc .hh.h: cp $< $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: pdns-3.3/pdns/backends/bind/bindlexer.c0000644000014601777760000015461412165464054021357 0ustar00jenkinsnogroup00000000000000 #line 3 "bindlexer.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart(yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart (FILE *input_file ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); void yypop_buffer_state (void ); static void yyensure_buffer_stack (void ); static void yy_load_buffer_state (void ); static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; int yylineno = 1; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 30 #define YY_END_OF_BUFFER 31 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[109] = { 0, 21, 21, 2, 2, 7, 7, 19, 19, 31, 21, 26, 25, 18, 21, 21, 24, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 23, 2, 4, 3, 30, 7, 30, 19, 20, 21, 26, 21, 0, 28, 1, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 2, 3, 3, 5, 7, 0, 19, 21, 0, 27, 13, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 21, 21, 10, 21, 21, 21, 21, 17, 9, 8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 6, 14, 16, 11, 21, 21, 21, 15, 21, 12, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 5, 1, 1, 1, 1, 1, 1, 6, 1, 1, 7, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 10, 1, 11, 12, 13, 14, 15, 1, 16, 1, 1, 17, 18, 19, 20, 21, 1, 22, 23, 24, 25, 1, 1, 1, 26, 27, 1, 1, 1, 1, 1, 1, 28, 1, 29, 30, 31, 32, 33, 1, 34, 1, 1, 35, 36, 37, 38, 39, 1, 40, 41, 42, 43, 1, 1, 1, 44, 45, 46, 1, 47, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[48] = { 0, 1, 2, 3, 4, 1, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6 } ; static yyconst flex_int16_t yy_base[121] = { 0, 0, 0, 45, 46, 51, 52, 192, 165, 131, 0, 119, 285, 285, 55, 57, 285, 51, 50, 51, 50, 50, 61, 51, 47, 54, 285, 285, 0, 285, 69, 285, 74, 0, 0, 285, 0, 118, 91, 116, 285, 0, 94, 64, 81, 83, 89, 96, 93, 86, 86, 90, 93, 0, 107, 108, 285, 130, 78, 0, 140, 76, 285, 0, 97, 105, 120, 117, 130, 122, 131, 135, 137, 69, 43, 142, 0, 129, 139, 143, 137, 0, 0, 285, 139, 135, 148, 142, 140, 148, 150, 161, 169, 168, 161, 166, 166, 169, 0, 0, 0, 0, 176, 167, 180, 0, 169, 0, 285, 213, 219, 225, 231, 236, 242, 248, 254, 260, 266, 272, 278 } ; static yyconst flex_int16_t yy_def[121] = { 0, 108, 1, 109, 109, 110, 110, 111, 111, 108, 112, 108, 108, 108, 113, 112, 108, 112, 112, 112, 112, 112, 112, 112, 112, 112, 108, 108, 114, 108, 115, 108, 108, 116, 117, 108, 112, 108, 113, 118, 108, 112, 119, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 114, 115, 115, 108, 108, 116, 117, 119, 120, 108, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 108, 112, 112, 112, 112, 112, 112, 112, 112, 112, 108, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 0, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108 } ; static yyconst flex_int16_t yy_nxt[333] = { 0, 10, 11, 12, 13, 14, 10, 10, 15, 16, 17, 10, 18, 10, 19, 10, 20, 21, 22, 10, 23, 10, 10, 10, 24, 10, 10, 25, 17, 10, 18, 10, 19, 10, 20, 21, 22, 10, 23, 10, 10, 10, 24, 10, 10, 25, 26, 27, 29, 29, 84, 30, 30, 32, 32, 33, 33, 39, 40, 39, 32, 32, 43, 41, 39, 42, 45, 46, 44, 47, 48, 49, 50, 51, 52, 55, 57, 56, 83, 62, 43, 63, 73, 57, 45, 46, 44, 47, 48, 49, 50, 51, 52, 39, 40, 39, 61, 62, 61, 63, 39, 39, 39, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 108, 55, 108, 56, 74, 75, 40, 37, 37, 64, 65, 66, 67, 68, 69, 70, 71, 72, 108, 57, 76, 77, 74, 75, 39, 39, 57, 61, 61, 61, 62, 61, 78, 79, 80, 81, 61, 82, 76, 77, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 78, 79, 80, 81, 95, 82, 35, 96, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 97, 98, 99, 100, 95, 61, 61, 96, 101, 102, 103, 104, 105, 106, 107, 35, 108, 108, 97, 98, 99, 100, 108, 108, 108, 108, 101, 102, 103, 104, 105, 106, 107, 28, 28, 28, 28, 28, 28, 31, 31, 31, 31, 31, 31, 34, 34, 34, 34, 34, 34, 36, 108, 108, 108, 36, 38, 38, 38, 38, 38, 38, 53, 53, 108, 53, 108, 53, 54, 54, 108, 54, 54, 54, 58, 108, 108, 108, 58, 58, 59, 59, 59, 108, 59, 59, 39, 39, 39, 39, 39, 39, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 9, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108 } ; static yyconst flex_int16_t yy_chk[333] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 74, 3, 4, 5, 6, 5, 6, 14, 14, 14, 5, 6, 17, 15, 14, 15, 18, 19, 17, 20, 21, 22, 23, 24, 25, 30, 32, 30, 73, 61, 17, 43, 58, 32, 18, 19, 17, 20, 21, 22, 23, 24, 25, 38, 38, 38, 42, 42, 42, 43, 38, 14, 14, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 54, 55, 64, 65, 39, 37, 11, 44, 45, 46, 47, 48, 49, 50, 51, 52, 9, 57, 66, 67, 64, 65, 38, 38, 57, 42, 42, 60, 60, 60, 68, 69, 70, 71, 60, 72, 66, 67, 75, 77, 78, 79, 80, 84, 85, 86, 87, 88, 68, 69, 70, 71, 89, 72, 8, 90, 75, 77, 78, 79, 80, 84, 85, 86, 87, 88, 91, 92, 93, 94, 89, 60, 60, 90, 95, 96, 97, 102, 103, 104, 106, 7, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 95, 96, 97, 102, 103, 104, 106, 109, 109, 109, 109, 109, 109, 110, 110, 110, 110, 110, 110, 111, 111, 111, 111, 111, 111, 112, 0, 0, 0, 112, 113, 113, 113, 113, 113, 113, 114, 114, 0, 114, 0, 114, 115, 115, 0, 115, 115, 115, 116, 0, 0, 0, 116, 116, 117, 117, 117, 0, 117, 117, 118, 118, 118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 120, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "bindlexer.l" #line 2 "bindlexer.l" #include #include #include #include #define YY_NO_INPUT 1 #define YYSTYPE char * #ifdef WIN32 #include "bindparser.tab.hh" extern "C" { int isatty( int ); int yywrap() { return 1; } } #else #include "bindparser.h" #endif // WIN32 int linenumber; #define MAX_INCLUDE_DEPTH 10 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ln[MAX_INCLUDE_DEPTH]; char *include_stack_name[MAX_INCLUDE_DEPTH]; char *current_filename; char *original_filename; int include_stack_ptr = 0; extern const char *bind_directory; #define YY_NO_INPUT 1 #line 609 "bindlexer.c" #define INITIAL 0 #define comment 1 #define incl 2 #define quoted 3 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int yylex_destroy (void ); int yyget_debug (void ); void yyset_debug (int debug_flag ); YY_EXTRA_TYPE yyget_extra (void ); void yyset_extra (YY_EXTRA_TYPE user_defined ); FILE *yyget_in (void ); void yyset_in (FILE * in_str ); FILE *yyget_out (void ); void yyset_out (FILE * out_str ); int yyget_leng (void ); char *yyget_text (void ); int yyget_lineno (void ); void yyset_lineno (int line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap (void ); #else extern int yywrap (void ); #endif #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif #endif static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = NULL; static void yy_push_state (int new_state ); static void yy_pop_state (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int yylex (void); #define YY_DECL int yylex (void) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 47 "bindlexer.l" #line 809 "bindlexer.c" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 109 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 285 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: YY_RULE_SETUP #line 50 "bindlexer.l" BEGIN(comment); YY_BREAK case 2: YY_RULE_SETUP #line 51 "bindlexer.l" /* eat anything that's not a '*' */ YY_BREAK case 3: YY_RULE_SETUP #line 52 "bindlexer.l" /* eat up '*'s not followed by '/'s */ YY_BREAK case 4: /* rule 4 can match eol */ YY_RULE_SETUP #line 53 "bindlexer.l" ++linenumber; YY_BREAK case 5: YY_RULE_SETUP #line 54 "bindlexer.l" BEGIN(INITIAL); YY_BREAK case 6: YY_RULE_SETUP #line 56 "bindlexer.l" BEGIN(incl); YY_BREAK case 7: YY_RULE_SETUP #line 57 "bindlexer.l" /* eat the whitespace */ YY_BREAK case 8: YY_RULE_SETUP #line 58 "bindlexer.l" { /* got the include file name */ char filename[1024]; if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) { fprintf( stderr, "Includes nested too deeply" ); exit( 1 ); } yytext[strlen(yytext)-2]=0; include_stack[include_stack_ptr]=YY_CURRENT_BUFFER; include_stack_name[include_stack_ptr]=current_filename=strdup(yytext+1); include_stack_ln[include_stack_ptr++]=linenumber; linenumber=1; if(*(yytext+1)=='/') strcpy(filename,yytext+1); else { strcpy(filename,bind_directory); strcat(filename,"/"); strcat(filename,yytext+1); } if (*yytext &&!(yyin=fopen(filename,"r"))) { fprintf( stderr, "Unable to open '%s': %s\n",filename,strerror(errno)); exit( 1 ); } BEGIN(INITIAL); yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); } YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(comment): case YY_STATE_EOF(incl): case YY_STATE_EOF(quoted): #line 91 "bindlexer.l" { if ( --include_stack_ptr < 0 ) { yyterminate(); } else { fclose(yyin); yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(include_stack[include_stack_ptr]); linenumber=include_stack_ln[include_stack_ptr]; free(include_stack_name[include_stack_ptr]); if(include_stack_ptr) current_filename=include_stack_name[include_stack_ptr-1]; else current_filename=original_filename; } } YY_BREAK case 9: YY_RULE_SETUP #line 114 "bindlexer.l" return ZONETOK; YY_BREAK case 10: YY_RULE_SETUP #line 116 "bindlexer.l" return FILETOK; YY_BREAK case 11: YY_RULE_SETUP #line 117 "bindlexer.l" return OPTIONSTOK; YY_BREAK case 12: YY_RULE_SETUP #line 118 "bindlexer.l" return ALSONOTIFYTOK; YY_BREAK case 13: YY_RULE_SETUP #line 119 "bindlexer.l" return ACLTOK; YY_BREAK case 14: YY_RULE_SETUP #line 120 "bindlexer.l" return LOGGINGTOK; YY_BREAK case 15: YY_RULE_SETUP #line 121 "bindlexer.l" return DIRECTORYTOK; YY_BREAK case 16: YY_RULE_SETUP #line 122 "bindlexer.l" return MASTERTOK; YY_BREAK case 17: YY_RULE_SETUP #line 123 "bindlexer.l" return TYPETOK; YY_BREAK case 18: YY_RULE_SETUP #line 124 "bindlexer.l" yy_push_state(quoted); YY_BREAK case 19: /* rule 19 can match eol */ YY_RULE_SETUP #line 125 "bindlexer.l" yylval=strdup(yytext); return QUOTEDWORD; YY_BREAK case 20: YY_RULE_SETUP #line 126 "bindlexer.l" yy_pop_state(); YY_BREAK case 21: YY_RULE_SETUP #line 127 "bindlexer.l" yylval=strdup(yytext);return AWORD; YY_BREAK case 22: YY_RULE_SETUP #line 128 "bindlexer.l" return OBRACE; YY_BREAK case 23: YY_RULE_SETUP #line 129 "bindlexer.l" return EBRACE; YY_BREAK case 24: YY_RULE_SETUP #line 130 "bindlexer.l" return SEMICOLON; YY_BREAK case 25: /* rule 25 can match eol */ YY_RULE_SETUP #line 131 "bindlexer.l" linenumber++; YY_BREAK case 26: YY_RULE_SETUP #line 132 "bindlexer.l" ; YY_BREAK case 27: *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 133 "bindlexer.l" ; YY_BREAK case 28: *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 134 "bindlexer.l" ; YY_BREAK case 29: YY_RULE_SETUP #line 135 "bindlexer.l" { fprintf(stderr,"Parsing '%s': unable to parse line %d at character '%s'\n",current_filename, linenumber, yytext); exit(1); } YY_BREAK case 30: YY_RULE_SETUP #line 138 "bindlexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK #line 1108 "bindlexer.c" case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (void) { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart(yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 109 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 109 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 108); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) #else static int input (void) #endif { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_init_buffer(YY_CURRENT_BUFFER,input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer(b,file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ); yyfree((void *) b ); } #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void yyensure_buffer_stack (void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer(b ); return b; } /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } static void yy_push_state (int new_state ) { if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) { yy_size_t new_size; (yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_start_stack_depth) * sizeof( int ); if ( ! (yy_start_stack) ) (yy_start_stack) = (int *) yyalloc(new_size ); else (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size ); if ( ! (yy_start_stack) ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; BEGIN(new_state); } static void yy_pop_state (void) { if ( --(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg ) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ int yyget_lineno (void) { return yylineno; } /** Get the input stream. * */ FILE *yyget_in (void) { return yyin; } /** Get the output stream. * */ FILE *yyget_out (void) { return yyout; } /** Get the length of the current token. * */ int yyget_leng (void) { return yyleng; } /** Get the current token. * */ char *yyget_text (void) { return yytext; } /** Set the current line number. * @param line_number * */ void yyset_lineno (int line_number ) { yylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * * @see yy_switch_to_buffer */ void yyset_in (FILE * in_str ) { yyin = in_str ; } void yyset_out (FILE * out_str ) { yyout = out_str ; } int yyget_debug (void) { return yy_flex_debug; } void yyset_debug (int bdebug ) { yy_flex_debug = bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. */ (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; (yy_start_stack_ptr) = 0; (yy_start_stack_depth) = 0; (yy_start_stack) = NULL; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * yylex_init() */ return 0; } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } /* Destroy the stack itself. */ yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Destroy the start condition stack. */ yyfree((yy_start_stack) ); (yy_start_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size ) { return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr ) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 138 "bindlexer.l" pdns-3.3/pdns/backends/bind/TODO0000644000014601777760000000037312136555572017723 0ustar00jenkinsnogroup00000000000000Stuff not working yet in zone2sql/bindbackend: $TTL Symbol notations of SOA, with 1H standing for 3600 etc We can't handle filenames that are mentioned multiply in named.conf it appears Reading zones only 1 time per all threads and not every time pdns-3.3/pdns/backends/bind/dnslabeltext.cc0000644000014601777760000001235112165464055022227 0ustar00jenkinsnogroup00000000000000 #line 1 "../../dnslabeltext.rl" #include #include #include #include #include #include "namespaces.hh" namespace { void appendSplit(vector& ret, string& segment, char c) { if(segment.size()>254) { ret.push_back(segment); segment.clear(); } segment.append(1, c); } } vector segmentDNSText(const string& input ) { #line 26 "dnslabeltext.cc" static const char _dnstext_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 0, 1, 2, 4, 5 }; static const char _dnstext_key_offsets[] = { 0, 0, 1, 8, 10, 12, 14, 21, 25 }; static const char _dnstext_trans_keys[] = { 34, 34, 92, 127, 0, 8, 11, 31, 48, 57, 48, 57, 48, 57, 34, 92, 127, 0, 8, 11, 31, 32, 34, 9, 13, 34, 0 }; static const char _dnstext_single_lengths[] = { 0, 1, 3, 0, 0, 0, 3, 2, 1 }; static const char _dnstext_range_lengths[] = { 0, 0, 2, 1, 1, 1, 2, 1, 0 }; static const char _dnstext_index_offsets[] = { 0, 0, 2, 8, 10, 12, 14, 20, 24 }; static const char _dnstext_trans_targs[] = { 2, 0, 7, 3, 0, 0, 0, 2, 4, 2, 5, 0, 6, 0, 7, 3, 0, 0, 0, 2, 8, 2, 8, 0, 2, 0, 0 }; static const char _dnstext_trans_actions[] = { 3, 0, 0, 0, 0, 0, 0, 11, 7, 5, 7, 0, 7, 0, 9, 9, 0, 0, 0, 16, 0, 13, 0, 0, 13, 0, 0 }; static const char _dnstext_eof_actions[] = { 0, 0, 0, 0, 0, 0, 0, 1, 1 }; static const int dnstext_start = 1; static const int dnstext_first_final = 7; static const int dnstext_error = 0; static const int dnstext_en_main = 1; #line 25 "../../dnslabeltext.rl" (void)dnstext_error; // silence warnings (void)dnstext_en_main; const char *p = input.c_str(), *pe = input.c_str() + input.length(); const char* eof = pe; int cs; char val = 0; string segment; vector ret; #line 99 "dnslabeltext.cc" { cs = dnstext_start; } #line 104 "dnslabeltext.cc" { int _klen; unsigned int _trans; const char *_acts; unsigned int _nacts; const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: _keys = _dnstext_trans_keys + _dnstext_key_offsets[cs]; _trans = _dnstext_index_offsets[cs]; _klen = _dnstext_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + _klen - 1; while (1) { if ( _upper < _lower ) break; _mid = _lower + ((_upper-_lower) >> 1); if ( (*p) < *_mid ) _upper = _mid - 1; else if ( (*p) > *_mid ) _lower = _mid + 1; else { _trans += (_mid - _keys); goto _match; } } _keys += _klen; _trans += _klen; } _klen = _dnstext_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + (_klen<<1) - 2; while (1) { if ( _upper < _lower ) break; _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( (*p) < _mid[0] ) _upper = _mid - 2; else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { _trans += ((_mid - _keys)>>1); goto _match; } } _trans += _klen; } _match: cs = _dnstext_trans_targs[_trans]; if ( _dnstext_trans_actions[_trans] == 0 ) goto _again; _acts = _dnstext_actions + _dnstext_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: #line 37 "../../dnslabeltext.rl" { ret.push_back(segment); segment.clear(); } break; case 1: #line 41 "../../dnslabeltext.rl" { segment.clear(); } break; case 2: #line 45 "../../dnslabeltext.rl" { char c = *p; appendSplit(ret, segment, c); } break; case 3: #line 49 "../../dnslabeltext.rl" { char c = *p; val *= 10; val += c-'0'; } break; case 4: #line 55 "../../dnslabeltext.rl" { appendSplit(ret, segment, val); val=0; } break; case 5: #line 60 "../../dnslabeltext.rl" { appendSplit(ret, segment, *(p)); } break; #line 219 "dnslabeltext.cc" } } _again: if ( cs == 0 ) goto _out; if ( ++p != pe ) goto _resume; _test_eof: {} if ( p == eof ) { const char *__acts = _dnstext_actions + _dnstext_eof_actions[cs]; unsigned int __nacts = (unsigned int) *__acts++; while ( __nacts-- > 0 ) { switch ( *__acts++ ) { case 0: #line 37 "../../dnslabeltext.rl" { ret.push_back(segment); segment.clear(); } break; #line 242 "dnslabeltext.cc" } } } _out: {} } #line 73 "../../dnslabeltext.rl" if ( cs < dnstext_first_final ) { throw runtime_error("Unable to parse DNS TXT '"+input+"'"); } return ret; }; #if 0 int main() { //char blah[]="\"blah\" \"bleh\" \"bloeh\\\"bleh\" \"\\97enzo\""; char blah[]="\"v=spf1 ip4:67.106.74.128/25 ip4:63.138.42.224/28 ip4:65.204.46.224/27 \\013\\010ip4:66.104.217.176/28 \\013\\010ip4:209.48.147.0/27 ~all\""; //char blah[]="\"abc \\097\\098 def\""; printf("Input: '%s'\n", blah); vector res=dnstext(blah); cerr<. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { AWORD = 258, QUOTEDWORD = 259, OBRACE = 260, EBRACE = 261, SEMICOLON = 262, ZONETOK = 263, FILETOK = 264, OPTIONSTOK = 265, DIRECTORYTOK = 266, ACLTOK = 267, LOGGINGTOK = 268, CLASSTOK = 269, TYPETOK = 270, MASTERTOK = 271, ALSONOTIFYTOK = 272 }; #endif /* Tokens. */ #define AWORD 258 #define QUOTEDWORD 259 #define OBRACE 260 #define EBRACE 261 #define SEMICOLON 262 #define ZONETOK 263 #define FILETOK 264 #define OPTIONSTOK 265 #define DIRECTORYTOK 266 #define ACLTOK 267 #define LOGGINGTOK 268 #define CLASSTOK 269 #define TYPETOK 270 #define MASTERTOK 271 #define ALSONOTIFYTOK 272 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; pdns-3.3/pdns/backends/bind/zone2ldap.cc0000644000014601777760000001746112140444471021434 0ustar00jenkinsnogroup00000000000000/* * PowerDNS BIND Zone to LDAP converter * Copyright (C) 2003 Norbert Sendetzky * Copyright (C) 2007 bert hubert * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * the Free Software Foundation * * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include "arguments.hh" #include "bindparserclasses.hh" #include "statbag.hh" #include #include "dnsrecords.hh" #include "misc.hh" #include "dns.hh" #include "zoneparser-tng.hh" using std::map; using std::string; using std::vector; StatBag S; ArgvMap args; bool g_dnsttl; string g_basedn; string g_zonename; map g_objects; static void callback_simple( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio ) { string host; string::size_type pos; vector parts; string domain2 = stripDot( domain ); if( ( pos = domain2.rfind( g_zonename ) ) == string::npos ) { cerr << "Domain " << domain2 << " not part of " << g_zonename << endl; return; } host = stripDot( domain2.substr( 0, pos ) ); cout << "dn: dc="; if( !host.empty() ) { cout << host << ",dc="; } cout << g_zonename << "," << g_basedn << endl; if( host.empty() ) { host = g_zonename; } if( !g_objects[domain2] ) { g_objects[domain2] = true; cout << "changetype: add" << endl; cout << "objectclass: dnsdomain2" << endl; cout << "objectclass: domainrelatedobject" << endl; cout << "dc: " << host << endl; if( g_dnsttl ) { cout << "dnsttl: " << ttl << endl; } cout << "associateddomain: " << domain2 << endl; } else { cout << "changetype: modify" << endl; cout << "add: " << qtype << "Record" << endl; } cout << qtype << "Record: "; if( prio != 0 ) { cout << prio << " "; } cout << stripDot( content ) << endl << endl; } static void callback_tree( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio ) { unsigned int i; string dn, net; vector parts; string domain2 = stripDot( domain ); stringtok( parts, domain2, "." ); if( parts.empty() ) { return; } for( i = parts.size() - 1; i > 0; i-- ) { net = parts[i] + net; dn = "dc=" + parts[i] + "," + dn; if( !g_objects[net] ) { g_objects[net] = true; cout << "dn: " << dn << g_basedn << endl; cout << "changetype: add" << endl; cout << "objectclass: dnsdomain2" << endl; cout << "objectclass: domainrelatedobject" << endl; cout << "dc: " << parts[i] << endl; cout << "associateddomain: " << net << endl << endl; } net = "." + net; } cout << "dn: " << "dc=" << parts[0] << "," << dn << g_basedn << endl; if( !g_objects[domain2] ) { g_objects[domain2] = true; cout << "changetype: add" << endl; cout << "objectclass: dnsdomain2" << endl; cout << "objectclass: domainrelatedobject" << endl; cout << "dc: " << parts[0] << endl; if( g_dnsttl ) { cout << "dnsttl: " << ttl << endl; } cout << "associateddomain: " << domain2 << endl; } else { cout << "changetype: modify" << endl; cout << "add: " << qtype << "Record" << endl; } cout << qtype << "Record: "; if( prio != 0 ) { cout << prio << " "; } cout << stripDot( content ) << endl << endl; } int main( int argc, char* argv[] ) { BindParser BP; vector parts; try { #if __GNUC__ >= 3 std::ios_base::sync_with_stdio( false ); #endif reportAllTypes(); args.setCmd( "help", "Provide a helpful message" ); args.setSwitch( "verbose", "Verbose comments on operation" ) = "no"; args.setSwitch( "resume", "Continue after errors" ) = "no"; args.setSwitch( "dnsttl", "Add dnsttl attribute to every entry" ) = "no"; args.set( "named-conf", "Bind 8 named.conf to parse" ) = ""; args.set( "zone-file", "Zone file to parse" ) = ""; args.set( "zone-name", "Specify a zone name if zone is set" ) = ""; args.set( "basedn", "Base DN to store objects below" ) = "ou=hosts,o=mycompany,c=de"; args.set( "layout", "How to arrange entries in the directory (simple or as tree)" ) = "simple"; args.parse( argc, argv ); if( argc < 2 || args.mustDo( "help" ) ) { cerr << "Syntax:" << endl << endl; cerr << args.helpstring() << endl; exit( 1 ); } g_basedn = args["basedn"]; g_dnsttl = args.mustDo( "dnsttl" ); typedef boost::function callback_t; callback_t callback = callback_simple; if( args["layout"] == "tree" ) { callback=callback_tree; } if( !args["named-conf"].empty() ) { BP.setVerbose( args.mustDo( "verbose" ) ); BP.parse( args["named-conf"] ); // ZP.setDirectory( BP.getDirectory() ); const vector &domains = BP.getDomains(); for( vector::const_iterator i = domains.begin(); i != domains.end(); i++ ) { if(i->type!="master" && i->type!="slave") { cerr<<" Warning! Skipping '"<type<<"' zone '"<name<<"'"<name != "." && i->name != "localhost" && i->name != "0.0.127.in-addr.arpa" ) { cerr << "Parsing file: " << i->filename << ", domain: " << i->name << endl; g_zonename = i->name; ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory()); DNSResourceRecord rr; while(zpt.get(rr)) callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); } } catch( AhuException &ae ) { cerr << "Fatal error: " << ae.reason << endl; if( !args.mustDo( "resume" ) ) { return 1; } } } } else { if( args["zone-file"].empty() || args["zone-name"].empty() ) { cerr << "Error: At least zone-file and zone-name are required" << endl; return 1; } g_zonename = args["zone-name"]; ZoneParserTNG zpt(args["zone-file"], args["zone-name"]); DNSResourceRecord rr; while(zpt.get(rr)) callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); } } catch( AhuException &ae ) { cerr << "Fatal error: " << ae.reason << endl; return 1; } catch( std::exception &e ) { cerr << "Died because of STL error: " << e.what() << endl; return 1; } catch( ... ) { cerr << "Died because of unknown exception" << endl; return 1; } return 0; } pdns-3.3/pdns/backends/bind/ylwrap0000755000014601777760000000764412136555572020507 0ustar00jenkinsnogroup00000000000000#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. # Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, 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. # Usage: # ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... # * INPUT is the input file # * OUTPUT is file PROG generates # * DESIRED is file we actually want # * PROGRAM is program to run # * ARGS are passed to PROG # Any number of OUTPUT,DESIRED pairs may be used. # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'` echo "got $input_rx" pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname $prog ${1+"$@"} "$input" status=$? if test $status -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # Edit out `#line' or `#' directives. We don't want the # resulting debug information to point at an absolute srcdir; # it is better for it to just mention the .y file with no # path. sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$? else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then status=1 fi fi shift shift first=no done else status=$? fi # Remove the directory. cd .. rm -rf $dirname exit $status pdns-3.3/pdns/backends/bind/Makefile.am0000644000014601777760000000624012150646616021262 0ustar00jenkinsnogroup00000000000000noinst_LTLIBRARIES = libbind2backend.la AM_CPPFLAGS=-I../.. $(BOOST_CPPFLAGS) @THREADFLAGS@ BUILT_SOURCES=bind-dnssec.schema.sqlite3.sql.h bindparser.h bind-dnssec.schema.sqlite3.sql.h: ../../bind-dnssec.schema.sqlite3.sql ( echo 'static char sqlCreate[] __attribute__((unused))=' ; sed 's/$$/"/g' ../../bind-dnssec.schema.sqlite3.sql | sed 's/^/"/g' ; echo ';' ) > $@ libbind2backend_la_SOURCES=bindbackend2.cc bindbackend2.hh bindparser.yy \ bindlexer.l ../../zoneparser-tng.cc ../../misc.cc \ bindparserclasses.hh ../../unix_utility.cc binddnssec.cc bind-dnssec.schema.sqlite3.sql.h libbind2backend_la_CXXFLAGS=$(AM_CXXFLAGS) libbind2backend_la_CFLAGS=$(AM_CFLAGS) libbind2backend_la_LDFLAGS=-module -avoid-version bin_PROGRAMS = zone2sql zone2ldap zone2json EXTRA_DIST=dnslabeltext.cc bindparser.cc bindparser.h bind-dnssec.schema.sqlite3.sql.h zone2sql_SOURCES=bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2sql.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../dns.cc \ ../../zoneparser-tng.cc ../../dnsrecords.cc ../../sillyrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc ../../aes/dns_random.cc \ ../../aes/aescpp.h ../../aes/aescrypt.c ../../aes/aes.h ../../aes/aeskey.c ../../aes/aes_modes.c ../../aes/aesopt.h \ ../../aes/aestab.c ../../aes/aestab.h ../../aes/brg_endian.h ../../aes/brg_types.h # ../../dbdnsseckeeper.cc zone2json_SOURCES=bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2json.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../zoneparser-tng.cc ../../dnsrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc ../../sillyrecords.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc zone2ldap_SOURCES=bindparser.yy bindlexer.l bind-dnssec.schema.sqlite3.sql.h \ ../../arguments.cc ../../logger.cc zone2ldap.cc ../../statbag.cc ../../misc.cc \ ../../unix_utility.cc ../../qtype.cc ../../zoneparser-tng.cc ../../dnsrecords.cc \ ../../dnswriter.cc dnslabeltext.cc ../../rcpgenerator.cc ../../dnsparser.cc ../../base64.cc ../../sillyrecords.cc \ ../../nsecrecords.cc ../../dnssecinfra.cc ../../base32.cc ../../aes/dns_random.cc \ ../../aes/aescpp.h ../../aes/aescrypt.c ../../aes/aes.h ../../aes/aeskey.c ../../aes/aes_modes.c ../../aes/aesopt.h \ ../../aes/aestab.c ../../aes/aestab.h ../../aes/brg_endian.h ../../aes/brg_types.h # ../../dbdnsseckeeper.cc zone2ldap_LDFLAGS=@THREADFLAGS@ if HAVE_LIBPOLARSSL zone2ldap_LDADD= else zone2ldap_LDADD= ../../ext/polarssl-1.1.2/library/libpolarssl.a endif zone2sql_LDFLAGS=@THREADFLAGS@ if HAVE_LIBPOLARSSL zone2sql_LDADD= else zone2sql_LDADD= ../../ext/polarssl-1.1.2/library/libpolarssl.a endif zone2json_LDFLAGS=@THREADFLAGS@ if HAVE_LIBPOLARSSL zone2json_LDADD= else zone2json_LDADD= ../../ext/polarssl-1.1.2/library/libpolarssl.a endif AM_LFLAGS = -s -i AM_YFLAGS = -d --verbose --debug dnslabeltext.cc: ../../dnslabeltext.rl ragel ../../dnslabeltext.rl -o dnslabeltext.cc .hh.h: cp $< $@ pdns-3.3/pdns/backends/bind/bindparserclasses.hh0000644000014601777760000000424212140444471023250 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2007 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef BINDPARSER_HH #define BINDPARSER_HH #include #include #include #include #include "namespaces.hh" class BindDomainInfo { public: BindDomainInfo() : d_dev(0), d_ino(0) {} void clear() { name=filename=type=""; masters.clear(); alsoNotify.clear(); d_dev=0; d_ino=0; } string name; string viewName; string filename; vector masters; set alsoNotify; string type; dev_t d_dev; ino_t d_ino; bool operator<(const BindDomainInfo& b) const { return make_pair(d_dev, d_ino) < make_pair(b.d_dev, b.d_ino); } }; extern const char *bind_directory; extern FILE *yyin; class BindParser { public: BindParser() : d_dir("."), d_verbose(false) { yyin=0; extern int include_stack_ptr; include_stack_ptr=0; bind_directory=d_dir.c_str(); } ~BindParser() { if(yyin) { fclose(yyin); yyin=0; } } void parse(const string &fname); void commit(BindDomainInfo DI); void setDirectory(const string &dir); const string &getDirectory(); const vector& getDomains(); void setVerbose(bool verbose); void addAlsoNotify(const string &host); set & getAlsoNotify() { return this->alsoNotify; } private: string d_dir; bool d_verbose; typedef map zonedomain_t; set alsoNotify; vector d_zonedomains; }; #endif /* BINDPARSER_HH */ pdns-3.3/pdns/backends/gsql/0000755000014601777760000000000012165464055017257 5ustar00jenkinsnogroup00000000000000pdns-3.3/pdns/backends/gsql/gsqlbackend.hh0000644000014601777760000001200012145153461022041 0ustar00jenkinsnogroup00000000000000#include #include #include "ssql.hh" #include "../../namespaces.hh" /* GSQLBackend is a generic backend used by other sql backends */ class GSQLBackend : public DNSBackend { public: GSQLBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails. virtual ~GSQLBackend() { if(d_db) delete d_db; } void setDB(SSql *db) { d_db=db; } virtual string sqlEscape(const string &name); void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1); bool list(const string &target, int domain_id); bool get(DNSResourceRecord &r); void getAllDomains(vector *domains); bool isMaster(const string &domain, const string &ip); void alsoNotifies(const string &domain, set *ips); bool startTransaction(const string &domain, int domain_id=-1); bool commitTransaction(); bool abortTransaction(); bool feedRecord(const DNSResourceRecord &r, string *ordername=0); bool feedEnts(int domain_id, set& nonterm); bool feedEnts3(int domain_id, const string &domain, set &nonterm, unsigned int times, const string &salt, bool narrow); bool createSlaveDomain(const string &ip, const string &domain, const string &account); bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db); void setFresh(uint32_t domain_id); void getUnfreshSlaveInfos(vector *domains); void getUpdatedMasters(vector *updatedDomains); bool getDomainInfo(const string &domain, DomainInfo &di); void setNotified(uint32_t domain_id, uint32_t serial); virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth); virtual bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth); virtual bool nullifyDNSSECOrderNameAndUpdateAuth(uint32_t domain_id, const std::string& qname, bool auth); virtual bool nullifyDNSSECOrderNameAndAuth(uint32_t domain_id, const std::string& qname, const std::string& type); virtual bool setDNSSECAuthOnDsRecord(uint32_t domain_id, const std::string& qname); virtual bool updateEmptyNonTerminals(uint32_t domain_id, const std::string& zonename, set& insert ,set& erase, bool remove); virtual bool doesDNSSEC(); virtual bool calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial); bool replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector& rrset); int addDomainKey(const string& name, const KeyData& key); bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys); bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); bool removeDomainKey(const string& name, unsigned int id); bool activateDomainKey(const string& name, unsigned int id); bool deactivateDomainKey(const string& name, unsigned int id); bool getTSIGKey(const string& name, string* algorithm, string* content); private: string d_qname; QType d_qtype; int d_count; SSql *d_db; SSql::result_t d_result; string d_wildCardNoIDQuery; string d_noWildCardNoIDQuery; string d_noWildCardIDQuery; string d_wildCardIDQuery; string d_wildCardANYNoIDQuery; string d_noWildCardANYNoIDQuery; string d_noWildCardANYIDQuery; string d_wildCardANYIDQuery; string d_listQuery; string d_logprefix; string d_MasterOfDomainsZoneQuery; string d_InfoOfDomainsZoneQuery; string d_InfoOfAllSlaveDomainsQuery; string d_SuperMasterInfoQuery; string d_InsertSlaveZoneQuery; string d_InsertRecordQuery; string d_InsertEntQuery; string d_InsertRecordOrderQuery; string d_InsertEntOrderQuery; string d_UpdateSerialOfZoneQuery; string d_UpdateLastCheckofZoneQuery; string d_InfoOfAllMasterDomainsQuery; string d_DeleteZoneQuery; string d_DeleteRRSet; string d_ZoneLastChangeQuery; string d_firstOrderQuery; string d_beforeOrderQuery; string d_afterOrderQuery; string d_lastOrderQuery; string d_setOrderAuthQuery; string d_nullifyOrderNameAndUpdateAuthQuery; string d_nullifyOrderNameAndAuthQuery; string d_setAuthOnDsRecordQuery; string d_removeEmptyNonTerminalsFromZoneQuery; string d_insertEmptyNonTerminalQuery; string d_deleteEmptyNonTerminalQuery; string d_AddDomainKeyQuery; string d_ListDomainKeysQuery; string d_GetDomainMetadataQuery; string d_ClearDomainMetadataQuery; string d_SetDomainMetadataQuery; string d_RemoveDomainKeyQuery; string d_ActivateDomainKeyQuery; string d_DeactivateDomainKeyQuery; string d_getTSIGKeyQuery; string d_getAllDomainsQuery; protected: bool d_dnssecQueries; }; pdns-3.3/pdns/backends/gsql/ssql.hh0000644000014601777760000000165512136555572020574 0ustar00jenkinsnogroup00000000000000/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE for more information. $Id$ */ #ifndef SSQL_HH #define SSQL_HH #ifdef WIN32 # pragma warning ( disable: 4786 ) #endif // WIN32 #include #include #include "../../namespaces.hh" class SSqlException { public: SSqlException(const string &reason) { d_reason=reason; } string txtReason() { return d_reason; } private: string d_reason; }; class SSql { public: typedef vector row_t; typedef vector result_t; virtual SSqlException sPerrorException(const string &reason)=0; virtual int doQuery(const string &query, result_t &result)=0; virtual int doQuery(const string &query)=0; virtual int doCommand(const string &query)=0; virtual bool getRow(row_t &row)=0; virtual string escape(const string &name)=0; virtual void setLog(bool state){} virtual ~SSql(){}; }; #endif /* SSQL_HH */ pdns-3.3/pdns/backends/gsql/gsqlbackend.cc0000644000014601777760000007165512145425420022051 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // $Id$ #ifdef WIN32 # pragma warning ( disable: 4786 ) #endif // WIN32 #include #include #include "namespaces.hh" #include "pdns/dns.hh" #include "pdns/dnsbackend.hh" #include "gsqlbackend.hh" #include "pdns/dnspacket.hh" #include "pdns/ueberbackend.hh" #include "pdns/ahuexception.hh" #include "pdns/logger.hh" #include "pdns/arguments.hh" #include "pdns/base32.hh" #include "pdns/dnssecinfra.hh" #include #include #include #include void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial) { char output[1024]; snprintf(output,sizeof(output)-1, d_UpdateSerialOfZoneQuery.c_str(), serial, domain_id); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); } } void GSQLBackend::setFresh(uint32_t domain_id) { char output[1024]; snprintf(output,sizeof(output)-1,d_UpdateLastCheckofZoneQuery.c_str(), time(0), domain_id); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); } } bool GSQLBackend::isMaster(const string &domain, const string &ip) { char output[1024]; snprintf(output,sizeof(output)-1, d_MasterOfDomainsZoneQuery.c_str(), sqlEscape(domain).c_str()); try { d_db->doQuery(output, d_result); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); } if(d_result.empty()) return 0; // we can have multiple masters separated by commas vector masters; stringtok(masters, d_result[0][0], " ,\t"); for(vector::const_iterator iter=masters.begin(); iter != masters.end(); ++iter) { // we can also have masters with a port specified (which we ignore here) ServiceTuple st; parseService(*iter, st); if (!strcmp(ip.c_str(), st.host.c_str())) { return 1; } } // if no masters matched then this is not a master return 0; } bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) { /* list all domains that need refreshing for which we are slave, and insert into SlaveDomain: id,name,master IP,serial */ char output[1024]; snprintf(output,sizeof(output)-1,d_InfoOfDomainsZoneQuery.c_str(), sqlEscape(domain).c_str()); try { d_db->doQuery(output,d_result); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason()); } int numanswers=d_result.size(); if(!numanswers) return false; di.id=atol(d_result[0][0].c_str()); di.zone=d_result[0][1]; stringtok(di.masters, d_result[0][2], " ,\t"); di.last_check=atol(d_result[0][3].c_str()); di.backend=this; string type=d_result[0][5]; if(pdns_iequals(type,"SLAVE")) { di.serial=0; try { SOAData sd; if(!getSOA(domain,sd)) L< *unfreshDomains) { /* list all domains that need refreshing for which we are slave, and insert into SlaveDomain: id,name,master IP,serial */ try { d_db->doQuery(d_InfoOfAllSlaveDomainsQuery, d_result); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason()); } vector allSlaves; int numanswers=d_result.size(); for(int n=0;n::iterator i=allSlaves.begin();i!=allSlaves.end();++i) { SOAData sdata; sdata.serial=0; sdata.refresh=0; getSOA(i->zone,sdata); if((time_t)(i->last_check+sdata.refresh) < time(0)) { i->serial=sdata.serial; unfreshDomains->push_back(*i); } } } void GSQLBackend::getUpdatedMasters(vector *updatedDomains) { /* list all domains that need notifications for which we are master, and insert into updatedDomains id,name,master IP,serial */ try { d_db->doQuery(d_InfoOfAllMasterDomainsQuery,d_result); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); } vector allMasters; int numanswers=d_result.size(); for(int n=0;n::iterator i=allMasters.begin();i!=allMasters.end();++i) { SOAData sdata; sdata.serial=0; sdata.refresh=0; getSOA(i->zone,sdata); if(i->notified_serial!=sdata.serial) { i->serial=sdata.serial; updatedDomains->push_back(*i); } } } string GSQLBackend::sqlEscape(const string &name) { string a; for(string::const_iterator i=name.begin();i!=name.end();++i) if(*i=='\'' || *i=='\\'){ a+='\\'; a+=*i; } else a+=*i; return a; } GSQLBackend::GSQLBackend(const string &mode, const string &suffix) { setArgPrefix(mode+suffix); d_db=0; d_logprefix="["+mode+"Backend"+suffix+"] "; try { d_dnssecQueries = mustDo("dnssec"); } catch (ArgException e) { d_dnssecQueries = false; } string authswitch = d_dnssecQueries ? "-auth" : ""; d_noWildCardNoIDQuery=getArg("basic-query"+authswitch); d_noWildCardIDQuery=getArg("id-query"+authswitch); d_wildCardNoIDQuery=getArg("wildcard-query"+authswitch); d_wildCardIDQuery=getArg("wildcard-id-query"+authswitch); d_noWildCardANYNoIDQuery=getArg("any-query"+authswitch); d_noWildCardANYIDQuery=getArg("any-id-query"+authswitch); d_wildCardANYNoIDQuery=getArg("wildcard-any-query"+authswitch); d_wildCardANYIDQuery=getArg("wildcard-any-id-query"+authswitch); d_listQuery=getArg("list-query"+authswitch); d_MasterOfDomainsZoneQuery=getArg("master-zone-query"); d_InfoOfDomainsZoneQuery=getArg("info-zone-query"); d_InfoOfAllSlaveDomainsQuery=getArg("info-all-slaves-query"); d_SuperMasterInfoQuery=getArg("supermaster-query"); d_InsertSlaveZoneQuery=getArg("insert-slave-query"); d_InsertRecordQuery=getArg("insert-record-query"+authswitch); d_InsertEntQuery=getArg("insert-ent-query"+authswitch); d_UpdateSerialOfZoneQuery=getArg("update-serial-query"); d_UpdateLastCheckofZoneQuery=getArg("update-lastcheck-query"); d_ZoneLastChangeQuery=getArg("zone-lastchange-query"); d_InfoOfAllMasterDomainsQuery=getArg("info-all-master-query"); d_DeleteZoneQuery=getArg("delete-zone-query"); d_DeleteRRSet=getArg("delete-rrset-query"); d_getAllDomainsQuery=getArg("get-all-domains-query"); d_removeEmptyNonTerminalsFromZoneQuery = getArg("remove-empty-non-terminals-from-zone-query"); d_insertEmptyNonTerminalQuery = getArg("insert-empty-non-terminal-query"+authswitch); d_deleteEmptyNonTerminalQuery = getArg("delete-empty-non-terminal-query"); if (d_dnssecQueries) { d_InsertRecordOrderQuery=getArg("insert-record-order-query-auth"); d_InsertEntOrderQuery=getArg("insert-ent-order-query-auth"); d_firstOrderQuery = getArg("get-order-first-query"); d_beforeOrderQuery = getArg("get-order-before-query"); d_afterOrderQuery = getArg("get-order-after-query"); d_lastOrderQuery = getArg("get-order-last-query"); d_setOrderAuthQuery = getArg("set-order-and-auth-query"); d_nullifyOrderNameAndUpdateAuthQuery = getArg("nullify-ordername-and-update-auth-query"); d_nullifyOrderNameAndAuthQuery = getArg("nullify-ordername-and-auth-query"); d_setAuthOnDsRecordQuery = getArg("set-auth-on-ds-record-query"); d_AddDomainKeyQuery = getArg("add-domain-key-query"); d_ListDomainKeysQuery = getArg("list-domain-keys-query"); d_GetDomainMetadataQuery = getArg("get-domain-metadata-query"); d_ClearDomainMetadataQuery = getArg("clear-domain-metadata-query"); d_SetDomainMetadataQuery = getArg("set-domain-metadata-query"); d_ActivateDomainKeyQuery = getArg("activate-domain-key-query"); d_DeactivateDomainKeyQuery = getArg("deactivate-domain-key-query"); d_RemoveDomainKeyQuery = getArg("remove-domain-key-query"); d_getTSIGKeyQuery = getArg("get-tsig-key-query"); } } bool GSQLBackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth) { if(!d_dnssecQueries) return false; string ins=toLower(labelReverse(makeRelative(qname, zonename))); return this->updateDNSSECOrderAndAuthAbsolute(domain_id, qname, ins, auth); } bool GSQLBackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output, sizeof(output)-1, d_setOrderAuthQuery.c_str(), sqlEscape(ordername).c_str(), auth, sqlEscape(qname).c_str(), domain_id); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } bool GSQLBackend::nullifyDNSSECOrderNameAndUpdateAuth(uint32_t domain_id, const std::string& qname, bool auth) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output, sizeof(output)-1, d_nullifyOrderNameAndUpdateAuthQuery.c_str(), auth, domain_id, sqlEscape(qname).c_str()); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } bool GSQLBackend::nullifyDNSSECOrderNameAndAuth(uint32_t domain_id, const std::string& qname, const std::string& type) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output, sizeof(output)-1, d_nullifyOrderNameAndAuthQuery.c_str(), sqlEscape(qname).c_str(), sqlEscape(type).c_str(), domain_id); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } bool GSQLBackend::setDNSSECAuthOnDsRecord(uint32_t domain_id, const std::string& qname) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output, sizeof(output)-1, d_setAuthOnDsRecordQuery.c_str(), domain_id, sqlEscape(qname).c_str()); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to set auth on DS record "+qname+" for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const std::string& zonename, set& insert, set& erase, bool remove) { char output[1024]; if(remove) { snprintf(output,sizeof(output)-1,d_removeEmptyNonTerminalsFromZoneQuery.c_str(), domain_id); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } else { BOOST_FOREACH(const string qname, erase) { snprintf(output,sizeof(output)-1,d_deleteEmptyNonTerminalQuery.c_str(), domain_id, sqlEscape(qname).c_str()); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to delete empty non-terminal rr "+qname+" from domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } } BOOST_FOREACH(const string qname, insert) { snprintf(output,sizeof(output)-1,d_insertEmptyNonTerminalQuery.c_str(), domain_id, sqlEscape(qname).c_str()); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to insert empty non-terminal rr "+qname+" in domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } return true; } bool GSQLBackend::doesDNSSEC() { return d_dnssecQueries; } bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { if(!d_dnssecQueries) return false; // cerr<<"gsql before/after called for id="<doQuery(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { after=row[0]; } if(after.empty() && !lcqname.empty()) { snprintf(output, sizeof(output)-1, d_firstOrderQuery.c_str(), id); try { d_db->doQuery(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { after=row[0]; } } if (before.empty()) { unhashed.clear(); snprintf(output, sizeof(output)-1, d_beforeOrderQuery.c_str(), sqlEscape(lcqname).c_str(), id); try { d_db->doQuery(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { before=row[0]; unhashed=row[1]; } if(! unhashed.empty()) { // cerr<<"unhashed="<getRow(row)) { before=row[0]; unhashed=row[1]; } } else { before=lcqname; } return true; } int GSQLBackend::addDomainKey(const string& name, const KeyData& key) { if(!d_dnssecQueries) return -1; char output[16384]; snprintf(output,sizeof(output)-1,d_AddDomainKeyQuery.c_str(), key.flags, (int)key.active, sqlEscape(key.content).c_str(), sqlEscape(toLower(name)).c_str()); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to store key: "+e.txtReason()); } return 1; // XXX FIXME, no idea how to get the id } bool GSQLBackend::activateDomainKey(const string& name, unsigned int id) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_ActivateDomainKeyQuery.c_str(), sqlEscape(toLower(name)).c_str(), id); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to activate key: "+e.txtReason()); } return true; } bool GSQLBackend::deactivateDomainKey(const string& name, unsigned int id) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_DeactivateDomainKeyQuery.c_str(), sqlEscape(toLower(name)).c_str(), id); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to deactivate key: "+e.txtReason()); } return true; } bool GSQLBackend::removeDomainKey(const string& name, unsigned int id) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_RemoveDomainKeyQuery.c_str(), sqlEscape(toLower(name)).c_str(), id); try { d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to remove key: "+e.txtReason()); } return true; } bool GSQLBackend::getTSIGKey(const string& name, string* algorithm, string* content) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_getTSIGKeyQuery.c_str(), sqlEscape(toLower(name)).c_str()); try { d_db->doQuery(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason()); } SSql::row_t row; content->clear(); while(d_db->getRow(row)) { *algorithm = row[0]; *content=row[1]; } return !content->empty(); } bool GSQLBackend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_ListDomainKeysQuery.c_str(), sqlEscape(toLower(name)).c_str()); try { d_db->doQuery(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to list keys: "+e.txtReason()); } SSql::row_t row; // "select id, kind, active, content from domains, cryptokeys where domain_id=domains.id and name='%s'"; KeyData kd; while(d_db->getRow(row)) { //~ BOOST_FOREACH(const std::string& val, row) { //~ cerr<<"'"< *ips) { if(!d_dnssecQueries) return; vector meta; getDomainMetadata(domain, "ALSO-NOTIFY", meta); BOOST_FOREACH(string& str, meta) { ips->insert(str); } } bool GSQLBackend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { if(!d_dnssecQueries) return false; char output[1024]; snprintf(output,sizeof(output)-1,d_GetDomainMetadataQuery.c_str(), sqlEscape(name).c_str(), sqlEscape(kind).c_str()); try { d_db->doQuery(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to list metadata: "+e.txtReason()); } SSql::row_t row; while(d_db->getRow(row)) { meta.push_back(row[0]); } return true; } bool GSQLBackend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { char output[16384]; if(!d_dnssecQueries) return false; if(!meta.empty()) snprintf(output,sizeof(output)-1,d_SetDomainMetadataQuery.c_str(), sqlEscape(kind).c_str(), sqlEscape(*meta.begin()).c_str(), sqlEscape(name).c_str()); string clearQuery = (boost::format(d_ClearDomainMetadataQuery) % sqlEscape(name) % sqlEscape(kind)).str(); try { d_db->doCommand(clearQuery); if(!meta.empty()) d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to store metadata key: "+e.txtReason()); } return true; } void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_p, int domain_id) { string format; char output[1024]; d_db->setLog(::arg().mustDo("query-logging")); string lcqname=toLower(qname); // lcqname=labelReverse(makeRelative(lcqname, "net")); if(qtype.getCode()!=QType::ANY) { // qtype qname domain_id if(domain_id<0) { if(qname[0]=='%') format=d_wildCardNoIDQuery; else format=d_noWildCardNoIDQuery; snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(qtype.getName()).c_str(), sqlEscape(lcqname).c_str()); } else { if(qname[0]!='%') format=d_noWildCardIDQuery; else format=d_wildCardIDQuery; snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(qtype.getName()).c_str(),sqlEscape(lcqname).c_str(),domain_id); } } else { // qtype==ANY // qname domain_id if(domain_id<0) { if(qname[0]=='%') format=d_wildCardANYNoIDQuery; else format=d_noWildCardANYNoIDQuery; snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str()); } else { if(qname[0]!='%') format=d_noWildCardANYIDQuery; else format=d_wildCardANYIDQuery; snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str(),domain_id); } } try { d_db->doQuery(output); } catch(SSqlException &e) { throw AhuException(e.txtReason()); } d_qname=qname; d_qtype=qtype; d_count=0; } bool GSQLBackend::list(const string &target, int domain_id ) { DLOG(L<<"GSQLBackend constructing handle for list of domain id '"<doQuery(output); } catch(SSqlException &e) { throw AhuException("GSQLBackend list query: "+e.txtReason()); } d_qname=""; d_count=0; return true; } bool GSQLBackend::superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **ddb) { string format; char output[1024]; format = d_SuperMasterInfoQuery; // check if we know the ip/ns couple in the database for(vector::const_iterator i=nsset.begin();i!=nsset.end();++i) { try { snprintf(output,sizeof(output)-1,format.c_str(),sqlEscape(ip).c_str(),sqlEscape(i->content).c_str()); d_db->doQuery(output, d_result); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to search for a domain: "+e.txtReason()); } if(!d_result.empty()) { *account=d_result[0][0]; *ddb=this; return true; } } return false; } bool GSQLBackend::createSlaveDomain(const string &ip, const string &domain, const string &account) { string format; char output[1024]; format = d_InsertSlaveZoneQuery; snprintf(output,sizeof(output)-1,format.c_str(),sqlEscape(domain).c_str(),sqlEscape(ip).c_str(),sqlEscape(account).c_str()); try { d_db->doCommand(output); } catch(SSqlException &e) { throw AhuException("Database error trying to insert new slave '"+domain+"': "+ e.txtReason()); } return true; } void GSQLBackend::getAllDomains(vector *domains) { DLOG(L<<"GSQLBackend retrieving all domains."<doQuery(d_getAllDomainsQuery.c_str()); } catch (SSqlException &e) { throw AhuException("Database error trying to retrieve all domains:" + e.txtReason()); } SSql::row_t row; while (d_db->getRow(row)) { DomainInfo di; di.id = atol(row[0].c_str()); di.zone = row[1]; if (!row[4].empty()) { stringtok(di.masters, row[4], " ,\t"); } di.last_check=atol(row[6].c_str()); SOAData sd; fillSOAData(row[2], sd); di.serial = sd.serial; if (!row[5].empty()) { di.notified_serial = atol(row[5].c_str()); } if (pdns_iequals(row[3], "MASTER")) di.kind = DomainInfo::Master; else if (pdns_iequals(row[3], "SLAVE")) di.kind = DomainInfo::Slave; else di.kind = DomainInfo::Native; di.backend = this; domains->push_back(di); } } bool GSQLBackend::get(DNSResourceRecord &r) { // L << "GSQLBackend get() was called for "<getRow(row)) { r.content=row[0]; if (row[1].empty()) r.ttl = ::arg().asNum( "default-ttl" ); else r.ttl=atol(row[1].c_str()); r.priority=atol(row[2].c_str()); if(!d_qname.empty()) r.qname=d_qname; else r.qname=row[5]; r.qtype=row[3]; r.last_modified=0; if(d_dnssecQueries) r.auth = !row[6].empty() && row[6][0]=='1'; else r.auth = 1; r.domain_id=atoi(row[4].c_str()); return true; } return false; } bool GSQLBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector& rrset) { string deleteQuery = (boost::format(d_DeleteRRSet) % domain_id % sqlEscape(qname) % sqlEscape(qt.getName())).str(); d_db->doCommand(deleteQuery); BOOST_FOREACH(const DNSResourceRecord& rr, rrset) { feedRecord(rr); } return true; } bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername) { string output; if(d_dnssecQueries) { if(ordername) output = (boost::format(d_InsertRecordOrderQuery) % sqlEscape(r.content) % r.ttl % r.priority % sqlEscape(r.qtype.getName()) % r.domain_id % toLower(sqlEscape(r.qname)) % sqlEscape(*ordername) % (int)r.auth).str(); else output = (boost::format(d_InsertRecordQuery) % sqlEscape(r.content) % r.ttl % r.priority % sqlEscape(r.qtype.getName()) % r.domain_id % toLower(sqlEscape(r.qname)) % (int)r.auth).str(); } else { output = (boost::format(d_InsertRecordQuery) % sqlEscape(r.content) % r.ttl % r.priority % sqlEscape(r.qtype.getName()) % r.domain_id % toLower(sqlEscape(r.qname))).str(); } try { d_db->doCommand(output.c_str()); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to feed record: "+e.txtReason()); } return true; // XXX FIXME this API should not return 'true' I think -ahu } bool GSQLBackend::feedEnts(int domain_id, set& nonterm) { string output; BOOST_FOREACH(const string qname, nonterm) { output = (boost::format(d_InsertEntQuery) % domain_id % toLower(sqlEscape(qname))).str(); try { d_db->doCommand(output.c_str()); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); } } return true; } bool GSQLBackend::feedEnts3(int domain_id, const string &domain, set &nonterm, unsigned int times, const string &salt, bool narrow) { if(!d_dnssecQueries) return false; string ordername, output; BOOST_FOREACH(const string qname, nonterm) { if(narrow) { output = (boost::format(d_InsertEntQuery) % domain_id % toLower(sqlEscape(qname))).str(); } else { ordername=toBase32Hex(hashQNameWithSalt(times, salt, qname)); output = (boost::format(d_InsertEntOrderQuery) % domain_id % toLower(sqlEscape(qname)) % toLower(sqlEscape(ordername))).str(); } try { d_db->doCommand(output.c_str()); } catch (SSqlException &e) { throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); } } return true; } bool GSQLBackend::startTransaction(const string &domain, int domain_id) { char output[1024]; if(domain_id >= 0) snprintf(output,sizeof(output)-1,d_DeleteZoneQuery.c_str(),domain_id); try { d_db->doCommand("begin"); if(domain_id >= 0) d_db->doCommand(output); } catch (SSqlException &e) { throw AhuException("Database failed to start transaction: "+e.txtReason()); } return true; } bool GSQLBackend::commitTransaction() { try { d_db->doCommand("commit"); } catch (SSqlException &e) { throw AhuException("Database failed to commit transaction: "+e.txtReason()); } return true; } bool GSQLBackend::abortTransaction() { try { d_db->doCommand("rollback"); } catch(SSqlException &e) { throw AhuException("Database failed to abort transaction: "+string(e.txtReason())); } return true; } bool GSQLBackend::calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial) { if (d_ZoneLastChangeQuery.empty()) { // query not set => fall back to default impl return DNSBackend::calculateSOASerial(domain, sd, serial); } char output[1024]; snprintf(output, sizeof(output)-1, d_ZoneLastChangeQuery.c_str(), sd.domain_id); try { d_db->doQuery(output, d_result); } catch (const SSqlException& e) { //DLOG(L<<"GSQLBackend unable to calculate SOA serial: " << e.txtReason()< #include #ifndef WIN32 # include # include # include # include # include #else # include "pdnsservice.hh" #endif // WIN32 #include #include "iputils.hh" #include "ahuexception.hh" #include "namespaces.hh" //! The DynMessenger can send messages to UNIX domain sockets and TCP sockets class DynMessenger { int d_s; #ifndef WIN32 struct sockaddr_un d_local; // our local address struct sockaddr_un d_remote; // our remote address #else HANDLE m_pipeHandle; // Named pipe handle. #endif // WIN32 DynMessenger(const DynMessenger &); // NOT IMPLEMENTED public: // CREATORS DynMessenger(const string &ldir, const string &filename); //!< Create a DynMessenger sending to this file DynMessenger(const ComboAddress& remote, const string &password); //!< Create a DynMessenger sending to this file ~DynMessenger(); // ACCESSORS int send(const string &message) const; //!< Send a message to a DynListener string receive() const; //!< receive an answer from a DynListener }; #endif pdns-3.3/pdns/mtasker.cc0000644000014601777760000003305512136555572016525 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2009 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mtasker.hh" #include #include /** \page MTasker Simple system for implementing cooperative multitasking of functions, with support for waiting on events which can return values. \section copyright Copyright and License MTasker is (c) 2002 - 2009 by bert hubert. It is licensed to you under the terms of the GPL version 2. \section overview High level overview MTasker is designed to support very simple cooperative multitasking to facilitate writing code that would ordinarily require a statemachine, for which the author does not consider himself smart enough. This class does not perform any magic it only makes calls to makecontext() and swapcontext(). Getting the details right however is complicated and MTasker does that for you. If preemptive multitasking or more advanced concepts such as semaphores, locks or mutexes are required, the use of POSIX threads is advised. MTasker is designed to offer the performance of statemachines while maintaining simple thread semantics. It is not a replacement for a full threading system. \section compatibility Compatibility MTasker is only guaranteed to work on Linux with glibc 2.2.5 and higher. It does not work on FreeBSD and notably, not on Red Hat 6.0. It may work on Solaris, please test. \section concepts Concepts There are two important concepts, the 'kernel' and the 'thread'. Each thread starts out as a function, which is passed to MTasker::makeThread(), together with a possible argument. This function is now free to do whatever it wants, but realise that MTasker implements cooperative multitasking, which means that the coder has the responsiblilty of not taking the CPU overly long. Other threads can only get the CPU if MTasker::yield() is called or if a thread sleeps to wait for an event, using the MTasker::waitEvent() method. \section kernel The Kernel The Kernel consists of functions that do housekeeping, but also of code that the client coder can call to report events. A minimal kernel loop looks like this: \code for(;;) { MT.schedule(); if(MT.noProcesses()) // exit if no processes are left break; } \endcode The kernel typically starts from the main() function of your program. New threads are also created from the kernel. This can also happen before entering the main loop. To start a thread, the method MTasker::makeThread is provided. \section events Events By default, Events are recognized by an int and their value is also an int. This can be overridden by specifying the EventKey and EventVal template parameters. An event can be a keypress, but also a UDP packet, or a bit of data from a TCP socket. The sample code provided works with keypresses, but that is just a not very useful example. A thread can also wait for an event only for a limited time, and receive a timeout of that event did not occur within the specified timeframe. \section example A simple menu system \code MTasker<> MT; void menuHandler(void *p) { int num=(int)p; cout<<"Key handler for key "<int MTasker::waitEvent(EventKey &key, EventVal *val, unsigned int timeoutMsec, struct timeval* now) { if(d_waiters.count(key)) { // there was already an exact same waiter return -1; } Waiter w; w.context=new ucontext_t; w.ttd.tv_sec = 0; w.ttd.tv_usec = 0; if(timeoutMsec) { struct timeval increment; increment.tv_sec = timeoutMsec / 1000; increment.tv_usec = 1000 * (timeoutMsec % 1000); if(now) w.ttd = increment + *now; else { struct timeval realnow; gettimeofday(&realnow, 0); w.ttd = increment + realnow; } } w.tid=d_tid; w.key=key; d_waiters.insert(w); if(swapcontext(d_waiters.find(key)->context,&d_kernel)) { // 'A' will return here when 'key' has arrived, hands over control to kernel first perror("swapcontext"); exit(EXIT_FAILURE); // no way we can deal with this } if(val && d_waitstatus==Answer) *val=d_waitval; d_tid=w.tid; if((char*)&w < d_threads[d_tid].highestStackSeen) { d_threads[d_tid].highestStackSeen = (char*)&w; } key=d_eventkey; return d_waitstatus; } //! yields control to the kernel or other threads /** Hands over control to the kernel, allowing other processes to run, or events to arrive */ templatevoid MTasker::yield() { d_runQueue.push(d_tid); if(swapcontext(d_threads[d_tid].context ,&d_kernel) < 0) { // give control to the kernel perror("swapcontext in yield"); exit(EXIT_FAILURE); } } //! reports that an event took place for which threads may be waiting /** From the kernel loop, sendEvent can be called to report that something occured for which there may be waiters. \param key Key of the event for which threads may be waiting \param val If non-zero, pointer to the content of the event \return Returns -1 in case of error, 0 if there were no waiters, 1 if a thread was woken up. WARNING: when passing val as zero, d_waitval is undefined, and hence waitEvent will return undefined! */ templateint MTasker::sendEvent(const EventKey& key, const EventVal* val) { typename waiters_t::iterator waiter=d_waiters.find(key); if(waiter == d_waiters.end()) { // cout<<"Event sent nobody was waiting for!"<context; d_tid=waiter->tid; // set tid d_eventkey=waiter->key; // pass waitEvent the exact key it was woken for d_waiters.erase(waiter); // removes the waitpoint if(swapcontext(&d_kernel,userspace)) { // swaps back to the above point 'A' perror("swapcontext in sendEvent"); exit(EXIT_FAILURE); } delete userspace; return 1; } inline pair splitPointer(void *ptr) { uint64_t ll = (uint64_t) ptr; return make_pair(ll >> 32, ll & 0xffffffff); } inline void* joinPtr(uint32_t val1, uint32_t val2) { return (void*)(((uint64_t)val1 << 32) | (uint64_t)val2); } //! launches a new thread /** The kernel can call this to make a new thread, which starts at the function start and gets passed the val void pointer. \param start Pointer to the function which will form the start of the thread \param val A void pointer that can be used to pass data to the thread */ templatevoid MTasker::makeThread(tfunc_t *start, void* val) { ucontext_t *uc=new ucontext_t; getcontext(uc); uc->uc_link = &d_kernel; // come back to kernel after dying uc->uc_stack.ss_sp = new char[d_stacksize]; uc->uc_stack.ss_size = d_stacksize; pair valpair = splitPointer(val); pair thispair = splitPointer(this); makecontext (uc, (void (*)(void))threadWrapper, 6, thispair.first, thispair.second, start, d_maxtid, valpair.first, valpair.second); d_threads[d_maxtid].context = uc; d_runQueue.push(d_maxtid++); // will run at next schedule invocation } //! needs to be called periodically so threads can run and housekeeping can be performed /** The kernel should call this function every once in a while. It makes sense to call this function if you: - reported an event - called makeThread - want to have threads running waitEvent() to get a timeout if enough time passed \return Returns if there is more work scheduled and recalling schedule now would be useful */ templatebool MTasker::schedule(struct timeval* now) { if(!d_runQueue.empty()) { d_tid=d_runQueue.front(); if(swapcontext(&d_kernel, d_threads[d_tid].context)) { perror("swapcontext in schedule"); exit(EXIT_FAILURE); } d_runQueue.pop(); return true; } if(!d_zombiesQueue.empty()) { delete[] (char *)d_threads[d_zombiesQueue.front()].context->uc_stack.ss_sp; delete d_threads[d_zombiesQueue.front()].context; d_threads.erase(d_zombiesQueue.front()); d_zombiesQueue.pop(); return true; } if(!d_waiters.empty()) { struct timeval rnow; if(!now) gettimeofday(&rnow, 0); else rnow = *now; typedef typename waiters_t::template index::type waiters_by_ttd_index_t; // waiters_by_ttd_index_t& ttdindex=d_waiters.template get(); waiters_by_ttd_index_t& ttdindex=boost::multi_index::get(d_waiters); for(typename waiters_by_ttd_index_t::iterator i=ttdindex.begin(); i != ttdindex.end(); ) { if(i->ttd.tv_sec && i->ttd < rnow) { d_waitstatus=TimeOut; d_eventkey=i->key; // pass waitEvent the exact key it was woken for ucontext_t* uc = i->context; ttdindex.erase(i++); // removes the waitpoint if(swapcontext(&d_kernel, uc)) { // swaps back to the above point 'A' perror("swapcontext in schedule2"); exit(EXIT_FAILURE); } delete uc; } else if(i->ttd.tv_sec) break; } } return false; } //! returns true if there are no processes /** Call this to check if no processes are running anymore \return true if no processes are left */ templatebool MTasker::noProcesses() { return d_threads.empty(); } //! returns the number of processes running /** Call this to perhaps limit activities if too many threads are running \return number of processes running */ templateunsigned int MTasker::numProcesses() { return d_threads.size(); } //! gives access to the list of Events threads are waiting for /** The kernel can call this to get a list of Events threads are waiting for. This is very useful to setup 'select' or 'poll' or 'aio' events needed to satisfy these requests. getEvents clears the events parameter before filling it. \param events Vector which is to be filled with keys threads are waiting for */ templatevoid MTasker::getEvents(std::vector& events) { events.clear(); for(typename waiters_t::const_iterator i=d_waiters.begin();i!=d_waiters.end();++i) { events.push_back(i->first); } } templatevoid MTasker::threadWrapper(uint32_t self1, uint32_t self2, tfunc_t *tf, int tid, uint32_t val1, uint32_t val2) { void* val = joinPtr(val1, val2); MTasker* self = (MTasker*) joinPtr(self1, self2); self->d_threads[self->d_tid].startOfStack = self->d_threads[self->d_tid].highestStackSeen = (char*)&val; (*tf)(val); self->d_zombiesQueue.push(tid); // we now jump to &kernel, automatically } //! Returns the current Thread ID (tid) /** Processes can call this to get a numerical representation of their current thread ID. This can be useful for logging purposes. */ templateint MTasker::getTid() { return d_tid; } //! Returns the maximum stack usage so far of this MThread templateunsigned int MTasker::getMaxStackUsage() { return d_threads[d_tid].startOfStack - d_threads[d_tid].highestStackSeen; } pdns-3.3/pdns/sdig.cc0000644000014601777760000001175312142724160015772 0ustar00jenkinsnogroup00000000000000#include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "statbag.hh" #include StatBag S; int main(int argc, char** argv) try { bool dnssec=false; bool recurse=false; bool tcp=false; bool showflags=false; reportAllTypes(); if(argc < 5) { cerr<<"Syntax: sdig IP-address port question question-type [dnssec|dnssec-tcp|recurse] [showflags]\n"; exit(EXIT_FAILURE); } // FIXME: turn recurse and dnssec into proper flags or something if(argc > 5 && strcmp(argv[5], "dnssec")==0) { dnssec=true; } if(argc > 5 && strcmp(argv[5], "dnssec-tcp")==0) { dnssec=true; tcp=true; } if(argc > 5 && strcmp(argv[5], "recurse")==0) { recurse=true; } if((argc > 5 && strcmp(argv[5], "showflags")==0) || (argc > 6 && strcmp(argv[6], "showflags")==0)) { showflags=true; } vector packet; DNSPacketWriter pw(packet, argv[3], DNSRecordContent::TypeToNumber(argv[4])); if(dnssec || getenv("SDIGBUFSIZE")) { char *sbuf=getenv("SDIGBUFSIZE"); int bufsize; if(sbuf) bufsize=atoi(sbuf); else bufsize=2800; pw.addOpt(bufsize, 0, dnssec ? EDNSOpts::DNSSECOK : 0); pw.commit(); } if(recurse) { pw.getHeader()->rd=true; } // pw.setRD(true); /* pw.startRecord("powerdns.com", DNSRecordContent::TypeToNumber("NS")); NSRecordContent nrc("ns1.powerdns.com"); nrc.toPacket(pw); pw.startRecord("powerdns.com", DNSRecordContent::TypeToNumber("NS")); NSRecordContent nrc2("ns2.powerdns.com"); nrc2.toPacket(pw); */ /* DNSPacketWriter::optvect_t opts; opts.push_back(make_pair(5, ping)); pw.commit(); */ // pw.addOpt(5200, 0, 0); // pw.commit(); string reply; if(tcp) { Socket sock(InterNetwork, Stream); ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); sock.connect(dest); uint16_t len; len = htons(packet.size()); if(sock.write((char *) &len, 2) != 2) throw AhuException("tcp write failed"); sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end())); if(sock.read((char *) &len, 2) != 2) throw AhuException("tcp read failed"); len=ntohs(len); char *creply = new char[len]; int n=0; int numread; while(nfirst.d_place-1<<"\t"<first.d_label<<"\tIN\t"<first.d_type); if(i->first.d_type == QType::RRSIG) { string zoneRep = i->first.d_content->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout<<"\t"<first.d_ttl<<"\t"<< parts[0]<<" "<first.d_type == QType::NSEC3) { string zoneRep = i->first.d_content->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout<<"\t"<first.d_ttl<<"\t"<< parts[0]<<" [flags] "<::iterator iter = parts.begin()+5; iter != parts.end(); ++iter) cout<<" "<<*iter; cout<<"\n"; } else if(i->first.d_type == QType::DNSKEY) { string zoneRep = i->first.d_content->getZoneRepresentation(); vector parts; stringtok(parts, zoneRep); cout<<"\t"<first.d_ttl<<"\t"<< parts[0]<<" "<first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n"; } } EDNSOpts edo; if(getEDNSOpts(mdp, &edo)) { // cerr<<"Have "< >::const_iterator iter = edo.d_options.begin(); iter != edo.d_options.end(); ++iter) { if(iter->first == 5) {// 'EDNS PING' cerr<<"Have ednsping: '"<second<<"'\n"; //if(iter->second == ping) // cerr<<"It is correct!"<first< #include "communicator.hh" #include #include #include "dnsbackend.hh" #include "ueberbackend.hh" #include "packethandler.hh" #include "resolver.hh" #include "logger.hh" #include "dns.hh" #include "arguments.hh" #include "session.hh" #include "packetcache.hh" #include // #include "namespaces.hh" void CommunicatorClass::retrievalLoopThread(void) { for(;;) { d_suck_sem.wait(); SuckRequest sr; { Lock l(&d_lock); if(d_suckdomains.empty()) continue; sr=d_suckdomains.front(); d_suckdomains.pop_front(); } suck(sr.domain,sr.master); } } void CommunicatorClass::go() { pthread_t tid; pthread_create(&tid,0,&launchhelper,this); // Starts CommunicatorClass::mainloop() for(int n=0; n < ::arg().asNum("retrieval-threads"); ++n) pthread_create(&tid, 0, &retrieveLaunchhelper, this); // Starts CommunicatorClass::retrievalLoopThread() d_preventSelfNotification =::arg().mustDo("prevent-self-notification"); } void CommunicatorClass::mainloop(void) { try { #ifndef WIN32 signal(SIGPIPE,SIG_IGN); #endif // WIN32 L< #include #include #include #include #include #include #include #include using namespace boost::multi_index; #ifndef WIN32 # include # include # include #endif // WIN32 #include "lock.hh" #include "packethandler.hh" #include "namespaces.hh" struct SuckRequest { string domain; string master; bool operator<(const SuckRequest& b) const { return tie(domain, master) < tie(b.domain, b.master); } }; struct IDTag{}; typedef multi_index_container< SuckRequest, indexed_by< sequenced<>, ordered_unique, identity > > > UniQueue; typedef UniQueue::index::type domains_by_name_t; class NotificationQueue { public: void add(const string &domain, const string &ip) { NotificationRequest nr; nr.domain = domain; nr.ip = ip; nr.attempts = 0; nr.id = Utility::random()%0xffff; nr.next = time(0); d_nqueue.push_back(nr); } bool removeIf(const string &remote, uint16_t id, const string &domain) { for(d_nqueue_t::iterator i=d_nqueue.begin(); i!=d_nqueue.end(); ++i) { // cout<id<<" "<ip<<" "<domain<<" "<ip, ':'); if(i->id==id && ourIP == remoteIP && i->domain==domain) { d_nqueue.erase(i); return true; } } return false; } bool getOne(string &domain, string &ip, uint16_t *id, bool &purged) { for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i) if(i->next <= time(0)) { i->attempts++; purged=false; i->next=time(0)+1+(1<attempts); domain=i->domain; ip=i->ip; *id=i->id; purged=false; if(i->attempts>4) { purged=true; d_nqueue.erase(i); } return true; } return false; } time_t earliest() { time_t early=std::numeric_limits::max() - 1; for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i) early=min(early,i->next); return early-time(0); } void dump(); private: struct NotificationRequest { string domain; string ip; int attempts; uint16_t id; time_t next; }; typedef std::list d_nqueue_t; d_nqueue_t d_nqueue; }; /** this class contains a thread that communicates with other nameserver and does housekeeping. Initially, it is notified only of zones that need to be pulled in because they have been updated. */ class CommunicatorClass { public: CommunicatorClass() { pthread_mutex_init(&d_lock,0); pthread_mutex_init(&d_holelock,0); d_tickinterval=60; d_masterschanged=d_slaveschanged=true; } time_t doNotifications(); void go(); void drillHole(const string &domain, const string &ip); bool justNotified(const string &domain, const string &ip); void addSuckRequest(const string &domain, const string &master); void addSlaveCheckRequest(const DomainInfo& di, const ComboAddress& remote); void addTrySuperMasterRequest(DNSPacket *p); void notify(const string &domain, const string &ip); void mainloop(); void retrievalLoopThread(); void sendNotification(int sock, const string &domain, const ComboAddress& remote, uint16_t id); static void *launchhelper(void *p) { static_cast(p)->mainloop(); return 0; } static void *retrieveLaunchhelper(void *p) { static_cast(p)->retrievalLoopThread(); return 0; } bool notifyDomain(const string &domain); private: void makeNotifySockets(); void queueNotifyDomain(const string &domain, DNSBackend *B); int d_nsock4, d_nsock6; map,time_t>d_holes; pthread_mutex_t d_holelock; void launchRetrievalThreads(); void suck(const string &domain, const string &remote); void slaveRefresh(PacketHandler *P); void masterUpdateCheck(PacketHandler *P); pthread_mutex_t d_lock; UniQueue d_suckdomains; bool d_havepriosuckrequest; Semaphore d_suck_sem; Semaphore d_any_sem; time_t d_tickinterval; NotificationQueue d_nq; bool d_masterschanged, d_slaveschanged; set d_tocheck; vector d_potentialsupermasters; bool d_preventSelfNotification; }; #endif pdns-3.3/pdns/botan18signers.cc0000644000014601777760000001615312136555572017726 0ustar00jenkinsnogroup00000000000000// utf-8 UTF-8 utf8 UTF8 #include #include #include #include #include #include #include #include "dnssecinfra.hh" using namespace Botan; class ECDSADNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: explicit ECDSADNSCryptoKeyEngine(unsigned int algo) : DNSCryptoKeyEngine(algo) {} string getName() const { return "Botan 1.8 ECDSA"; } void create(unsigned int bits); storvector_t convertToISCVector() const; std::string getPubKeyHash() const; std::string sign(const std::string& hash) const; std::string hash(const std::string& hash) const; bool verify(const std::string& msg, const std::string& signature) const; std::string getPublicKeyString() const; int getBits() const; void fromISCMap(DNSKEYRecordContent& drc, std::map& stormap); void fromPublicKeyString(const std::string& content); void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) {} static DNSCryptoKeyEngine* maker(unsigned int algorithm) { return new ECDSADNSCryptoKeyEngine(algorithm); } private: static EC_Domain_Params getECParams(unsigned int algorithm); shared_ptr d_key; shared_ptr d_pubkey; }; EC_Domain_Params ECDSADNSCryptoKeyEngine::getECParams(unsigned int algorithm) { if(algorithm==13) return get_EC_Dom_Pars_by_oid("1.2.840.10045.3.1.7"); else if(algorithm == 14) return get_EC_Dom_Pars_by_oid("1.3.132.0.34"); else throw runtime_error("Requested for unknown EC domain parameters for algorithm "+lexical_cast(algorithm)); } void ECDSADNSCryptoKeyEngine::create(unsigned int bits) { AutoSeeded_RNG rng; if(bits != 256 && bits != 384) { throw runtime_error("Unknown key length of "+lexical_cast(bits)+" bits requested from ECDSA class"); } d_key = shared_ptr(new ECDSA_PrivateKey(rng, getECParams((bits == 256) ? 13 : 14))); // PKCS8_Encoder* pk8e= d_key->pkcs8_encoder(); // MemoryVector getbits=pk8e->key_bits(); // cerr<private_value(); // SecureVector buffer=BigInt::encode(x); // cerr<private_value(); SecureVector buffer=BigInt::encode(x); storvector.push_back(make_pair("PrivateKey", string((char*)&*buffer.begin(), (char*)&*buffer.end()))); return storvector; } void ECDSADNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap ) { /*Private-key-format: v1.2 Algorithm: 13 (ECDSAP256SHA256) PrivateKey: GU6SnQ/Ou+xC5RumuIUIuJZteXT2z0O/ok1s38Et6mQ= */ drc.d_algorithm = atoi(stormap["algorithm"].c_str()); if(drc.d_algorithm != d_algorithm) throw runtime_error("Tried to feed an algorithm "+lexical_cast(drc.d_algorithm)+" to a "+lexical_cast(d_algorithm)+" key!"); string privateKey = stormap["privatekey"]; BigInt bigint((byte*)privateKey.c_str(), privateKey.length()); EC_Domain_Params params=getECParams(drc.d_algorithm); d_key=shared_ptr(new ECDSA_PrivateKey); AutoSeeded_RNG rng; SecureVector octstr_secret = BigInt::encode_1363(bigint, getBits()/8); SecureVector octstr_params = encode_der_ec_dompar(params, ENC_EXPLICIT); MemoryVector data = DER_Encoder() .start_cons(SEQUENCE) .encode(BigInt(1)) .encode(octstr_secret, OCTET_STRING) .end_cons() .get_contents(); PKCS8_Decoder *p8e = d_key->pkcs8_decoder(rng); if (d_algorithm == 13) p8e->alg_id(AlgorithmIdentifier("1.2.840.10045.3.1.7", octstr_params)); else p8e->alg_id(AlgorithmIdentifier("1.3.132.0.34", octstr_params)); p8e->key_bits(data); delete p8e; } std::string ECDSADNSCryptoKeyEngine::getPubKeyHash() const { BigInt x = d_key->private_value(); SecureVector buffer=BigInt::encode(x); return string((const char*)buffer.begin(), (const char*)buffer.end()); } std::string ECDSADNSCryptoKeyEngine::getPublicKeyString() const { BigInt x =d_key->public_point().get_affine_x().get_value(); BigInt y =d_key->public_point().get_affine_y().get_value(); size_t part_size = std::max(x.bytes(), y.bytes()); MemoryVector bits(2*part_size); x.binary_encode(&bits[part_size - x.bytes()]); y.binary_encode(&bits[2*part_size - y.bytes()]); return string((const char*)bits.begin(), (const char*)bits.end()); } void ECDSADNSCryptoKeyEngine::fromPublicKeyString(const std::string&input) { BigInt x, y; x.binary_decode((const byte*)input.c_str(), input.length()/2); y.binary_decode((const byte*)input.c_str() + input.length()/2, input.length()/2); EC_Domain_Params params=getECParams(d_algorithm); GFpElement gfpx(params.get_curve().get_ptr_mod(), x); GFpElement gfpy(params.get_curve().get_ptr_mod(), y); PointGFp point(params.get_curve(), gfpx,gfpy); d_pubkey = shared_ptr(new ECDSA_PublicKey(params, point)); d_key.reset(); } std::string ECDSADNSCryptoKeyEngine::sign(const std::string& msg) const { AutoSeeded_RNG rng; string hash = this->hash(msg); Default_ECDSA_Op ops(d_key->domain_parameters(), d_key->private_value(), d_key->public_point()); SecureVector signature=ops.sign((byte*)hash.c_str(), hash.length(), rng); return string((const char*)signature.begin(), (const char*) signature.end()); } std::string ECDSADNSCryptoKeyEngine::hash(const std::string& orig) const { SecureVector result; if(getBits() == 256) { // SHA256 SHA_256 hasher; result= hasher.process(orig); } else { // SHA384 SHA_384 hasher; result = hasher.process(orig); } return string((const char*)result.begin(), (const char*) result.end()); } bool ECDSADNSCryptoKeyEngine::verify(const std::string& msg, const std::string& signature) const { string hash = this->hash(msg); ECDSA_PublicKey* key = d_key ? d_key.get() : d_pubkey.get(); Default_ECDSA_Op ops(key->domain_parameters(), BigInt(0), key->public_point()); return ops.verify((byte*)signature.c_str(), signature.length(), (byte*)hash.c_str(), hash.length()); } namespace { struct LoaderBotan18Struct { LoaderBotan18Struct() { // DNSCryptoKeyEngine::report(12, &GOSTDNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(13, &ECDSADNSCryptoKeyEngine::maker); DNSCryptoKeyEngine::report(14, &ECDSADNSCryptoKeyEngine::maker); } } loaderbotan18; } pdns-3.3/pdns/rcpgenerator.cc0000644000014601777760000003110412144677100017532 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "rcpgenerator.hh" #include "dnsparser.hh" #include "misc.hh" #include #include #include #include "base32.hh" #include "base64.hh" #include "namespaces.hh" RecordTextReader::RecordTextReader(const string& str, const string& zone) : d_string(str), d_zone(zone), d_pos(0), d_end(str.size()) { } void RecordTextReader::xfr48BitInt(uint64_t &val) { xfr64BitInt(val); } void RecordTextReader::xfr64BitInt(uint64_t &val) { skipSpaces(); if(!isdigit(d_string.at(d_pos))) throw RecordTextException("expected digits at position "+lexical_cast(d_pos)+" in '"+d_string+"'"); char *endptr; unsigned long ret=strtoull(d_string.c_str() + d_pos, &endptr, 10); val=ret; d_pos = endptr - d_string.c_str(); } void RecordTextReader::xfr32BitInt(uint32_t &val) { skipSpaces(); if(!isdigit(d_string.at(d_pos))) throw RecordTextException("expected digits at position "+lexical_cast(d_pos)+" in '"+d_string+"'"); char *endptr; unsigned long ret=strtoul(d_string.c_str() + d_pos, &endptr, 10); val=ret; d_pos = endptr - d_string.c_str(); } void RecordTextReader::xfrTime(uint32_t &val) { struct tm tm; memset(&tm, 0, sizeof(tm)); string tmp; xfrLabel(tmp); // ends on number, so this works sscanf(tmp.c_str(), "%04d%02d%02d" "%02d%02d%02d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); tm.tm_year-=1900; tm.tm_mon-=1; val=(uint32_t)Utility::timegm(&tm); } void RecordTextReader::xfrIP(uint32_t &val) { skipSpaces(); if(!isdigit(d_string.at(d_pos))) throw RecordTextException("while parsing IP address, expected digits at position "+lexical_cast(d_pos)+" in '"+d_string+"'"); uint32_t octet=0; val=0; char count=0; for(;;) { if(d_string.at(d_pos)=='.') { val<<=8; val+=octet; octet=0; count++; if(count > 3) break; } else if(isdigit(d_string.at(d_pos))) { octet*=10; octet+=d_string.at(d_pos) - '0'; if(octet > 255) throw RecordTextException("unable to parse IP address"); } else if(dns_isspace(d_string.at(d_pos))) break; else { throw RecordTextException(string("unable to parse IP address, strange character: ")+d_string.at(d_pos)); } d_pos++; if(d_pos == d_string.length()) break; } if(count<=3) { val<<=8; val+=octet; } val=ntohl(val); } void RecordTextReader::xfrIP6(std::string &val) { struct in6_addr tmpbuf; skipSpaces(); size_t len; // lookup end of value for(len=0; d_pos+len < d_string.length() && (isxdigit(d_string.at(d_pos+len)) || d_string.at(d_pos+len) == ':'); len++); if(!len) throw RecordTextException("while parsing IPv6 address, expected xdigits at position "+lexical_cast(d_pos)+" in '"+d_string+"'"); // end of value is here, try parse as IPv6 string address=d_string.substr(d_pos, len); if (inet_pton(AF_INET6, address.c_str(), &tmpbuf) != 1) { throw RecordTextException("while parsing IPv6 address: '" + address + "' is invalid"); } val = std::string((char*)tmpbuf.s6_addr, 16); d_pos += len; } bool RecordTextReader::eof() { return d_pos==d_end; } void RecordTextReader::xfr16BitInt(uint16_t &val) { uint32_t tmp; xfr32BitInt(tmp); val=tmp; if(val!=tmp) throw RecordTextException("Overflow reading 16 bit integer from record content"); // fixme improve } void RecordTextReader::xfr8BitInt(uint8_t &val) { uint32_t tmp; xfr32BitInt(tmp); val=tmp; if(val!=tmp) throw RecordTextException("Overflow reading 8 bit integer from record content"); // fixme improve } // this code should leave all the escapes around void RecordTextReader::xfrLabel(string& val, bool) { skipSpaces(); val.clear(); val.reserve(d_end - d_pos); const char* strptr=d_string.c_str(); string::size_type begin_pos = d_pos; while(d_pos < d_end) { if(strptr[d_pos]!='\r' && dns_isspace(strptr[d_pos])) break; d_pos++; } val.append(strptr+begin_pos, strptr+d_pos); if(val.empty()) val=d_zone; else if(!d_zone.empty()) { char last=val[val.size()-1]; if(last =='.') val.resize(val.size()-1); else if(last != '.' && !isdigit(last)) // don't add zone to IP address val+="."+d_zone; } } static bool isbase64(char c) { if(dns_isspace(c)) return true; if(c >= '0' && c <= '9') return true; if(c >= 'a' && c <= 'z') return true; if(c >= 'A' && c <= 'Z') return true; if(c=='+' || c=='/' || c=='=') return true; return false; } void RecordTextReader::xfrBlob(string& val, int) { skipSpaces(); int pos=(int)d_pos; const char* strptr=d_string.c_str(); while(d_pos < d_end && isbase64(strptr[d_pos])) d_pos++; string tmp; tmp.assign(d_string.c_str()+pos, d_string.c_str() + d_pos); boost::erase_all(tmp," "); val.clear(); B64Decode(tmp, val); } static inline uint8_t hextodec(uint8_t val) { if(val >= '0' && val<='9') return val-'0'; else if(val >= 'A' && val<='F') return 10+(val-'A'); else if(val >= 'a' && val<='f') return 10+(val-'a'); else throw RecordTextException("Unknown hexadecimal character '"+lexical_cast(val)+"'"); } void HEXDecode(const char* begin, const char* end, string& out) { if(end - begin == 1 && *begin=='-') { out.clear(); return; } out.clear(); out.reserve((end-begin)/2); uint8_t mode=0, val=0; for(; begin != end; ++begin) { if(!isalnum(*begin)) continue; if(mode==0) { val = 16*hextodec(*begin); mode=1; } else { val += hextodec(*begin); out.append(1, (char) val); mode = 0; val = 0; } } if(mode) out.append(1, (char) val); } void RecordTextReader::xfrHexBlob(string& val, bool keepReading) { skipSpaces(); int pos=(int)d_pos; while(d_pos < d_end && (keepReading || !dns_isspace(d_string[d_pos]))) d_pos++; HEXDecode(d_string.c_str()+pos, d_string.c_str() + d_pos, val); } void RecordTextReader::xfrBase32HexBlob(string& val) { skipSpaces(); int pos=(int)d_pos; while(d_pos < d_end && !dns_isspace(d_string[d_pos])) d_pos++; val=fromBase32Hex(string(d_string.c_str()+pos, d_pos-pos)); } void RecordTextWriter::xfrBase32HexBlob(const string& val) { if(!d_string.empty()) d_string.append(1,' '); d_string.append(toBase32Hex(val)); } void RecordTextReader::xfrText(string& val, bool multi) { val.clear(); val.reserve(d_end - d_pos); while(d_pos != d_end) { if(!val.empty()) val.append(1, ' '); skipSpaces(); if(d_string[d_pos]!='"') { // special case 'plenus' - without quotes string::size_type pos = d_pos; while(pos != d_end && isalnum(d_string[pos])) pos++; if(pos == d_end) { val.append(1, '"'); val.append(d_string.c_str() + d_pos, d_end - d_pos); val.append(1, '"'); d_pos = d_end; break; } throw RecordTextException("Data field in DNS should start with quote (\") at position "+lexical_cast(d_pos)+" of '"+d_string+"'"); } val.append(1, '"'); while(++d_pos < d_end && d_string[d_pos]!='"') { if(d_string[d_pos]=='\\' && d_pos+1!=d_end) { val.append(1, d_string[d_pos++]); } val.append(1, d_string[d_pos]); } val.append(1,'"'); if(d_pos == d_end) throw RecordTextException("Data field in DNS should end on a quote (\") in '"+d_string+"'"); d_pos++; if(!multi) break; } } void RecordTextReader::xfrType(uint16_t& val) { skipSpaces(); int pos=(int)d_pos; while(d_pos < d_end && !dns_isspace(d_string[d_pos])) d_pos++; string tmp; tmp.assign(d_string.c_str()+pos, d_string.c_str() + d_pos); val=DNSRecordContent::TypeToNumber(tmp); } void RecordTextReader::skipSpaces() { const char* strptr = d_string.c_str(); while(d_pos < d_end && dns_isspace(strptr[d_pos])) d_pos++; if(d_pos == d_end) throw RecordTextException("missing field at the end of record content '"+d_string+"'"); } RecordTextWriter::RecordTextWriter(string& str) : d_string(str) { d_string.clear(); } void RecordTextWriter::xfr48BitInt(const uint64_t& val) { if(!d_string.empty()) d_string.append(1,' '); d_string+=lexical_cast(val); } void RecordTextWriter::xfr32BitInt(const uint32_t& val) { if(!d_string.empty()) d_string.append(1,' '); d_string+=lexical_cast(val); } void RecordTextWriter::xfrType(const uint16_t& val) { if(!d_string.empty()) d_string.append(1,' '); d_string+=DNSRecordContent::NumberToType(val); } // this function is on the fast path for the pdns_recursor void RecordTextWriter::xfrIP(const uint32_t& val) { if(!d_string.empty()) d_string.append(1,' '); char tmp[17]; uint32_t ip=val; uint8_t vals[4]; memcpy(&vals[0], &ip, sizeof(ip)); char *pos=tmp; for(int n=0; n < 4; ++n) { if(vals[n]<10) { *(pos++)=vals[n]+'0'; } else if(vals[n] < 100) { *(pos++)=(vals[n]/10) +'0'; *(pos++)=(vals[n]%10) +'0'; } else { *(pos++)=(vals[n]/100) +'0'; vals[n]%=100; *(pos++)=(vals[n]/10) +'0'; *(pos++)=(vals[n]%10) +'0'; } if(n!=3) *(pos++)='.'; } *pos=0; d_string.append(tmp, pos); } void RecordTextWriter::xfrIP6(const std::string& val) { char tmpbuf[16]; char addrbuf[40]; if(!d_string.empty()) d_string.append(1,' '); val.copy(tmpbuf,16); if (inet_ntop(AF_INET6, tmpbuf, addrbuf, sizeof addrbuf) == NULL) throw RecordTextException("Unable to convert to ipv6 address"); d_string += std::string(addrbuf); } void RecordTextWriter::xfrTime(const uint32_t& val) { if(!d_string.empty()) d_string.append(1,' '); struct tm tm; time_t time=val; // Y2038 bug! #ifndef WIN32 gmtime_r(&time, &tm); #else struct tm* tmptr; tmptr=gmtime(&time); if(!tmptr) throw RecordTextException("Unable to convert timestamp into pretty printable time"); tm=*tmptr; #endif char tmp[16]; snprintf(tmp,sizeof(tmp)-1, "%04d%02d%02d" "%02d%02d%02d", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); d_string += tmp; } void RecordTextWriter::xfr16BitInt(const uint16_t& val) { xfr32BitInt(val); } void RecordTextWriter::xfr8BitInt(const uint8_t& val) { xfr32BitInt(val); } // should not mess with the escapes void RecordTextWriter::xfrLabel(const string& val, bool) { if(!d_string.empty()) d_string.append(1,' '); d_string+=val; } void RecordTextWriter::xfrBlob(const string& val, int) { if(!d_string.empty()) d_string.append(1,' '); d_string+=Base64Encode(val); } void RecordTextWriter::xfrHexBlob(const string& val, bool) { if(!d_string.empty()) d_string.append(1,' '); if(val.empty()) { d_string.append(1,'-'); return; } string::size_type limit=val.size(); char tmp[5]; for(string::size_type n = 0; n < limit; ++n) { snprintf(tmp, sizeof(tmp)-1, "%02x", (unsigned char)val[n]); d_string+=tmp; } } void RecordTextWriter::xfrText(const string& val, bool multi) { if(!d_string.empty()) d_string.append(1,' '); d_string.append(val); } #ifdef TESTING int main(int argc, char**argv) try { RecordTextReader rtr(argv[1], argv[2]); unsigned int order, pref; string flags, services, regexp, replacement; string mx; rtr.xfrInt(order); rtr.xfrInt(pref); rtr.xfrText(flags); rtr.xfrText(services); rtr.xfrText(regexp); rtr.xfrLabel(replacement); cout<<"order: "< namespace anonpdns { char B64Decode1(char cInChar) { // The incoming character will be A-Z, a-z, 0-9, +, /, or =. // The idea is to quickly determine which grouping the // letter belongs to and return the associated value // without having to search the global encoding string // (the value we're looking for would be the resulting // index into that string). // // To do that, we'll play some tricks... unsigned char iIndex = '\0'; switch ( cInChar ) { case '+': iIndex = 62; break; case '/': iIndex = 63; break; case '=': iIndex = 0; break; default: // Must be 'A'-'Z', 'a'-'z', '0'-'9', or an error... // // Numerically, small letters are "greater" in value than // capital letters and numerals (ASCII value), and capital // letters are "greater" than numerals (again, ASCII value), // so we check for numerals first, then capital letters, // and finally small letters. iIndex = '9' - cInChar; if ( iIndex > 0x3F ) { // Not from '0' to '9'... iIndex = 'Z' - cInChar; if ( iIndex > 0x3F ) { // Not from 'A' to 'Z'... iIndex = 'z' - cInChar; if ( iIndex > 0x3F ) { // Invalid character...cannot // decode! iIndex = 0x80; // set the high bit } // if else { // From 'a' to 'z' iIndex = (('z' - iIndex) - 'a') + 26; } // else } // if else { // From 'A' to 'Z' iIndex = ('Z' - iIndex) - 'A'; } // else } // if else { // Adjust the index... iIndex = (('9' - iIndex) - '0') + 52; } // else break; } // switch return iIndex; } inline char B64Encode1(unsigned char uc) { if (uc < 26) { return 'A'+uc; } if (uc < 52) { return 'a'+(uc-26); } if (uc < 62) { return '0'+(uc-52); } if (uc == 62) { return '+'; } return '/'; }; } using namespace anonpdns; int B64Decode(const std::string& strInput, std::string& strOutput) { // Set up a decoding buffer long cBuf = 0; char* pBuf = (char*)&cBuf; // Decoding management... int iBitGroup = 0, iInNum = 0; // While there are characters to process... // // We'll decode characters in blocks of 4, as // there are 4 groups of 6 bits in 3 bytes. The // incoming Base64 character is first decoded, and // then it is inserted into the decode buffer // (with any relevant shifting, as required). // Later, after all 3 bytes have been reconstituted, // we assign them to the output string, ultimately // to be returned as the original message. int iInSize = strInput.size(); unsigned char cChar = '\0'; uint8_t pad = 0; while ( iInNum < iInSize ) { // Fill the decode buffer with 4 groups of 6 bits cBuf = 0; // clear pad = 0; for ( iBitGroup = 0; iBitGroup < 4; ++iBitGroup ) { if ( iInNum < iInSize ) { // Decode a character if(strInput.at(iInNum)=='=') pad++; while(isspace(strInput.at(iInNum))) iInNum++; cChar = B64Decode1(strInput.at(iInNum++)); } // if else { // Decode a padded zero cChar = '\0'; } // else // Check for valid decode if ( cChar > 0x7F ) return -1; // Adjust the bits switch ( iBitGroup ) { case 0: // The first group is copied into // the least significant 6 bits of // the decode buffer...these 6 bits // will eventually shift over to be // the most significant bits of the // third byte. cBuf = cBuf | cChar; break; default: // For groupings 1-3, simply shift // the bits in the decode buffer over // by 6 and insert the 6 from the // current decode character. cBuf = (cBuf << 6) | cChar; break; } // switch } // for // Interpret the resulting 3 bytes...note there // may have been padding, so those padded bytes // are actually ignored. strOutput += pBuf[2]; strOutput += pBuf[1]; strOutput += pBuf[0]; } // while if(pad) strOutput.resize(strOutput.length()-pad); return 1; } /* www.kbcafe.com Copyright 2001-2002 Randy Charles Morin The Encode static method takes an array of 8-bit values and returns a base-64 stream. */ std::string Base64Encode (const std::string& vby) { std::string retval; if (vby.size () == 0) { return retval; }; for (unsigned int i = 0; i < vby.size (); i += 3) { unsigned char by1 = 0, by2 = 0, by3 = 0; by1 = vby[i]; if (i + 1 < vby.size ()) { by2 = vby[i + 1]; }; if (i + 2 < vby.size ()) { by3 = vby[i + 2]; } unsigned char by4 = 0, by5 = 0, by6 = 0, by7 = 0; by4 = by1 >> 2; by5 = ((by1 & 0x3) << 4) | (by2 >> 4); by6 = ((by2 & 0xf) << 2) | (by3 >> 6); by7 = by3 & 0x3f; retval += B64Encode1 (by4); retval += B64Encode1 (by5); if (i + 1 < vby.size ()) { retval += B64Encode1 (by6); } else { retval += "="; }; if (i + 2 < vby.size ()) { retval += B64Encode1 (by7); } else { retval += "="; }; /* if ((i % (76 / 4 * 3)) == 0) { retval += "\r\n"; }*/ }; return retval; }; pdns-3.3/pdns/json_ws.hh0000644000014601777760000000213012136555572016541 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2003 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include "namespaces.hh" #include "mplexer.hh" class JWebserver : public boost::noncopyable { public: explicit JWebserver(FDMultiplexer* fdm); void newConnection(); void readRequest(int fd); private: FDMultiplexer* d_fdm; int d_socket; }; string returnJSONStats(const map& items); pdns-3.3/pdns/recursor_cache.cc0000644000014601777760000003137612136555572020052 0ustar00jenkinsnogroup00000000000000#include "recursor_cache.hh" #include "misc.hh" #include #include #include "dnsrecords.hh" #include "arguments.hh" #include "syncres.hh" #include "recursor_cache.hh" #include "cachecleaner.hh" #include "namespaces.hh" #include "namespaces.hh" #include "config.h" DNSResourceRecord String2DNSRR(const string& qname, const QType& qt, const string& serial, uint32_t ttd) { DNSResourceRecord rr; rr.ttl=ttd; rr.qtype=qt; rr.qname=qname; if(rr.qtype.getCode()==QType::A && serial.size()==4) { uint32_t ip; memcpy((char*)&ip, serial.c_str(), 4); rr.content=U32ToIP(ntohl(ip)); } else if(rr.qtype.getCode()==QType::AAAA && serial.size()==16) { ComboAddress tmp; memset(&tmp, 0, sizeof(tmp)); tmp.sin4.sin_family=AF_INET6; memcpy(tmp.sin6.sin6_addr.s6_addr, serial.c_str(), 16); rr.content=tmp.toString(); } else if(rr.qtype.getCode()==QType::CNAME || rr.qtype.getCode()==QType::NS || rr.qtype.getCode()==QType::PTR) { unsigned int frompos=0; unsigned char labellen; while((labellen=serial.at(frompos++))) { if((labellen & 0xc0) == 0xc0) { string encoded=simpleCompress(qname); uint16_t offset=256*(labellen & ~0xc0) + (unsigned int)serial.at(frompos++) - sizeof(dnsheader)-5; simpleExpandTo(encoded, offset, rr.content); // cerr<<"Oops, fallback, content so far: '"< regen=DNSRecordContent::unserialize(qname, qt.getCode(), serial); rr.content=regen->getZoneRepresentation(); } rr.content.reserve(0); rr.qname.reserve(0); return rr; } // returns the RDATA for rr - might be compressed! string DNSRR2String(const DNSResourceRecord& rr) { uint16_t type=rr.qtype.getCode(); if(type==QType::A) { uint32_t ip; IpToU32(rr.content, &ip); return string((char*)&ip, 4); } else if(type==QType::AAAA) { ComboAddress ca(rr.content); return string((char*)&ca.sin6.sin6_addr.s6_addr, 16); } else if(type==QType::NS || type==QType::CNAME) return simpleCompress(rr.content, rr.qname); else { string ret; shared_ptr drc(DNSRecordContent::mastermake(type, 1, rr.content)); ret=drc->serialize(rr.qname); // cerr<<"stored '"<d_qname.length(); for(vector::const_iterator j=i->d_records.begin(); j!= i->d_records.end(); ++j) ret+=j->size(); } return ret; } int MemRecursorCache::get(time_t now, const string &qname, const QType& qt, set* res) { unsigned int ttd=0; // cerr<<"looking up "<< qname+"|"+qt.getName()<<"\n"; if(!d_cachecachevalid || !pdns_iequals(d_cachedqname, qname)) { // cerr<<"had cache cache miss"<clear(); if(d_cachecache.first!=d_cachecache.second) { for(cache_t::const_iterator i=d_cachecache.first; i != d_cachecache.second; ++i) if(i->d_qtype == qt.getCode() || qt.getCode()==QType::ANY || (qt.getCode()==QType::ADDR && (i->d_qtype == QType::A || i->d_qtype == QType::AAAA) ) ) { for(vector::const_iterator k=i->d_records.begin(); k != i->d_records.end(); ++k) { if(k->d_ttd < 1000000000 || k->d_ttd > (uint32_t) now) { // FIXME what does the 100000000 number mean? ttd=k->d_ttd; if(res) { DNSResourceRecord rr=String2DNSRR(qname, QType(i->d_qtype), k->d_string, ttd); res->insert(rr); } } } if(res) { if(res->empty()) moveCacheItemToFront(d_cache, i); else moveCacheItemToBack(d_cache, i); } if(qt.getCode()!=QType::ANY && qt.getCode()!=QType::ADDR) // normally if we have a hit, we are done break; } // cerr<<"time left : "<size() : 0) <<"\n"; return (int)ttd-now; } return -1; } bool MemRecursorCache::attemptToRefreshNSTTL(const QType& qt, const set& content, const CacheEntry& stored) { if(!stored.d_auth) { //~ cerr<<"feel free to scribble non-auth data!"<d_ttd > content.begin()->ttl) { //~ cerr<<"attempt to LOWER TTL - fine by us"<& content, bool auth) { d_cachecachevalid=false; tuple key=make_tuple(qname, qt.getCode()); cache_t::iterator stored=d_cache.find(key); uint32_t maxTTD=UINT_MAX; bool isNew=false; if(stored == d_cache.end()) { stored=d_cache.insert(CacheEntry(key,vector(), auth)).first; isNew=true; } pair::iterator, vector::iterator> range; StoredRecord dr; CacheEntry ce=*stored; //~ cerr<<"asked to store "<< qname+"|"+qt.getName()<<" -> '"<content<<"', isnew="<::iterator j; for(j = ce.d_records.begin() ; j != ce.d_records.end(); ++j) if((time_t)j->d_ttd > now) break; if(j != ce.d_records.end()) { // we still have valid data, ignore unauth data // cerr<<"\tStill hold valid auth data, and the new data is unauth, return\n"; return; } else { ce.d_auth = false; // new data won't be auth } } // limit TTL of auth->auth NSset update if needed, except for root if(ce.d_auth && auth && qt.getCode()==QType::NS && !((qname.length()==1 && qname[0]=='.'))) { // cerr<<"\tLimiting TTL of auth->auth NS set replace"<::iterator j; for(j = ce.d_records.begin() ; j != ce.d_records.end(); ++j) { maxTTD=min(maxTTD, j->d_ttd); } } // make sure that we CAN refresh the root if(auth && ((qname.length()==1 && qname[0]=='.') || !attemptToRefreshNSTTL(qt, content, ce) ) ) { // cerr<<"\tGot auth data, and it was not refresh attempt of an unchanged NS set, nuking storage"<::const_iterator i=content.begin(); i != content.end(); ++i) { // cerr<<"To store: "<content<<" with ttl/ttd "<ttl<ttl); dr.d_string=DNSRR2String(*i); if(isNew) ce.d_records.push_back(dr); else { range=equal_range(ce.d_records.begin(), ce.d_records.end(), dr); if(range.first != range.second) { // cerr<<"\t\tMay need to modify TTL of stored record\n"; for(vector::iterator j=range.first ; j!=range.second; ++j) { /* see http://mailman.powerdns.com/pipermail/pdns-users/2006-May/003413.html */ if(j->d_ttd > (unsigned int) now && i->ttl > j->d_ttd && qt.getCode()==QType::NS && auth) { // don't allow auth servers to *raise* TTL of an NS record //~ cerr<<"\t\tNot doing so, trying to raise TTL NS\n"; continue; } if(i->ttl > j->d_ttd || (auth) ) { // authoritative packets can override the TTL to be lower //~ cerr<<"\t\tUpdating the ttl, diff="<d_ttd - i->ttl<d_ttd=i->ttl; } else { //~ cerr<<"\t\tNOT updating the ttl, old= " <d_ttd - now <<", new: "<ttl - now <(ce.d_records).swap(ce.d_records); d_cache.replace(stored, ce); } int MemRecursorCache::doWipeCache(const string& name, uint16_t qtype) { int count=0; d_cachecachevalid=false; pair range; if(qtype==0xffff) range=d_cache.equal_range(tie(name)); else range=d_cache.equal_range(tie(name, qtype)); for(cache_t::const_iterator i=range.first; i != range.second; ) { count++; d_cache.erase(i++); } return count; } bool MemRecursorCache::doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL) { cache_t::iterator iter = d_cache.find(tie(name, qtype)); uint32_t maxTTD=std::numeric_limits::min(); if(iter == d_cache.end()) { return false; } CacheEntry ce = *iter; if(ce.d_records.size()==1) { maxTTD=ce.d_records.begin()->d_ttd; } else { // find the LATEST ttd for(vector::const_iterator i=ce.d_records.begin(); i != ce.d_records.end(); ++i) maxTTD=max(maxTTD, i->d_ttd); } int32_t maxTTL = maxTTD - now; if(maxTTL < 0) return false; // would be dead anyhow if(maxTTL > newTTL) { d_cachecachevalid=false; uint32_t newTTD = now + newTTL; for(vector::iterator j = ce.d_records.begin() ; j != ce.d_records.end(); ++j) { if(j->d_ttd>newTTD) // do never renew expired or older TTLs j->d_ttd = newTTD; } d_cache.replace(iter, ce); return true; } return false; } uint64_t MemRecursorCache::doDumpNSSpeeds(int fd) { FILE* fp=fdopen(dup(fd), "w"); if(!fp) return 0; fprintf(fp, "; nsspeed dump from thread follows\n;\n"); uint64_t count=0; for(SyncRes::nsspeeds_t::iterator i = t_sstorage->nsSpeeds.begin() ; i!= t_sstorage->nsSpeeds.end(); ++i) { count++; fprintf(fp, "%s -> ", i->first.c_str()); for(SyncRes::DecayingEwmaCollection::collection_t::iterator j = i->second.d_collection.begin(); j!= i->second.d_collection.end(); ++j) { // typedef vector > collection_t; fprintf(fp, "%s/%f ", j->first.toString().c_str(), j->second.peek()); } fprintf(fp, "\n"); } fclose(fp); return count; } uint64_t MemRecursorCache::doDump(int fd) { FILE* fp=fdopen(dup(fd), "w"); if(!fp) { // dup probably failed return 0; } fprintf(fp, "; main record cache dump from thread follows\n;\n"); typedef cache_t::nth_index<1>::type sequence_t; sequence_t& sidx=d_cache.get<1>(); uint64_t count=0; time_t now=time(0); for(sequence_t::const_iterator i=sidx.begin(); i != sidx.end(); ++i) { for(vector::const_iterator j=i->d_records.begin(); j != i->d_records.end(); ++j) { count++; try { DNSResourceRecord rr=String2DNSRR(i->d_qname, QType(i->d_qtype), j->d_string, j->d_ttd - now); fprintf(fp, "%s %d IN %s %s\n", rr.qname.c_str(), rr.ttl, rr.qtype.getName().c_str(), rr.content.c_str()); } catch(...) { fprintf(fp, "; error printing '%s'\n", i->d_qname.c_str()); } } } fclose(fp); return count; } void MemRecursorCache::doPrune(void) { d_cachecachevalid=false; unsigned int maxCached=::arg().asNum("max-cache-entries") / g_numThreads; pruneCollection(d_cache, maxCached); } pdns-3.3/pdns/dns.cc0000644000014601777760000001341412136555572015640 0ustar00jenkinsnogroup00000000000000#include "dns.hh" #include "misc.hh" #include "arguments.hh" #include #include #include #include static void appendEscapedLabel(string& ret, const char* begin, unsigned char labellen) { unsigned char n = 0; for(n = 0 ; n < labellen; ++n) if(begin[n] == '.' || begin[n] == '\\' || begin[n] == ' ') break; if( n == labellen) { ret.append(begin, labellen); return; } string label(begin, labellen); boost::replace_all(label, "\\", "\\\\"); boost::replace_all(label, ".", "\\."); boost::replace_all(label, " ", "\\032"); ret.append(label); } class BoundsCheckingPointer { public: explicit BoundsCheckingPointer(const char* a, unsigned int length) : d_ptr(a), d_length(length) {} explicit BoundsCheckingPointer(const std::string& str) : d_ptr(str.c_str()), d_length(str.size()) {} const char operator[](unsigned int offset) const { if(offset < d_length) return d_ptr[offset]; else throw runtime_error("out of bounds: "+boost::lexical_cast(offset)+" >= " + boost::lexical_cast(d_length)); } private: const char* d_ptr; const unsigned int d_length; }; //! compares two dns packets, skipping the header, but including the question and the qtype bool dnspacketLessThan(const std::string& a, const std::string& b) { if(a.length() <= 12 || b.length() <= 12) return a.length() < b.length(); // throw runtime_error("Error parsing question in dnspacket comparison: packet too short"); // we find: 3www4ds9a2nl0XXYY, where XX and YY are each 2 bytes describing class and type BoundsCheckingPointer aSafe(a), bSafe(b); int aPos=12, bPos=12; unsigned char aLabelLen, bLabelLen; do { aLabelLen = aSafe[aPos++]; bLabelLen = bSafe[bPos++]; // cerr<<"aLabelLen: "<<(int)aLabelLen<<", bLabelLen: "<< (int)bLabelLen< end) throw runtime_error("Error parsing question in incoming packet: label extends beyond packet"); appendEscapedLabel(ret, (const char*) pos, labellen); ret.append(1, '.'); pos += labellen; } if(pos + labellen + 2 <= end) type=(*pos)*256 + *(pos+1); // cerr << "returning: '"<parts; stringtok(parts,content); int pleft=parts.size(); // cout<<"'"<1) data.hostmaster=attodot(parts[1]); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl data.serial = pleft > 2 ? strtoul(parts[2].c_str(), NULL, 10) : 0; data.refresh = pleft > 3 ? atoi(parts[3].c_str()) : ::arg().asNum("soa-refresh-default"); data.retry = pleft > 4 ? atoi(parts[4].c_str()) : ::arg().asNum("soa-retry-default"); data.expire = pleft > 5 ? atoi(parts[5].c_str()) : ::arg().asNum("soa-expire-default"); data.default_ttl = pleft > 6 ?atoi(parts[6].c_str()) : ::arg().asNum("soa-minimum-ttl"); } string serializeSOAData(const SOAData &d) { ostringstream o; // nameservername hostmaster serial-number [refresh [retry [expire [ minimum] ] ] ] o<((int)rcode); } pdns-3.3/pdns/dns.hh0000644000014601777760000002617312155272633015653 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // $Id$ /* (C) 2002 POWERDNS.COM BV */ #ifndef DNS_HH #define DNS_HH #include #include #include #include #include #include #include #include "utility.hh" #include "qtype.hh" #include #include class DNSBackend; struct SOAData { SOAData() : db(0), scopeMask(0) {}; string qname; string nameserver; string hostmaster; uint32_t ttl; uint32_t serial; uint32_t refresh; uint32_t retry; uint32_t expire; uint32_t default_ttl; int domain_id; DNSBackend *db; uint8_t scopeMask; }; class RCode { public: enum rcodes_ { NoError=0, FormErr=1, ServFail=2, NXDomain=3, NotImp=4, Refused=5, NotAuth=9 }; }; class Opcode { public: enum { Query=0, IQuery=1, Status=2, Notify=4, Update=5 }; }; //! This class represents a resource record class DNSResourceRecord { public: DNSResourceRecord() : qclass(1), priority(0), signttl(0), last_modified(0), d_place(ANSWER), auth(1), scopeMask(0) {}; ~DNSResourceRecord(){}; // data QType qtype; //!< qtype of this record, ie A, CNAME, MX etc uint16_t qclass; //!< class of this record string qname; //!< the name of this record, for example: www.powerdns.com string wildcardname; string content; //!< what this record points to. Example: 10.1.2.3 uint16_t priority; //!< For qtypes that support a priority or preference (MX, SRV) uint32_t ttl; //!< Time To Live of this record uint32_t signttl; //!< If non-zero, use this TTL as original TTL in the RRSIG int domain_id; //!< If a backend implements this, the domain_id of the zone this record is in time_t last_modified; //!< For autocalculating SOA serial numbers - the backend needs to fill this in enum Place {QUESTION=0, ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //!< Type describing the positioning of a DNSResourceRecord within, say, a DNSPacket Place d_place; //!< This specifies where a record goes within the packet bool auth; uint8_t scopeMask; template void serialize(Archive & ar, const unsigned int version) { ar & qtype; ar & qclass; ar & qname; ar & wildcardname; ar & content; ar & priority; ar & ttl; ar & domain_id; ar & last_modified; ar & d_place; ar & auth; } bool operator<(const DNSResourceRecord &b) const { if(qname < b.qname) return true; if(qname == b.qname) return(content < b.content); return false; } }; #ifdef _MSC_VER # pragma pack ( push ) # pragma pack ( 1 ) # define GCCPACKATTRIBUTE #else # define GCCPACKATTRIBUTE __attribute__((packed)) #endif struct dnsrecordheader { uint16_t d_type; uint16_t d_class; uint32_t d_ttl; uint16_t d_clen; } GCCPACKATTRIBUTE; struct EDNS0Record { uint8_t extRCode, version; uint16_t Z; } GCCPACKATTRIBUTE; #ifdef _MSC_VER #pragma pack (pop) #endif enum { ns_t_invalid = 0, /* Cookie. */ ns_t_a = 1, /* Host address. */ ns_t_ns = 2, /* Authoritative server. */ ns_t_md = 3, /* Mail destination. */ ns_t_mf = 4, /* Mail forwarder. */ ns_t_cname = 5, /* Canonical name. */ ns_t_soa = 6, /* Start of authority zone. */ ns_t_mb = 7, /* Mailbox domain name. */ ns_t_mg = 8, /* Mail group member. */ ns_t_mr = 9, /* Mail rename name. */ ns_t_null = 10, /* Null resource record. */ ns_t_wks = 11, /* Well known service. */ ns_t_ptr = 12, /* Domain name pointer. */ ns_t_hinfo = 13, /* Host information. */ ns_t_minfo = 14, /* Mailbox information. */ ns_t_mx = 15, /* Mail routing information. */ ns_t_txt = 16, /* Text strings. */ ns_t_rp = 17, /* Responsible person. */ ns_t_afsdb = 18, /* AFS cell database. */ ns_t_x25 = 19, /* X_25 calling address. */ ns_t_isdn = 20, /* ISDN calling address. */ ns_t_rt = 21, /* Router. */ ns_t_nsap = 22, /* NSAP address. */ ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ ns_t_sig = 24, /* Security signature. */ ns_t_key = 25, /* Security key. */ ns_t_px = 26, /* X.400 mail mapping. */ ns_t_gpos = 27, /* Geographical position (withdrawn). */ ns_t_aaaa = 28, /* Ip6 Address. */ ns_t_loc = 29, /* Location Information. */ ns_t_nxt = 30, /* Next domain (security). */ ns_t_eid = 31, /* Endpoint identifier. */ ns_t_nimloc = 32, /* Nimrod Locator. */ ns_t_srv = 33, /* Server Selection. */ ns_t_atma = 34, /* ATM Address */ ns_t_naptr = 35, /* Naming Authority PoinTeR */ ns_t_kx = 36, /* Key Exchange */ ns_t_cert = 37, /* Certification record */ ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ ns_t_sink = 40, /* Kitchen sink (experimental) */ ns_t_opt = 41, /* EDNS0 option (meta-RR) */ ns_t_ds = 43, /* Delegation signer */ ns_t_ipseckey = 45, /* IPSEC Key */ ns_t_rrsig = 46, /* Resoure Record signature */ ns_t_nsec = 47, /* Next Record */ ns_t_dnskey = 48, /* DNSKEY record */ ns_t_nsec3 = 50, /* Next Record v3 */ ns_t_nsec3param = 51, /* NSEC Parameters */ ns_t_tlsa = 52, /* TLSA */ ns_t_eui48 = 108, /* EUI-48 */ ns_t_eui64 = 109, /* EUI-64 */ ns_t_tsig = 250, /* Transaction signature. */ ns_t_ixfr = 251, /* Incremental zone transfer. */ ns_t_axfr = 252, /* Transfer zone of authority. */ ns_t_mailb = 253, /* Transfer mailbox records. */ ns_t_maila = 254, /* Transfer mail agent records. */ ns_t_any = 255, /* Wildcard match. */ }; #ifdef WIN32 #define BYTE_ORDER 1 #define LITTLE_ENDIAN 1 #elif __FreeBSD__ || __APPLE__ || __OpenBSD__ #include #elif __linux__ # include #else // with thanks to # define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ # define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ # define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ defined(__i386) || defined(__ia64) || defined(__amd64) || \ defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ defined(__alpha__) || defined(__alpha) || \ (defined(__Lynx__) && defined(__x86__)) # define BYTE_ORDER LITTLE_ENDIAN #endif #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ defined(__sparc) || \ defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ defined(apollo) || defined(__convex__) || defined(_CRAY) || \ defined(__hppa) || defined(__hp9000) || \ defined(__hp9000s300) || defined(__hp9000s700) || \ defined(__hp3000s900) || defined(MPE) || \ defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \ (defined(__Lynx__) && \ (defined(__68k__) || defined(__sparc__) || defined(__powerpc__))) # define BYTE_ORDER BIG_ENDIAN #endif #endif struct dnsheader { unsigned id :16; /* query identification number */ #if BYTE_ORDER == BIG_ENDIAN /* fields in third byte */ unsigned qr: 1; /* response flag */ unsigned opcode: 4; /* purpose of message */ unsigned aa: 1; /* authoritive answer */ unsigned tc: 1; /* truncated message */ unsigned rd: 1; /* recursion desired */ /* fields in fourth byte */ unsigned ra: 1; /* recursion available */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned ad: 1; /* authentic data from named */ unsigned cd: 1; /* checking disabled by resolver */ unsigned rcode :4; /* response code */ #endif #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN /* fields in third byte */ unsigned rd :1; /* recursion desired */ unsigned tc :1; /* truncated message */ unsigned aa :1; /* authoritive answer */ unsigned opcode :4; /* purpose of message */ unsigned qr :1; /* response flag */ /* fields in fourth byte */ unsigned rcode :4; /* response code */ unsigned cd: 1; /* checking disabled by resolver */ unsigned ad: 1; /* authentic data from named */ unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ unsigned ra :1; /* recursion available */ #endif /* remaining bytes */ unsigned qdcount :16; /* number of question entries */ unsigned ancount :16; /* number of answer entries */ unsigned nscount :16; /* number of authority entries */ unsigned arcount :16; /* number of resource entries */ }; #define L theL() extern time_t s_starttime; std::string questionExpand(const char* packet, uint16_t len, uint16_t& type); bool dnspacketLessThan(const std::string& a, const std::string& b); /** helper function for both DNSPacket and addSOARecord() - converts a line into a struct, for easier parsing */ void fillSOAData(const string &content, SOAData &data); /** for use by DNSPacket, converts a SOAData class to a ascii line again */ string serializeSOAData(const SOAData &data); string &attodot(string &str); //!< for when you need to insert an email address in the SOA string strrcode(unsigned char rcode); #endif pdns-3.3/pdns/config.sub0000755000014601777760000007054312136555572016536 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-03-07' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dsp16xx \ | fr30 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el | mips64vr4300 \ | mips64vr4300el | mips64vr5000 | mips64vr5000el \ | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ | mipsisa32 | mipsisa64 \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3d) basic_machine=alpha-cray os=-unicos ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: pdns-3.3/pdns/htimer.cc0000644000014601777760000000520612136555572016344 0ustar00jenkinsnogroup00000000000000#include #include "htimer.hh" #include HTimer::timers_t HTimer::s_timers; #include "namespaces.hh" #include "namespaces.hh" /* idea: nested timers, where the hierarchy of nesting is constructed at runtime. Each timer can have multiple positions in the hierarchy, and might conceivable nest within itself. Desired result: Processing incoming questions Rest Parsing question Rest MOADNSParser Searching cache Processing Server Answers Rest MOADNSParser Waiting for packets Parsing question Rest MOADDNSParser Processing Server Answers Rest MOADNSParser Waiting for packets */ #define RDTSC(qp) \ do { \ unsigned long lowPart, highPart; \ __asm__ __volatile__("rdtsc" : "=a" (lowPart), "=d" (highPart)); \ qp = (((unsigned long long) highPart) << 32) | lowPart; \ } while (0) HTimer::HTimer(const std::string& name) : d_accumulated(0), d_started(0) { s_timers[name]=this; } HTimer::~HTimer() { for(timers_t::iterator iter = s_timers.begin(); iter != s_timers.end() ; ++iter) { if(iter->second == this) { s_timers.erase(iter); break; } } } void HTimer::start() { if(d_started) throw runtime_error("HTimer restarted!"); RDTSC(d_started); } void HTimer::stop() { if(!d_started) throw runtime_error("HTimer stopped that wasn't started!"); uint64_t stopped; RDTSC(stopped); d_accumulated += stopped - d_started; d_started=0; } uint64_t HTimer::getAccumulated() const { uint64_t accumulated = d_accumulated; if(d_started) { uint64_t midterm; RDTSC(midterm); accumulated += midterm - d_started; } return accumulated; } uint64_t HTimer::getAccumulatedReset() { uint64_t accumulated = d_accumulated; if(d_started) { uint64_t midterm; RDTSC(midterm); accumulated += midterm - d_started; d_started=midterm; } d_accumulated=0; return accumulated; } HTimerSentinel HTimer::getSentinel() { return HTimerSentinel(this); } void HTimer::listAll() { for(timers_t::iterator iter = s_timers.begin(); iter != s_timers.end() ; ++iter) { cerr << iter->first <<": " << iter->second->getAccumulatedReset()/3000.0 <<"usec\n"; } } #if 0 int main() { char *q = new char; delete q; HTimer htmain("main"); htmain.start(); HTimer htloop("loop"); { HTimerSentinel hts=htloop.getSentinel(); for(int i=0; i < 1000; ++i) { shared_ptr p(shared_ptr(new char)); } } htloop.listAll(); cerr<<"accumulated: "<< htmain.getAccumulated() < void pruneCollection(T& collection, unsigned int maxCached, unsigned int scanFraction=1000) { uint32_t now=(uint32_t)time(0); unsigned int toTrim=0; unsigned int cacheSize=collection.size(); if(cacheSize > maxCached) { toTrim = cacheSize - maxCached; } // cout<<"Need to trim "<::type sequence_t; sequence_t& sidx=collection.template get<1>(); unsigned int tried=0, lookAt, erased=0; // two modes - if toTrim is 0, just look through 1/scanFraction of all records // and nuke everything that is expired // otherwise, scan first 5*toTrim records, and stop once we've nuked enough if(toTrim) lookAt=5*toTrim; else lookAt=cacheSize/scanFraction; typename sequence_t::iterator iter=sidx.begin(), eiter; for(; iter != sidx.end() && tried < lookAt ; ++tried) { if(iter->getTTD() < now) { sidx.erase(iter++); erased++; } else ++iter; if(toTrim && erased > toTrim) break; } //cout<<"erased "<= toTrim) // done return; toTrim -= erased; //if(toTrim) // cout<<"Still have "< void moveCacheItemToFrontOrBack(T& collection, typename T::iterator& iter, bool front) { typedef typename T::template nth_index<1>::type sequence_t; sequence_t& sidx=collection.template get<1>(); typename sequence_t::iterator si=collection.template project<1>(iter); if(front) sidx.relocate(sidx.begin(), si); // at the beginning of the delete queue else sidx.relocate(sidx.end(), si); // back } template void moveCacheItemToFront(T& collection, typename T::iterator& iter) { moveCacheItemToFrontOrBack(collection, iter, true); } template void moveCacheItemToBack(T& collection, typename T::iterator& iter) { moveCacheItemToFrontOrBack(collection, iter, false); } #endif pdns-3.3/pdns/dnsproxy.hh0000644000014601777760000000512712136555572016756 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_DNSPROXY #define PDNS_DNSPROXY #include #include #ifndef WIN32 # include # include # include #endif // WIN32 #include "dnspacket.hh" #include "lock.hh" #include "iputils.hh" #include "namespaces.hh" /** how will this work. This is a thread that just throws packets around. Should handle ~1000 packets/second. Consists of a thread receiving packets back from the backend and retransmitting them to the original client. Furthermore, it provides a member function that reports the packet to the connection tracker and actually sends it out. The sending happens from a source port that is determined by the constructor, but IS random. Furthermore, the ID is XOR-ed with a random value to make sure outside parties can't spoof us. To fix: how to remove the stale entries that will surely accumulate */ class DNSProxy { public: DNSProxy(const string &ip); //!< creates socket void go(); //!< launches the actual thread void onlyFrom(const string &ips); //!< Only these netmasks are allowed to recurse via us bool sendPacket(DNSPacket *p); //!< send out a packet and make a conntrack entry to we can send back the answer void mainloop(); //!< this is the main loop that receives reply packets and sends them out again static void *launchhelper(void *p) { static_cast(p)->mainloop(); return 0; } bool recurseFor(DNSPacket* p); private: NetmaskGroup d_ng; int d_sock; unsigned int* d_resanswers; unsigned int* d_udpanswers; unsigned int* d_resquestions; pthread_mutex_t d_lock; uint16_t d_xor; int getID_locked(); struct ConntrackEntry { uint16_t id; ComboAddress remote; int outsock; time_t created; string qname; uint16_t qtype; }; typedef map map_t; map_t d_conntrack; }; #endif pdns-3.3/pdns/test-base64_cc.cc0000644000014601777760000000514612142151015017542 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include #include #include "base64.hh" using namespace boost; BOOST_AUTO_TEST_SUITE(base64_cc) BOOST_AUTO_TEST_CASE(test_Base64_Roundtrip) { std::string before("Some Random String"), after; std::string encoded = Base64Encode(before); B64Decode(encoded, after); BOOST_CHECK_EQUAL(before, after); } /* for a in $(seq 1 32); do plain=$(pwgen -1 -s $a) echo \(\"$plain\",\"$(echo -n $plain | openssl enc -base64)\"\) ; done */ BOOST_AUTO_TEST_CASE(test_Base64_Encode) { typedef std::map cases_t; cases_t cases; assign::insert(cases)("z","eg==") ("x4","eDQ=") ("J07","SjA3") ("kl8F","a2w4Rg==") ("2NUx9","Mk5VeDk=") ("hwXQ8C","aHdYUThD") ("V7ZHmlG","VjdaSG1sRw==") ("FuNFLSd5","RnVORkxTZDU=") ("YVGwy3Vbi","WVZHd3kzVmJp") ("6ueW4V3oLG","NnVlVzRWM29MRw==") ("d5zR7AWIBIQ","ZDV6UjdBV0lCSVE=") ("WJjZ6xgpRMCD","V0pqWjZ4Z3BSTUNE") ("e8I52L0vC9Kfq","ZThJNTJMMHZDOUtmcQ==") ("ufxMi8EZgTDja8","dWZ4TWk4RVpnVERqYTg=") ("MiNPxzxUkNXCFg1","TWlOUHh6eFVrTlhDRmcx") ("abqIPosEky85gFVM","YWJxSVBvc0VreTg1Z0ZWTQ==") ("Qccuox8igoyRKEeTo","UWNjdW94OGlnb3lSS0VlVG8=") ("wbaw6g6WWo4iiYXosV","d2JhdzZnNldXbzRpaVlYb3NW") ("ZIfJZIA3Kd0a6iIr0vc","WklmSlpJQTNLZDBhNmlJcjB2Yw==") ("SUhE1RK7xrRfvYOiaPMQ","U1VoRTFSSzd4clJmdllPaWFQTVE=") ("ZAWsEeB4bcTUzTr828VTd","WkFXc0VlQjRiY1RVelRyODI4VlRk") ("xc9rpu0F5ztR7r3jElr2BS","eGM5cnB1MEY1enRSN3IzakVscjJCUw==") ("xvEWPkZjqVjIZwsL5WhijES","eHZFV1BrWmpxVmpJWndzTDVXaGlqRVM=") ("yy4yAmcBKCNF3hWriWbDnKmF","eXk0eUFtY0JLQ05GM2hXcmlXYkRuS21G") ("9wKEMpl8OlFvnD10wwhoK7BjY","OXdLRU1wbDhPbEZ2bkQxMHd3aG9LN0JqWQ==") ("SB6yLm39pDVIUiQ5g73BvyRzBs","U0I2eUxtMzlwRFZJVWlRNWc3M0J2eVJ6QnM=") ("Acu4kk1puF98lIzd1b9bt8ha7Er","QWN1NGtrMXB1Rjk4bEl6ZDFiOWJ0OGhhN0Vy") ("P4X6efItE6cn03ksLTvniqMQlel3","UDRYNmVmSXRFNmNuMDNrc0xUdm5pcU1RbGVsMw==") ("RnQSvhIOz3ywuHCoSotJGKjBdCVbx","Um5RU3ZoSU96M3l3dUhDb1NvdEpHS2pCZENWYng=") ("ykybXtN0lelsLSzyzd4DTP3sYp8YGu","eWt5Ylh0TjBsZWxzTFN6eXpkNERUUDNzWXA4WUd1") ("eSHBt7Xx5F7A4HFtabXEzDLD01bnSiG","ZVNIQnQ3WHg1RjdBNEhGdGFiWEV6RExEMDFiblNpRw==") ("dq4KydZjmcoQQ45VYBP2EDR8FqKaMul0","ZHE0S3lkWmptY29RUTQ1VllCUDJFRFI4RnFLYU11bDA="); BOOST_FOREACH(const cases_t::value_type& val, cases) { std::string encoded = Base64Encode(val.first), decoded; BOOST_CHECK_EQUAL(encoded, val.second); B64Decode(encoded, decoded); BOOST_CHECK_EQUAL(decoded, val.first); } } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/README0000644000014601777760000000003612136555572015421 0ustar00jenkinsnogroup00000000000000See http://doc.powerdns.com pdns-3.3/pdns/misc.cc0000644000014601777760000004177612165455411016014 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2010 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef WIN32 #include #include #include #include #include #include #endif // WIN32 #include "misc.hh" #include #include #include #include #include #include #include #include #include #include #include #include #include "ahuexception.hh" #include #include "utility.hh" #include #include "logger.hh" bool g_singleThreaded; int writen2(int fd, const void *buf, size_t count) { const char *ptr = (char*)buf; const char *eptr = ptr + count; int res; while(ptr != eptr) { res = ::write(fd, ptr, eptr - ptr); if(res < 0) { if (errno == EAGAIN) throw std::runtime_error("used writen2 on non-blocking socket, got EAGAIN"); else unixDie("failed in writen2"); } else if (res == 0) throw std::runtime_error("could not write all bytes, got eof in writen2"); ptr += res; } return count; } string nowTime() { time_t now=time(0); string t=ctime(&now); boost::trim_right(t); return t; } uint16_t getShort(const unsigned char *p) { return p[0] * 256 + p[1]; } uint16_t getShort(const char *p) { return getShort((const unsigned char *)p); } uint32_t getLong(const unsigned char* p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } uint32_t getLong(const char* p) { return getLong((unsigned char *)p); } /** strips a domain suffix from a domain, returns true if it stripped */ bool stripDomainSuffix(string *qname, const string &domain) { if(!endsOn(*qname, domain)) return false; if(toLower(*qname)==toLower(domain)) *qname="@"; else { if((*qname)[qname->size()-domain.size()-1]!='.') return false; qname->resize(qname->size()-domain.size()-1); } return true; } /** Chops off the start of a domain, so goes from 'www.ds9a.nl' to 'ds9a.nl' to 'nl' to ''. Return zero on the empty string */ bool chopOff(string &domain) { if(domain.empty()) return false; string::size_type fdot=domain.find('.'); if(fdot==string::npos) domain=""; else { string::size_type remain = domain.length() - (fdot + 1); char tmp[remain]; memcpy(tmp, domain.c_str()+fdot+1, remain); domain.assign(tmp, remain); // don't dare to do this w/o tmp holder :-) } return true; } /** Chops off the start of a domain, so goes from 'www.ds9a.nl.' to 'ds9a.nl.' to 'nl.' to '.' Return zero on the empty string */ bool chopOffDotted(string &domain) { if(domain.empty() || (domain.size()==1 && domain[0]=='.')) return false; string::size_type fdot=domain.find('.'); if(fdot == string::npos) return false; if(fdot==domain.size()-1) domain="."; else { string::size_type remain = domain.length() - (fdot + 1); char tmp[remain]; memcpy(tmp, domain.c_str()+fdot+1, remain); domain.assign(tmp, remain); } return true; } bool ciEqual(const string& a, const string& b) { if(a.size()!=b.size()) return false; string::size_type pos=0, epos=a.size(); for(;pos < epos; ++pos) if(dns_tolower(a[pos])!=dns_tolower(b[pos])) return false; return true; } /** does domain end on suffix? Is smart about "wwwds9a.nl" "ds9a.nl" not matching */ bool endsOn(const string &domain, const string &suffix) { if( suffix.empty() || ciEqual(domain, suffix) ) return true; if(domain.size()<=suffix.size()) return false; string::size_type dpos=domain.size()-suffix.size()-1, spos=0; if(domain[dpos++]!='.') return false; for(; dpos < domain.size(); ++dpos, ++spos) if(dns_tolower(domain[dpos]) != dns_tolower(suffix[spos])) return false; return true; } /** does domain end on suffix? Is smart about "wwwds9a.nl" "ds9a.nl" not matching */ bool dottedEndsOn(const string &domain, const string &suffix) { if( suffix=="." || ciEqual(domain, suffix) ) return true; if(domain.size()<=suffix.size()) return false; string::size_type dpos=domain.size()-suffix.size()-1, spos=0; if(domain[dpos++]!='.') return false; for(; dpos < domain.size(); ++dpos, ++spos) if(dns_tolower(domain[dpos]) != dns_tolower(suffix[spos])) return false; return true; } int sendData(const char *buffer, int replen, int outsock) { uint16_t nlen=htons(replen); Utility::iovec iov[2]; iov[0].iov_base=(char*)&nlen; iov[0].iov_len=2; iov[1].iov_base=(char*)buffer; iov[1].iov_len=replen; int ret=Utility::writev(outsock,iov,2); if(ret <= 0) // "EOF is error" - we can't deal with EAGAIN errors at this stage yet return -1; if(ret!=replen+2) { // we can safely assume ret > 2, as 2 is < PIPE_BUF buffer += (ret - 2); replen -= (ret - 2); while (replen) { ret = write(outsock, buffer, replen); if(ret < 0) { if(errno==EAGAIN) { // wait, we might've exhausted the window while(waitForRWData(outsock, false, 1, 0)==0) ; continue; } return ret; } if(!ret) return -1; // "EOF == error" replen -= ret; buffer += ret; } if(!replen) return 0; return -1; } return 0; } static void parseService4(const string &descr, ServiceTuple &st) { vectorparts; stringtok(parts,descr,":"); if(parts.empty()) throw AhuException("Unable to parse '"+descr+"' as a service"); st.host=parts[0]; if(parts.size()>1) st.port=atoi(parts[1].c_str()); } static void parseService6(const string &descr, ServiceTuple &st) { string::size_type pos=descr.find(']'); if(pos == string::npos) throw AhuException("Unable to parse '"+descr+"' as an IPv6 service"); st.host=descr.substr(1, pos-1); if(pos + 2 < descr.length()) st.port=atoi(descr.c_str() + pos +2); } void parseService(const string &descr, ServiceTuple &st) { if(descr.empty()) throw AhuException("Unable to parse '"+descr+"' as a service"); vector parts; stringtok(parts, descr, ":"); if(descr[0]=='[') { parseService6(descr, st); } else if(descr[0]==':' || parts.size() > 2 || descr.find("::") != string::npos) { st.host=descr; } else { parseService4(descr, st); } } // returns -1 in case if error, 0 if no data is available, 1 if there is. In the first two cases, errno is set int waitForData(int fd, int seconds, int useconds) { return waitForRWData(fd, true, seconds, useconds); } int waitForRWData(int fd, bool waitForRead, int seconds, int useconds) { int ret; struct pollfd pfd; memset(&pfd, 0, sizeof(pfd)); pfd.fd = fd; if(waitForRead) pfd.events=POLLIN; else pfd.events=POLLOUT; ret = poll(&pfd, 1, seconds * 1000 + useconds/1000); if ( ret == -1 ) errno = ETIMEDOUT; // ??? return ret; } // returns -1 in case of error, 0 if no data is available, 1 if there is. In the first two cases, errno is set int waitFor2Data(int fd1, int fd2, int seconds, int useconds, int*fd) { int ret; struct pollfd pfds[2]; memset(&pfds[0], 0, 2*sizeof(struct pollfd)); pfds[0].fd = fd1; pfds[1].fd = fd2; pfds[0].events= pfds[1].events = POLLIN; int nsocks = 1 + (fd2 >= 0); // fd2 can optionally be -1 if(seconds >= 0) ret = poll(pfds, nsocks, seconds * 1000 + useconds/1000); else ret = poll(pfds, nsocks, -1); if(!ret || ret < 0) return ret; if((pfds[0].revents & POLLIN) && !(pfds[1].revents & POLLIN)) *fd = pfds[0].fd; else if((pfds[1].revents & POLLIN) && !(pfds[0].revents & POLLIN)) *fd = pfds[1].fd; else if(ret == 2) { *fd = pfds[random()%2].fd; } else *fd = -1; // should never happen return 1; } string humanDuration(time_t passed) { ostringstream ret; if(passed<60) ret<> 24)&0xff, (val >> 16)&0xff, (val >> 8)&0xff, (val )&0xff); return tmp; } string makeHexDump(const string& str) { char tmp[5]; string ret; ret.reserve((int)(str.size()*2.2)); for(string::size_type n=0;n& rrs) { vector::iterator first, second; for(first=rrs.begin();first!=rrs.end();++first) if(first->d_place==DNSResourceRecord::ANSWER && first->qtype.getCode() != QType::CNAME) // CNAME must come first break; for(second=first;second!=rrs.end();++second) if(second->d_place!=DNSResourceRecord::ANSWER) break; if(second-first>1) random_shuffle(first,second); // now shuffle the additional records for(first=second;first!=rrs.end();++first) if(first->d_place==DNSResourceRecord::ADDITIONAL && first->qtype.getCode() != QType::CNAME) // CNAME must come first break; for(second=first;second!=rrs.end();++second) if(second->d_place!=DNSResourceRecord::ADDITIONAL) break; if(second-first>1) random_shuffle(first,second); // we don't shuffle the rest } static bool comparePlace(DNSResourceRecord a, DNSResourceRecord b) { return (a.d_place < b.d_place); } // make sure rrs is sorted in d_place order to avoid surprises later // then shuffle the parts that desire shuffling void orderAndShuffle(vector& rrs) { std::stable_sort(rrs.begin(), rrs.end(), comparePlace); shuffle(rrs); } void normalizeTV(struct timeval& tv) { if(tv.tv_usec > 1000000) { ++tv.tv_sec; tv.tv_usec-=1000000; } else if(tv.tv_usec < 0) { --tv.tv_sec; tv.tv_usec+=1000000; } } const struct timeval operator+(const struct timeval& lhs, const struct timeval& rhs) { struct timeval ret; ret.tv_sec=lhs.tv_sec + rhs.tv_sec; ret.tv_usec=lhs.tv_usec + rhs.tv_usec; normalizeTV(ret); return ret; } const struct timeval operator-(const struct timeval& lhs, const struct timeval& rhs) { struct timeval ret; ret.tv_sec=lhs.tv_sec - rhs.tv_sec; ret.tv_usec=lhs.tv_usec - rhs.tv_usec; normalizeTV(ret); return ret; } pair splitField(const string& inp, char sepa) { pair ret; string::size_type cpos=inp.find(sepa); if(cpos==string::npos) ret.first=inp; else { ret.first=inp.substr(0, cpos); ret.second=inp.substr(cpos+1); } return ret; } int logFacilityToLOG(unsigned int facility) { switch(facility) { case 0: return LOG_LOCAL0; case 1: return(LOG_LOCAL1); case 2: return(LOG_LOCAL2); case 3: return(LOG_LOCAL3); case 4: return(LOG_LOCAL4); case 5: return(LOG_LOCAL5); case 6: return(LOG_LOCAL6); case 7: return(LOG_LOCAL7); default: return -1; } } string stripDot(const string& dom) { if(dom.empty()) return dom; if(dom[dom.size()-1]!='.') return dom; return dom.substr(0,dom.size()-1); } string labelReverse(const std::string& qname) { if(qname.empty()) return qname; bool dotName = qname.find('.') != string::npos; vector labels; stringtok(labels, qname, ". "); if(labels.size()==1) return qname; string ret; // vv const_reverse_iter http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729 for(vector::reverse_iterator iter = labels.rbegin(); iter != labels.rend(); ++iter) { if(iter != labels.rbegin()) ret.append(1, dotName ? ' ' : '.'); ret+=*iter; } return ret; } // do NOT feed trailing dots! // www.powerdns.com, powerdns.com -> www string makeRelative(const std::string& fqdn, const std::string& zone) { if(zone.empty()) return fqdn; if(fqdn != zone) return fqdn.substr(0, fqdn.size() - zone.length() - 1); // strip domain name return ""; } string dotConcat(const std::string& a, const std::string &b) { if(a.empty() || b.empty()) return a+b; else return a+"."+b; } int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret) { if(addr.empty()) return -1; string ourAddr(addr); int port = -1; if(addr[0]=='[') { // [::]:53 style address string::size_type pos = addr.find(']'); if(pos == string::npos || pos + 2 > addr.size() || addr[pos+1]!=':') return -1; ourAddr.assign(addr.c_str() + 1, pos-1); port = atoi(addr.c_str()+pos+2); } struct addrinfo* res; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_flags = AI_NUMERICHOST; int error; if((error=getaddrinfo(ourAddr.c_str(), 0, &hints, &res))) { // this is correct /* cerr<<"Error translating IPv6 address '"<ai_addr, res->ai_addrlen); if(port >= 0) ret->sin6_port = htons(port); freeaddrinfo(res); return 0; } int makeIPv4sockaddr(const string &str, struct sockaddr_in* ret) { if(str.empty()) { return -1; } struct in_addr inp; string::size_type pos = str.find(':'); if(pos == string::npos) { // no port specified, not touching the port if(Utility::inet_aton(str.c_str(), &inp)) { ret->sin_addr.s_addr=inp.s_addr; return 0; } return -1; } if(!*(str.c_str() + pos + 1)) // trailing : return -1; char *eptr = (char*)str.c_str() + str.size(); int port = strtol(str.c_str() + pos + 1, &eptr, 10); if(*eptr) return -1; ret->sin_port = htons(port); if(Utility::inet_aton(str.substr(0, pos).c_str(), &inp)) { ret->sin_addr.s_addr=inp.s_addr; return 0; } return -1; } //! read a line of text from a FILE* to a std::string, returns false on 'no data' bool stringfgets(FILE* fp, std::string& line) { char buffer[1024]; line.clear(); do { if(!fgets(buffer, sizeof(buffer), fp)) return !line.empty(); line.append(buffer); } while(!strchr(buffer, '\n')); return true; } Regex::Regex(const string &expr) { if(regcomp(&d_preg, expr.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED)) throw AhuException("Regular expression did not compile"); } pdns-3.3/pdns/mplexer.hh0000644000014601777760000001135712136555572016546 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_MPLEXER_HH #define PDNS_MPLEXER_HH #include #include #include #include #include #include #include #include #include #include #include "utility.hh" class FDMultiplexerException : public std::runtime_error { public: FDMultiplexerException(const std::string& str) : std::runtime_error(str) {} }; /** Very simple FD multiplexer, based on callbacks and boost::any parameters As a special service, this parameter is kept around and can be modified, allowing for state to be stored inside the multiplexer. It has some "interesting" semantics */ class FDMultiplexer { public: // typedef boost::variant funcparam_t; typedef boost::any funcparam_t; protected: typedef boost::function< void(int, funcparam_t&) > callbackfunc_t; struct Callback { callbackfunc_t d_callback; funcparam_t d_parameter; struct timeval d_ttd; }; public: FDMultiplexer() : d_inrun(false) {} virtual ~FDMultiplexer() {} virtual int run(struct timeval* tv) = 0; //! Add an fd to the read watch list - currently an fd can only be on one list at a time! virtual void addReadFD(int fd, callbackfunc_t toDo, const funcparam_t& parameter=funcparam_t()) { this->addFD(d_readCallbacks, fd, toDo, parameter); } //! Add an fd to the write watch list - currently an fd can only be on one list at a time! virtual void addWriteFD(int fd, callbackfunc_t toDo, const funcparam_t& parameter=funcparam_t()) { this->addFD(d_writeCallbacks, fd, toDo, parameter); } //! Remove an fd from the read watch list. You can't call this function on an fd that is closed already! /** WARNING: references to 'parameter' become invalid after this function! */ virtual void removeReadFD(int fd) { this->removeFD(d_readCallbacks, fd); } //! Remove an fd from the write watch list. You can't call this function on an fd that is closed already! /** WARNING: references to 'parameter' become invalid after this function! */ virtual void removeWriteFD(int fd) { this->removeFD(d_writeCallbacks, fd); } virtual void setReadTTD(int fd, struct timeval tv, int timeout) { if(!d_readCallbacks.count(fd)) throw FDMultiplexerException("attempt to timestamp fd not in the multiplexer"); tv.tv_sec += timeout; d_readCallbacks[fd].d_ttd=tv; } virtual funcparam_t& getReadParameter(int fd) { if(!d_readCallbacks.count(fd)) throw FDMultiplexerException("attempt to look up data in multiplexer for unlisted fd "+boost::lexical_cast(fd)); return d_readCallbacks[fd].d_parameter; } virtual std::vector > getTimeouts(const struct timeval& tv) { std::vector > ret; for(callbackmap_t::iterator i=d_readCallbacks.begin(); i!=d_readCallbacks.end(); ++i) if(i->second.d_ttd.tv_sec && boost::tie(tv.tv_sec, tv.tv_usec) > boost::tie(i->second.d_ttd.tv_sec, i->second.d_ttd.tv_usec)) ret.push_back(std::make_pair(i->first, i->second.d_parameter)); return ret; } typedef FDMultiplexer* getMultiplexer_t(); typedef std::multimap FDMultiplexermap_t; static FDMultiplexermap_t& getMultiplexerMap() { static FDMultiplexermap_t theMap; return theMap; } virtual std::string getName() = 0; protected: typedef std::map callbackmap_t; callbackmap_t d_readCallbacks, d_writeCallbacks; virtual void addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter)=0; virtual void removeFD(callbackmap_t& cbmap, int fd)=0; bool d_inrun; callbackmap_t::iterator d_iter; void accountingAddFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter) { Callback cb; cb.d_callback=toDo; cb.d_parameter=parameter; memset(&cb.d_ttd, 0, sizeof(cb.d_ttd)); if(cbmap.count(fd)) throw FDMultiplexerException("Tried to add fd "+boost::lexical_cast(fd)+ " to multiplexer twice"); cbmap[fd]=cb; } void accountingRemoveFD(callbackmap_t& cbmap, int fd) { if(!cbmap.erase(fd)) throw FDMultiplexerException("Tried to remove unlisted fd "+boost::lexical_cast(fd)+ " from multiplexer"); } }; class SelectFDMultiplexer : public FDMultiplexer { public: SelectFDMultiplexer() {} virtual ~SelectFDMultiplexer() {} virtual int run(struct timeval* tv); virtual void addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter); virtual void removeFD(callbackmap_t& cbmap, int fd); std::string getName() { return "select"; } }; #endifpdns-3.3/pdns/TODO0000644000014601777760000000035112136555572015231 0ustar00jenkinsnogroup00000000000000This file is no longer maintained, its contents can now be found on: http://wiki.powerdns.com/trac/wiki/TodoList Some notes ---------- Recursor needs to re-learn shuffling done and truncation figure out negative recursor cache pdns-3.3/pdns/base32.hh0000644000014601777760000000026112136555572016141 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_BASE32_HH #define PDNS_BASE32_HH #include std::string toBase32Hex(const std::string& input); std::string fromBase32Hex(const std::string& input); #endif pdns-3.3/pdns/statbag.cc0000644000014601777760000001252512155641611016472 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include "statbag.hh" #include "ahuexception.hh" #include #include #include #include "arguments.hh" #include "lock.hh" #include "namespaces.hh" StatBag::StatBag() { d_doRings=false; pthread_mutex_init(&d_lock,0); } /** this NEEDS TO HAVE THE LOCK held already! */ void StatBag::exists(const string &key) { if(!d_stats.count(key)) { unlock(); // it's the details that count throw AhuException("Trying to deposit into unknown StatBag key '"+key+"'"); } } string StatBag::directory() { string dir; ostringstream o; lock(); for(map::const_iterator i=d_stats.begin(); i!=d_stats.end(); i++) { o<first<<"="<<*(i->second)<<","; } unlock(); dir=o.str(); return dir; } vectorStatBag::getEntries() { vector ret; lock(); for(map::const_iterator i=d_stats.begin(); i!=d_stats.end(); i++) ret.push_back(i->first); unlock(); return ret; } string StatBag::getDescrip(const string &item) { lock(); string tmp=d_keyDescrips[item]; unlock(); return tmp; } void StatBag::declare(const string &key, const string &descrip) { lock(); unsigned int *i=new unsigned int(0); d_stats[key]=i; d_keyDescrips[key]=descrip; unlock(); } void StatBag::set(const string &key, unsigned int value) { lock(); exists(key); *d_stats[key]=value; unlock(); } unsigned int StatBag::read(const string &key) { lock(); if(!d_stats.count(key)) { unlock(); return 0; } unsigned int tmp=*d_stats[key]; unlock(); return tmp; } unsigned int StatBag::readZero(const string &key) { lock(); if(!d_stats.count(key)) { unlock(); return 0; } unsigned int tmp=*d_stats[key]; d_stats[key]=0; unlock(); return tmp; } string StatBag::getValueStr(const string &key) { ostringstream o; o<::const_iterator i=d_stats.begin(); i!=d_stats.end(); i++) { delete i->second; } } StatRing::StatRing(unsigned int size) { d_size=size; d_items.resize(d_size); d_lock=0; d_pos=0; d_lock=new pthread_mutex_t; pthread_mutex_init(d_lock, 0); } void StatRing::resize(unsigned int newsize) { if(d_size==newsize) return; Lock l(d_lock); if(newsize>d_size) { d_size=newsize; d_items.resize(d_size); return; } // this is the hard part, shrink int startpos=d_pos-newsize; int rpos; vectornewring; for(unsigned int i=startpos;i &a, const pair &b) { return (a.second > b.second); } vector >StatRing::get() const { Lock l(d_lock); map res; for(vector::const_iterator i=d_items.begin();i!=d_items.end();++i) { if(!i->empty()) res[*i]++; } vector > tmp; for(map::const_iterator i=res.begin();i!=res.end();++i) tmp.push_back(*i); sort(tmp.begin(),tmp.end(),popisort); return tmp; } void StatBag::declareRing(const string &name, const string &help, unsigned int size) { d_rings[name]=StatRing(size); d_rings[name].setHelp(help); } vector > StatBag::getRing(const string &name) { return d_rings[name].get(); } void StatRing::reset() { Lock l(d_lock); for(vector::iterator i=d_items.begin();i!=d_items.end();++i) { if(!i->empty()) *i=""; } } void StatBag::resetRing(const string &name) { d_rings[name].reset(); } void StatBag::resizeRing(const string &name, unsigned int newsize) { d_rings[name].resize(newsize); } unsigned int StatBag::getRingSize(const string &name) { return d_rings[name].getSize(); } string StatBag::getRingTitle(const string &name) { return d_rings[name].getHelp(); } vectorStatBag::listRings() { vector ret; for(map::const_iterator i=d_rings.begin();i!=d_rings.end();++i) ret.push_back(i->first); return ret; } pdns-3.3/pdns/ueberbackend.cc0000644000014601777760000003271512151412571017457 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include "packetcache.hh" #include "utility.hh" #ifdef HAVE_CONFIG_H # include "config.h" #endif // HAVE_CONFIG_H #include #include #include #include #include #include #include #include #include #include "dns.hh" #include "arguments.hh" #include "dnsbackend.hh" #include "ueberbackend.hh" #include "dnspacket.hh" #include "logger.hh" #include "statbag.hh" #include extern StatBag S; vectorUeberBackend::instances; pthread_mutex_t UeberBackend::instances_lock=PTHREAD_MUTEX_INITIALIZER; sem_t UeberBackend::d_dynserialize; string UeberBackend::s_status; // initially we are blocked bool UeberBackend::d_go=false; pthread_mutex_t UeberBackend::d_mut = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t UeberBackend::d_cond = PTHREAD_COND_INITIALIZER; int UeberBackend::s_s=-1; // ? #ifdef NEED_RTLD_NOW #define RTLD_NOW RTLD_LAZY #endif //! Loads a module and reports it to all UeberBackend threads bool UeberBackend::loadmodule(const string &name) { // TODO: Implement dynamic loading? #if !defined(WIN32) && !defined(DARWIN) void *dlib=dlopen(name.c_str(), RTLD_NOW); if(dlib == NULL) { L<::const_iterator i=backends.begin();i!=backends.end();++i) if((*i)->getDomainInfo(domain, di)) return true; return false; } int UeberBackend::addDomainKey(const string& name, const KeyData& key) { int ret; BOOST_FOREACH(DNSBackend* db, backends) { if((ret = db->addDomainKey(name, key)) >= 0) return ret; } return -1; } bool UeberBackend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->getDomainKeys(name, kind, keys)) return true; } return false; } bool UeberBackend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->getDomainMetadata(name, kind, meta)) return true; } return false; } bool UeberBackend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->setDomainMetadata(name, kind, meta)) return true; } return false; } bool UeberBackend::activateDomainKey(const string& name, unsigned int id) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->activateDomainKey(name, id)) return true; } return false; } bool UeberBackend::deactivateDomainKey(const string& name, unsigned int id) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->deactivateDomainKey(name, id)) return true; } return false; } bool UeberBackend::removeDomainKey(const string& name, unsigned int id) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->removeDomainKey(name, id)) return true; } return false; } bool UeberBackend::getTSIGKey(const string& name, string* algorithm, string* content) { BOOST_FOREACH(DNSBackend* db, backends) { if(db->getTSIGKey(name, algorithm, content)) return true; } return false; } void UeberBackend::reload() { for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) { ( *i )->reload(); } } void UeberBackend::rediscover(string *status) { for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) { string tmpstr; ( *i )->rediscover(&tmpstr); if(status) *status+=tmpstr + (i!=backends.begin() ? "\n" : ""); } } void UeberBackend::getUnfreshSlaveInfos(vector* domains) { for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) { ( *i )->getUnfreshSlaveInfos( domains ); } } void UeberBackend::getUpdatedMasters(vector* domains) { for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) { ( *i )->getUpdatedMasters( domains ); } } /** special trick - if sd.db is set to -1, the cache is ignored */ bool UeberBackend::getSOA(const string &domain, SOAData &sd, DNSPacket *p) { d_question.qtype=QType::SOA; d_question.qname=domain; d_question.zoneId=-1; if(sd.db!=(DNSBackend *)-1) { int cstat=cacheHas(d_question,d_answers); if(cstat==0) { // negative return false; } else if(cstat==1 && !d_answers.empty()) { fillSOAData(d_answers[0].content,sd); sd.domain_id=d_answers[0].domain_id; sd.ttl=d_answers[0].ttl; sd.db=0; return true; } } for(vector::const_iterator i=backends.begin();i!=backends.end();++i) if((*i)->getSOA(domain, sd, p)) { DNSResourceRecord rr; rr.qname=domain; rr.qtype=QType::SOA; rr.content=serializeSOAData(sd); rr.ttl=sd.ttl; rr.domain_id=sd.domain_id; vector rrs; rrs.push_back(rr); addCache(d_question, rrs); return true; } addNegCache(d_question); return false; } bool UeberBackend::superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db) { for(vector::const_iterator i=backends.begin();i!=backends.end();++i) if((*i)->superMasterBackend(ip,domain,nsset,account, db)) return true; return false; } void UeberBackend::setStatus(const string &st) { s_status=st; } UeberBackend::UeberBackend(const string &pname) { pthread_mutex_lock(&instances_lock); instances.push_back(this); // report to the static list of ourself pthread_mutex_unlock(&instances_lock); tid=pthread_self(); stale=false; backends=BackendMakers().all(pname=="key-only"); } void UeberBackend::die() { cleanup(); stale=true; } void del(DNSBackend* d) { delete d; } void UeberBackend::cleanup() { pthread_mutex_lock(&instances_lock); remove(instances.begin(),instances.end(),this); instances.resize(instances.size()-1); pthread_mutex_unlock(&instances_lock); for_each(backends.begin(),backends.end(),del); } // silly Solaris fix #undef PC // returns -1 for miss, 0 for negative match, 1 for hit int UeberBackend::cacheHas(const Question &q, vector &rrs) { extern PacketCache PC; static unsigned int *qcachehit=S.getPointer("query-cache-hit"); static unsigned int *qcachemiss=S.getPointer("query-cache-miss"); static int negqueryttl=::arg().asNum("negquery-cache-ttl"); static int queryttl=::arg().asNum("query-cache-ttl"); if(!negqueryttl && !queryttl) { (*qcachemiss)++; return -1; } string content; // L<> rrs; return 1; } void UeberBackend::addNegCache(const Question &q) { extern PacketCache PC; static int negqueryttl=::arg().asNum("negquery-cache-ttl"); if(!negqueryttl) return; // we should also not be storing negative answers if a pipebackend does scopeMask, but we can't pass a negative scopeMask in an empty set! PC.insert(q.qname, q.qtype, PacketCache::QUERYCACHE, "", negqueryttl, q.zoneId); } void UeberBackend::addCache(const Question &q, const vector &rrs) { extern PacketCache PC; static unsigned int queryttl=::arg().asNum("query-cache-ttl"); unsigned int cachettl; if(!queryttl) return; // L< *ips) { for ( vector< DNSBackend * >::iterator i = backends.begin(); i != backends.end(); ++i ) (*i)->alsoNotifies(domain,ips); } UeberBackend::~UeberBackend() { DLOG(L<lookup(qtype, qname,pkt_p,zoneId); } else if(cstat==0) { d_negcached=true; d_cached=false; d_answers.clear(); } else { d_negcached=false; d_cached=true; d_cachehandleiter = d_answers.begin(); } } d_handle.parent=this; } void UeberBackend::getAllDomains(vector *domains) { for (vector::iterator i = backends.begin(); i != backends.end(); ++i ) { (*i)->getAllDomains(domains); } } bool UeberBackend::get(DNSResourceRecord &rr) { if(d_negcached) { return false; } if(d_cached) { if(d_cachehandleiter != d_answers.end()) { rr=*d_cachehandleiter++;; return true; } return false; } if(!d_handle.get(rr)) { if(!d_ancount && !d_handle.qname.empty()) // don't cache axfr addNegCache(d_question); addCache(d_question, d_answers); d_answers.clear(); return false; } d_ancount++; d_answers.push_back(rr); return true; } bool UeberBackend::list(const string &target, int domain_id) { L<get(r))) { // this backend out of answers if(ibackends.size()) { DLOG(L<<"Backend #"<backends.size() <<" out of answers, taking next"<backends[i++]; d_hinterBackend->lookup(qtype,qname,pkt_p,parent->domain_id); } else break; DLOG(L<<"Now asking backend #"<backends.size()) { DLOG(L<<"UeberBackend reached end of backends"<backends.size(); // don't go on to the next backend return true; } pdns-3.3/pdns/recursor_cache.hh0000644000014601777760000000627112136555572020060 0ustar00jenkinsnogroup00000000000000#ifndef RECURSOR_CACHE_HH #define RECURSOR_CACHE_HH #include #include #include "dns.hh" #include "qtype.hh" #include "misc.hh" #include #include #undef L #include #include #include #include #include #include #undef max #define L theL() #include "namespaces.hh" using namespace ::boost::multi_index; class MemRecursorCache : public boost::noncopyable // : public RecursorCache { public: MemRecursorCache() : d_cachecachevalid(false) { cacheHits = cacheMisses = 0; } unsigned int size(); unsigned int bytes(); int get(time_t, const string &qname, const QType& qt, set* res); int getDirect(time_t now, const char* qname, const QType& qt, uint32_t ttd[10], char* data[10], uint16_t len[10]); void replace(time_t, const string &qname, const QType& qt, const set& content, bool auth); void doPrune(void); void doSlash(int perc); uint64_t doDump(int fd); uint64_t doDumpNSSpeeds(int fd); int doWipeCache(const string& name, uint16_t qtype=0xffff); bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL); uint64_t cacheHits, cacheMisses; private: struct StoredRecord { mutable uint32_t d_ttd; string d_string; bool operator<(const StoredRecord& rhs) const { return d_string < rhs.d_string; } unsigned int size() const { return sizeof(*this) + d_string.size(); } }; struct CacheEntry { CacheEntry(const tuple& key, const vector& records, bool auth) : d_qname(key.get<0>()), d_qtype(key.get<1>()), d_auth(auth), d_records(records) {} typedef vector records_t; uint32_t getTTD() const { if(d_records.size()==1) return d_records.begin()->d_ttd; uint32_t earliest=std::numeric_limits::max(); for(records_t::const_iterator i=d_records.begin(); i != d_records.end(); ++i) earliest=min(earliest, i->d_ttd); return earliest; } string d_qname; uint16_t d_qtype; bool d_auth; records_t d_records; }; typedef multi_index_container< CacheEntry, indexed_by < ordered_unique< composite_key< CacheEntry, member, member >, composite_key_compare > >, sequenced<> > > cache_t; cache_t d_cache; pair d_cachecache; string d_cachedqname; bool d_cachecachevalid; bool attemptToRefreshNSTTL(const QType& qt, const set& content, const CacheEntry& stored); }; string DNSRR2String(const DNSResourceRecord& rr); DNSResourceRecord String2DNSRR(const string& qname, const QType& qt, const string& serial, uint32_t ttd); #endif pdns-3.3/pdns/polarrsakeyinfra.cc0000644000014601777760000002654612136555572020442 0ustar00jenkinsnogroup00000000000000#ifdef HAVE_LIBPOLARSSLSSL #include #include #include #include #include #include #include #else #include "ext/polarssl-1.1.2/include/polarssl/rsa.h" #include "ext/polarssl-1.1.2/include/polarssl/base64.h" #include "ext/polarssl-1.1.2/include/polarssl/sha1.h" #include "ext/polarssl-1.1.2/include/polarssl/sha2.h" #include "ext/polarssl-1.1.2/include/polarssl/sha4.h" #include "ext/polarssl-1.1.2/include/polarssl/entropy.h" #include "ext/polarssl-1.1.2/include/polarssl/ctr_drbg.h" #endif #include // for 'operator+=()' #include #include "dnssecinfra.hh" using namespace boost::assign; #define PDNSSEC_MI(x) mpi_init(&d_context.x) #define PDNSSEC_MC(x) PDNSSEC_MI(x); mpi_copy(&d_context.x, const_cast(&orig.d_context.x)) #define PDNSSEC_MF(x) mpi_free(&d_context.x) class RSADNSCryptoKeyEngine : public DNSCryptoKeyEngine { public: string getName() const { return "PolarSSL RSA"; } explicit RSADNSCryptoKeyEngine(unsigned int algorithm) : DNSCryptoKeyEngine(algorithm) { memset(&d_context, 0, sizeof(d_context)); PDNSSEC_MI(N); PDNSSEC_MI(E); PDNSSEC_MI(D); PDNSSEC_MI(P); PDNSSEC_MI(Q); PDNSSEC_MI(DP); PDNSSEC_MI(DQ); PDNSSEC_MI(QP); PDNSSEC_MI(RN); PDNSSEC_MI(RP); PDNSSEC_MI(RQ); } ~RSADNSCryptoKeyEngine() { PDNSSEC_MF(N); PDNSSEC_MF(E); PDNSSEC_MF(D); PDNSSEC_MF(P); PDNSSEC_MF(Q); PDNSSEC_MF(DP); PDNSSEC_MF(DQ); PDNSSEC_MF(QP); PDNSSEC_MF(RN); PDNSSEC_MF(RP); PDNSSEC_MF(RQ); } bool operator<(const RSADNSCryptoKeyEngine& rhs) const { return tie(d_context.N, d_context.E, d_context.D, d_context.P, d_context.Q, d_context.DP, d_context.DQ, d_context.QP) < tie(rhs.d_context.N, rhs.d_context.E, rhs.d_context.D, rhs.d_context.P, rhs.d_context.Q, rhs.d_context.DP, rhs.d_context.DQ, rhs.d_context.QP); } RSADNSCryptoKeyEngine(const RSADNSCryptoKeyEngine& orig) : DNSCryptoKeyEngine(orig.d_algorithm) { // this part is a little bit scary.. we make a 'deep copy' of an RSA state, and polarssl isn't helping us so we delve into thr struct d_context.ver = orig.d_context.ver; d_context.len = orig.d_context.len; d_context.padding = orig.d_context.padding; d_context.hash_id = orig.d_context.hash_id; PDNSSEC_MC(N); PDNSSEC_MC(E); PDNSSEC_MC(D); PDNSSEC_MC(P); PDNSSEC_MC(Q); PDNSSEC_MC(DP); PDNSSEC_MC(DQ); PDNSSEC_MC(QP); PDNSSEC_MC(RN); PDNSSEC_MC(RP); PDNSSEC_MC(RQ); } RSADNSCryptoKeyEngine& operator=(const RSADNSCryptoKeyEngine& orig) { *this = RSADNSCryptoKeyEngine(orig); return *this; } const rsa_context& getConstContext() const { return d_context; } rsa_context& getContext() { return d_context; } void create(unsigned int bits); storvector_t convertToISCVector() const; std::string getPubKeyHash() const; std::string sign(const std::string& hash) const; std::string hash(const std::string& hash) const; bool verify(const std::string& hash, const std::string& signature) const; std::string getPublicKeyString() const; int getBits() const { return mpi_size(&d_context.N)*8; } void fromISCMap(DNSKEYRecordContent& drc, std::map& stormap); void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw); void fromPublicKeyString(const std::string& raw); static DNSCryptoKeyEngine* maker(unsigned int algorithm) { return new RSADNSCryptoKeyEngine(algorithm); } private: rsa_context d_context; }; // see above #undef PDNSSEC_MC #undef PDNSSEC_MI #undef PDNSSEC_MF inline bool operator<(const mpi& a, const mpi& b) { return mpi_cmp_mpi(&a, &b) < 0; } void RSADNSCryptoKeyEngine::create(unsigned int bits) { entropy_context entropy; ctr_drbg_context ctr_drbg; entropy_init( &entropy ); int ret=ctr_drbg_init( &ctr_drbg, entropy_func, &entropy, (unsigned char *) "PowerDNS", 8); if(ret < 0) throw runtime_error("Entropy gathering for key generation failed"); rsa_init(&d_context, RSA_PKCS_V15, 0); // FIXME this leaks memory (it does?) ret=rsa_gen_key(&d_context, ctr_drbg_random, &ctr_drbg, bits, 65537); if(ret < 0) throw runtime_error("Key generation failed"); } std::string RSADNSCryptoKeyEngine::getPubKeyHash() const { unsigned char hash[20]; unsigned char N[mpi_size(&d_context.N)]; mpi_write_binary(&d_context.N, N, sizeof(N)); unsigned char E[mpi_size(&d_context.E)]; mpi_write_binary(&d_context.E, E, sizeof(E)); sha1_context ctx; sha1_starts(&ctx); sha1_update(&ctx, N, sizeof(N)); sha1_update(&ctx, E, sizeof(E)); sha1_finish(&ctx, hash); return string((char*)hash, sizeof(hash)); } std::string RSADNSCryptoKeyEngine::sign(const std::string& msg) const { string hash = this->hash(msg); unsigned char signature[mpi_size(&d_context.N)]; int hashKind; if(hash.size()==20) hashKind= SIG_RSA_SHA1; else if(hash.size()==32) hashKind= SIG_RSA_SHA256; else hashKind = SIG_RSA_SHA512; int ret=rsa_pkcs1_sign(const_cast(&d_context), NULL, NULL, RSA_PRIVATE, hashKind, hash.size(), (const unsigned char*) hash.c_str(), signature); if(ret!=0) { cerr<<"signing returned: "<hash(msg); if(hash.size()==20) hashKind= SIG_RSA_SHA1; else if(hash.size()==32) hashKind= SIG_RSA_SHA256; else hashKind = SIG_RSA_SHA512; int ret=rsa_pkcs1_verify(const_cast(&d_context), RSA_PUBLIC, hashKind, hash.size(), (const unsigned char*) hash.c_str(), (unsigned char*) signature.c_str()); return ret==0; // 0 really IS ok ;-) } std::string RSADNSCryptoKeyEngine::hash(const std::string& toHash) const { if(d_algorithm <= 7 ) { // RSASHA1 unsigned char hash[20]; sha1((unsigned char*)toHash.c_str(), toHash.length(), hash); return string((char*)hash, sizeof(hash)); } else if(d_algorithm == 8) { // RSASHA256 unsigned char hash[32]; sha2((unsigned char*)toHash.c_str(), toHash.length(), hash, 0); return string((char*)hash, sizeof(hash)); } else if(d_algorithm == 10) { // RSASHA512 unsigned char hash[64]; sha4((unsigned char*)toHash.c_str(), toHash.length(), hash, 0); return string((char*)hash, sizeof(hash)); } throw runtime_error("PolarSSL hashing method can't hash algorithm "+lexical_cast(d_algorithm)); } DNSCryptoKeyEngine::storvector_t RSADNSCryptoKeyEngine::convertToISCVector() const { storvector_t storvect; typedef vector > outputs_t; outputs_t outputs; push_back(outputs)("Modulus", &d_context.N)("PublicExponent",&d_context.E) ("PrivateExponent",&d_context.D) ("Prime1",&d_context.P) ("Prime2",&d_context.Q) ("Exponent1",&d_context.DP) ("Exponent2",&d_context.DQ) ("Coefficient",&d_context.QP); string algorithm=lexical_cast(d_algorithm); switch(d_algorithm) { case 5: case 7 : algorithm+= " (RSASHA1)"; break; case 8: algorithm += " (RSASHA256)"; break; } storvect.push_back(make_pair("Algorithm", algorithm)); BOOST_FOREACH(outputs_t::value_type value, outputs) { unsigned char tmp[mpi_size(value.second)]; mpi_write_binary(value.second, tmp, sizeof(tmp)); storvect.push_back(make_pair(value.first, string((char*)tmp, sizeof(tmp)))); } return storvect; } void RSADNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::map& stormap) { string sline; string key,value; typedef map places_t; places_t places; rsa_init(&d_context, RSA_PKCS_V15, 0); places["Modulus"]=&d_context.N; places["PublicExponent"]=&d_context.E; places["PrivateExponent"]=&d_context.D; places["Prime1"]=&d_context.P; places["Prime2"]=&d_context.Q; places["Exponent1"]=&d_context.DP; places["Exponent2"]=&d_context.DQ; places["Coefficient"]=&d_context.QP; drc.d_algorithm = atoi(stormap["algorithm"].c_str()); string raw; BOOST_FOREACH(const places_t::value_type& val, places) { raw=stormap[toLower(val.first)]; mpi_read_binary(val.second, (unsigned char*) raw.c_str(), raw.length()); } d_context.len = ( mpi_msb( &d_context.N ) + 7 ) >> 3; // no clue what this does drc.d_key = this->getPublicKeyString(); drc.d_protocol=3; } void RSADNSCryptoKeyEngine::fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) { vector integers; decodeDERIntegerSequence(raw, integers); cerr<<"Got "< places; rsa_init(&d_context, RSA_PKCS_V15, 0); places[1]=&d_context.N; places[2]=&d_context.E; places[3]=&d_context.D; places[4]=&d_context.P; places[5]=&d_context.Q; places[6]=&d_context.DP; places[7]=&d_context.DQ; places[8]=&d_context.QP; string modulus, exponent; for(int n = 0; n < 9 ; ++n) { if(places.count(n)) { if(places[n]) { mpi_read_binary(places[n], (const unsigned char*)integers[n].c_str(), integers[n].length()); if(n==1) modulus=integers[n]; if(n==2) exponent=integers[n]; } } } d_context.len = ( mpi_msb( &d_context.N ) + 7 ) >> 3; // no clue what this does if(exponent.length() < 255) drc.d_key.assign(1, (char) (unsigned int) exponent.length()); else { drc.d_key.assign(1, 0); uint16_t len=htons(exponent.length()); drc.d_key.append((char*)&len, 2); } drc.d_key.append(exponent); drc.d_key.append(modulus); drc.d_protocol=3; } void RSADNSCryptoKeyEngine::fromPublicKeyString(const std::string& rawString) { rsa_init(&d_context, RSA_PKCS_V15, 0); string exponent, modulus; const unsigned char* raw = (const unsigned char*)rawString.c_str(); if(raw[0] != 0) { exponent=rawString.substr(1, raw[0]); modulus=rawString.substr(raw[0]+1); } else { exponent=rawString.substr(3, raw[1]*0xff + raw[2]); modulus = rawString.substr(3+ raw[1]*0xff + raw[2]); } mpi_read_binary(&d_context.E, (unsigned char*)exponent.c_str(), exponent.length()); mpi_read_binary(&d_context.N, (unsigned char*)modulus.c_str(), modulus.length()); d_context.len = ( mpi_msb( &d_context.N ) + 7 ) >> 3; // no clue what this does } string RSADNSCryptoKeyEngine::getPublicKeyString() const { string keystring; char tmp[std::max(mpi_size(&d_context.E), mpi_size(&d_context.N))]; mpi_write_binary(&d_context.E, (unsigned char*)tmp, mpi_size(&d_context.E) ); string exponent((char*)tmp, mpi_size(&d_context.E)); mpi_write_binary(&d_context.N, (unsigned char*)tmp, mpi_size(&d_context.N) ); string modulus((char*)tmp, mpi_size(&d_context.N)); if(exponent.length() < 255) keystring.assign(1, (char) (unsigned int) exponent.length()); else { keystring.assign(1, 0); uint16_t len=htons(exponent.length()); keystring.append((char*)&len, 2); } keystring.append(exponent); keystring.append(modulus); return keystring; } namespace { struct LoaderStruct { LoaderStruct() { DNSCryptoKeyEngine::report(5, &RSADNSCryptoKeyEngine::maker, true); DNSCryptoKeyEngine::report(7, &RSADNSCryptoKeyEngine::maker, true); DNSCryptoKeyEngine::report(8, &RSADNSCryptoKeyEngine::maker, true); DNSCryptoKeyEngine::report(10, &RSADNSCryptoKeyEngine::maker, true); } } loaderPolar; } pdns-3.3/pdns/dnslabeltext.cc0000644000014601777760000001225512165464054017543 0ustar00jenkinsnogroup00000000000000 #line 1 "dnslabeltext.rl" #include #include #include #include #include #include "namespaces.hh" namespace { void appendSplit(vector& ret, string& segment, char c) { if(segment.size()>254) { ret.push_back(segment); segment.clear(); } segment.append(1, c); } } vector segmentDNSText(const string& input ) { #line 26 "dnslabeltext.cc" static const char _dnstext_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 0, 1, 2, 4, 5 }; static const char _dnstext_key_offsets[] = { 0, 0, 1, 8, 10, 12, 14, 21, 25 }; static const char _dnstext_trans_keys[] = { 34, 34, 92, 127, 0, 8, 11, 31, 48, 57, 48, 57, 48, 57, 34, 92, 127, 0, 8, 11, 31, 32, 34, 9, 13, 34, 0 }; static const char _dnstext_single_lengths[] = { 0, 1, 3, 0, 0, 0, 3, 2, 1 }; static const char _dnstext_range_lengths[] = { 0, 0, 2, 1, 1, 1, 2, 1, 0 }; static const char _dnstext_index_offsets[] = { 0, 0, 2, 8, 10, 12, 14, 20, 24 }; static const char _dnstext_trans_targs[] = { 2, 0, 7, 3, 0, 0, 0, 2, 4, 2, 5, 0, 6, 0, 7, 3, 0, 0, 0, 2, 8, 2, 8, 0, 2, 0, 0 }; static const char _dnstext_trans_actions[] = { 3, 0, 0, 0, 0, 0, 0, 11, 7, 5, 7, 0, 7, 0, 9, 9, 0, 0, 0, 16, 0, 13, 0, 0, 13, 0, 0 }; static const char _dnstext_eof_actions[] = { 0, 0, 0, 0, 0, 0, 0, 1, 1 }; static const int dnstext_start = 1; static const int dnstext_first_final = 7; static const int dnstext_error = 0; static const int dnstext_en_main = 1; #line 25 "dnslabeltext.rl" (void)dnstext_error; // silence warnings (void)dnstext_en_main; const char *p = input.c_str(), *pe = input.c_str() + input.length(); const char* eof = pe; int cs; char val = 0; string segment; vector ret; #line 99 "dnslabeltext.cc" { cs = dnstext_start; } #line 104 "dnslabeltext.cc" { int _klen; unsigned int _trans; const char *_acts; unsigned int _nacts; const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: _keys = _dnstext_trans_keys + _dnstext_key_offsets[cs]; _trans = _dnstext_index_offsets[cs]; _klen = _dnstext_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + _klen - 1; while (1) { if ( _upper < _lower ) break; _mid = _lower + ((_upper-_lower) >> 1); if ( (*p) < *_mid ) _upper = _mid - 1; else if ( (*p) > *_mid ) _lower = _mid + 1; else { _trans += (_mid - _keys); goto _match; } } _keys += _klen; _trans += _klen; } _klen = _dnstext_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + (_klen<<1) - 2; while (1) { if ( _upper < _lower ) break; _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( (*p) < _mid[0] ) _upper = _mid - 2; else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { _trans += ((_mid - _keys)>>1); goto _match; } } _trans += _klen; } _match: cs = _dnstext_trans_targs[_trans]; if ( _dnstext_trans_actions[_trans] == 0 ) goto _again; _acts = _dnstext_actions + _dnstext_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: #line 37 "dnslabeltext.rl" { ret.push_back(segment); segment.clear(); } break; case 1: #line 41 "dnslabeltext.rl" { segment.clear(); } break; case 2: #line 45 "dnslabeltext.rl" { char c = *p; appendSplit(ret, segment, c); } break; case 3: #line 49 "dnslabeltext.rl" { char c = *p; val *= 10; val += c-'0'; } break; case 4: #line 55 "dnslabeltext.rl" { appendSplit(ret, segment, val); val=0; } break; case 5: #line 60 "dnslabeltext.rl" { appendSplit(ret, segment, *(p)); } break; #line 219 "dnslabeltext.cc" } } _again: if ( cs == 0 ) goto _out; if ( ++p != pe ) goto _resume; _test_eof: {} if ( p == eof ) { const char *__acts = _dnstext_actions + _dnstext_eof_actions[cs]; unsigned int __nacts = (unsigned int) *__acts++; while ( __nacts-- > 0 ) { switch ( *__acts++ ) { case 0: #line 37 "dnslabeltext.rl" { ret.push_back(segment); segment.clear(); } break; #line 242 "dnslabeltext.cc" } } } _out: {} } #line 73 "dnslabeltext.rl" if ( cs < dnstext_first_final ) { throw runtime_error("Unable to parse DNS TXT '"+input+"'"); } return ret; }; #if 0 int main() { //char blah[]="\"blah\" \"bleh\" \"bloeh\\\"bleh\" \"\\97enzo\""; char blah[]="\"v=spf1 ip4:67.106.74.128/25 ip4:63.138.42.224/28 ip4:65.204.46.224/27 \\013\\010ip4:66.104.217.176/28 \\013\\010ip4:209.48.147.0/27 ~all\""; //char blah[]="\"abc \\097\\098 def\""; printf("Input: '%s'\n", blah); vector res=dnstext(blah); cerr< #include #include #include #include #include #include #include // for 'operator+=()' #include #include "base64.hh" #include "cachecleaner.hh" #include "arguments.hh" using namespace boost::assign; #include "namespaces.hh" DNSSECKeeper::keycache_t DNSSECKeeper::s_keycache; DNSSECKeeper::metacache_t DNSSECKeeper::s_metacache; pthread_rwlock_t DNSSECKeeper::s_metacachelock = PTHREAD_RWLOCK_INITIALIZER; pthread_rwlock_t DNSSECKeeper::s_keycachelock = PTHREAD_RWLOCK_INITIALIZER; AtomicCounter DNSSECKeeper::s_ops; time_t DNSSECKeeper::s_last_prune; bool DNSSECKeeper::isSecuredZone(const std::string& zone) { if(isPresigned(zone)) return true; if(!((++s_ops) % 100000)) { cleanup(); } { ReadLock l(&s_keycachelock); keycache_t::const_iterator iter = s_keycache.find(zone); if(iter != s_keycache.end() && iter->d_ttd > (unsigned int)time(0)) { if(iter->d_keys.empty()) return false; else return true; } else ; } keyset_t keys = getKeys(zone, true); // does the cache BOOST_FOREACH(keyset_t::value_type& val, keys) { if(val.second.active) { return true; } } return false; } bool DNSSECKeeper::isPresigned(const std::string& name) { string meta; getFromMeta(name, "PRESIGNED", meta); return meta=="1"; } bool DNSSECKeeper::addKey(const std::string& name, bool keyOrZone, int algorithm, int bits, bool active) { if(!bits) { if(algorithm <= 10) bits = keyOrZone ? 2048 : 1024; else { if(algorithm == 12 || algorithm == 13 || algorithm == 250) // ECDSA, GOST, ED25519 bits = 256; else if(algorithm == 14) bits = 384; else { throw runtime_error("Can't guess key size for algoritm "+lexical_cast(algorithm)); } } } DNSSECPrivateKey dspk; shared_ptr dpk(DNSCryptoKeyEngine::make(algorithm)); // defaults to RSA for now, could be smart w/algorithm! XXX FIXME dpk->create(bits); dspk.setKey(dpk); dspk.d_algorithm = algorithm; dspk.d_flags = keyOrZone ? 257 : 256; return addKey(name, dspk, active); } void DNSSECKeeper::clearAllCaches() { { WriteLock l(&s_keycachelock); s_keycache.clear(); } WriteLock l(&s_metacachelock); s_metacache.clear(); } void DNSSECKeeper::clearCaches(const std::string& name) { { WriteLock l(&s_keycachelock); s_keycache.erase(name); } WriteLock l(&s_metacachelock); pair range = s_metacache.equal_range(name); while(range.first != range.second) s_metacache.erase(range.first++); } bool DNSSECKeeper::addKey(const std::string& name, const DNSSECPrivateKey& dpk, bool active) { clearCaches(name); DNSBackend::KeyData kd; kd.flags = dpk.d_flags; // the dpk doesn't get stored, only they key part kd.active = active; kd.content = dpk.getKey()->convertToISC(); // now store it return d_keymetadb->addDomainKey(name, kd) >= 0; // >= 0 == s } static bool keyCompareByKindAndID(const DNSSECKeeper::keyset_t::value_type& a, const DNSSECKeeper::keyset_t::value_type& b) { return make_pair(!a.second.keyOrZone, a.second.id) < make_pair(!b.second.keyOrZone, b.second.id); } DNSSECPrivateKey DNSSECKeeper::getKeyById(const std::string& zname, unsigned int id) { vector keys; d_keymetadb->getDomainKeys(zname, 0, keys); BOOST_FOREACH(const DNSBackend::KeyData& kd, keys) { if(kd.id != id) continue; DNSSECPrivateKey dpk; DNSKEYRecordContent dkrc; dpk.setKey(shared_ptr(DNSCryptoKeyEngine::makeFromISCString(dkrc, kd.content))); dpk.d_flags = kd.flags; dpk.d_algorithm = dkrc.d_algorithm; if(dpk.d_algorithm == 5 && getNSEC3PARAM(zname)) { dpk.d_algorithm += 2; } return dpk; } throw runtime_error("Can't find a key with id "+lexical_cast(id)+" for zone '"+zname+"'"); } bool DNSSECKeeper::removeKey(const std::string& zname, unsigned int id) { clearCaches(zname); return d_keymetadb->removeDomainKey(zname, id); } bool DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id) { clearCaches(zname); return d_keymetadb->deactivateDomainKey(zname, id); } bool DNSSECKeeper::activateKey(const std::string& zname, unsigned int id) { clearCaches(zname); return d_keymetadb->activateDomainKey(zname, id); } void DNSSECKeeper::getFromMeta(const std::string& zname, const std::string& key, std::string& value) { value.clear(); unsigned int now = time(0); if(!((++s_ops) % 100000)) { cleanup(); } { ReadLock l(&s_metacachelock); metacache_t::const_iterator iter = s_metacache.find(tie(zname, key)); if(iter != s_metacache.end() && iter->d_ttd > now) { value = iter->d_value; return; } } vector meta; d_keymetadb->getDomainMetadata(zname, key, meta); if(!meta.empty()) value=*meta.begin(); METACacheEntry nce; nce.d_domain=zname; nce.d_ttd = now+60; nce.d_key= key; nce.d_value = value; { WriteLock l(&s_metacachelock); replacing_insert(s_metacache, nce); } } bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow) { string value; getFromMeta(zname, "NSEC3PARAM", value); if(value.empty()) { // "no NSEC3" return false; } if(ns3p) { NSEC3PARAMRecordContent* tmp=dynamic_cast(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value)); *ns3p = *tmp; delete tmp; } if(narrow) { getFromMeta(zname, "NSEC3NARROW", value); *narrow = (value=="1"); } return true; } bool DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow) { clearCaches(zname); string descr = ns3p.getZoneRepresentation(); vector meta; meta.push_back(descr); if (d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", meta)) { meta.clear(); if(narrow) meta.push_back("1"); return d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", meta); } return false; } bool DNSSECKeeper::unsetNSEC3PARAM(const std::string& zname) { clearCaches(zname); return (d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", vector()) && d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", vector())); } bool DNSSECKeeper::setPresigned(const std::string& zname) { clearCaches(zname); vector meta; meta.push_back("1"); return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", meta); } bool DNSSECKeeper::unsetPresigned(const std::string& zname) { clearCaches(zname); return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", vector()); } DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const std::string& zone, boost::tribool allOrKeyOrZone) { unsigned int now = time(0); if(!((++s_ops) % 100000)) { cleanup(); } { ReadLock l(&s_keycachelock); keycache_t::const_iterator iter = s_keycache.find(zone); if(iter != s_keycache.end() && iter->d_ttd > now) { keyset_t ret; BOOST_FOREACH(const keyset_t::value_type& value, iter->d_keys) { if(boost::indeterminate(allOrKeyOrZone) || allOrKeyOrZone == value.second.keyOrZone) ret.push_back(value); } return ret; } } keyset_t retkeyset, allkeyset; vector dbkeyset; d_keymetadb->getDomainKeys(zone, 0, dbkeyset); BOOST_FOREACH(UeberBackend::KeyData& kd, dbkeyset) { DNSSECPrivateKey dpk; DNSKEYRecordContent dkrc; dpk.setKey(shared_ptr(DNSCryptoKeyEngine::makeFromISCString(dkrc, kd.content))); dpk.d_flags = kd.flags; dpk.d_algorithm = dkrc.d_algorithm; if(dpk.d_algorithm == 5 && getNSEC3PARAM(zone)) dpk.d_algorithm+=2; KeyMetaData kmd; kmd.active = kd.active; kmd.keyOrZone = (kd.flags == 257); kmd.id = kd.id; if(boost::indeterminate(allOrKeyOrZone) || allOrKeyOrZone == kmd.keyOrZone) retkeyset.push_back(make_pair(dpk, kmd)); allkeyset.push_back(make_pair(dpk, kmd)); } sort(retkeyset.begin(), retkeyset.end(), keyCompareByKindAndID); sort(allkeyset.begin(), allkeyset.end(), keyCompareByKindAndID); KeyCacheEntry kce; kce.d_domain=zone; kce.d_keys = allkeyset; kce.d_ttd = now + 30; { WriteLock l(&s_keycachelock); replacing_insert(s_keycache, kce); } return retkeyset; } bool DNSSECKeeper::secureZone(const std::string& name, int algorithm, int size) { clearCaches(name); // just to be sure ;) return addKey(name, true, algorithm, size); } bool DNSSECKeeper::getPreRRSIGs(DNSBackend& db, const std::string& signer, const std::string& qname, const std::string& wildcardname, const QType& qtype, DNSPacketWriter::Place signPlace, vector& rrsigs, uint32_t signTTL) { // cerr<<"Doing DB lookup for precomputed RRSIGs for '"<<(wildcardname.empty() ? qname : wildcardname)<<"'"< parts; stringtok(parts, rr.content); if(parts[0] == qtype.getName() && pdns_iequals(parts[7], signer+".")) { // cerr<<"Got it"< allowed; d_keymetadb->getDomainMetadata(zone, "TSIG-ALLOW-AXFR", allowed); BOOST_FOREACH(const string& dbkey, allowed) { if(pdns_iequals(dbkey, keyname)) return true; } return false; } bool DNSSECKeeper::getTSIGForAccess(const string& zone, const string& master, string* keyname) { vector keynames; d_keymetadb->getDomainMetadata(zone, "AXFR-MASTER-TSIG", keynames); keyname->clear(); // XXX FIXME this should check for a specific master! BOOST_FOREACH(const string& dbkey, keynames) { *keyname=dbkey; return true; } return false; } void DNSSECKeeper::cleanup() { struct timeval now; Utility::gettimeofday(&now, 0); if(now.tv_sec - s_last_prune > (time_t)(30)) { { WriteLock l(&s_metacachelock); pruneCollection(s_metacache, ::arg().asNum("max-cache-entries")); } { WriteLock l(&s_keycachelock); pruneCollection(s_keycache, ::arg().asNum("max-cache-entries")); } s_last_prune=time(0); } } pdns-3.3/pdns/dnsrecords.cc0000644000014601777760000003240712156577120017220 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2009 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include "dnsrecords.hh" #include boilerplate_conv(A, ns_t_a, conv.xfrIP(d_ip)); ARecordContent::ARecordContent(uint32_t ip) : DNSRecordContent(ns_t_a) { d_ip = ip; } uint32_t ARecordContent::getIP() const { return d_ip; } void ARecordContent::doRecordCheck(const DNSRecord& dr) { if(dr.d_clen!=4) throw MOADNSException("Wrong size for A record ("+lexical_cast(dr.d_clen)+")"); } boilerplate_conv(AAAA, ns_t_aaaa, conv.xfrIP6(d_ip6); ); boilerplate_conv(NS, ns_t_ns, conv.xfrLabel(d_content, true)); boilerplate_conv(PTR, ns_t_ptr, conv.xfrLabel(d_content, true)); boilerplate_conv(CNAME, ns_t_cname, conv.xfrLabel(d_content, true)); boilerplate_conv(MR, ns_t_mr, conv.xfrLabel(d_alias, true)); boilerplate_conv(MINFO, ns_t_minfo, conv.xfrLabel(d_rmailbx, true); conv.xfrLabel(d_emailbx, true)); boilerplate_conv(TXT, ns_t_txt, conv.xfrText(d_text, true)); boilerplate_conv(SPF, 99, conv.xfrText(d_text, true)); boilerplate_conv(HINFO, ns_t_hinfo, conv.xfrText(d_cpu); conv.xfrText(d_host)); boilerplate_conv(RP, ns_t_rp, conv.xfrLabel(d_mbox); conv.xfrLabel(d_info) ); boilerplate_conv(OPT, ns_t_opt, conv.xfrBlob(d_data) ); void OPTRecordContent::getData(vector >& options) { string::size_type pos=0; uint16_t code, len; while(d_data.size() >= 4 + pos) { code = 256 * (unsigned char)d_data[pos] + (unsigned char)d_data[pos+1]; len = 256 * (unsigned char)d_data[pos+2] + (unsigned char)d_data[pos+3]; pos+=4; if(pos + len > d_data.size()) break; string field(d_data.c_str() + pos, len); pos+=len; options.push_back(make_pair(code, field)); } } boilerplate_conv(TSIG, ns_t_tsig, conv.xfrLabel(d_algoName); conv.xfr48BitInt(d_time); conv.xfr16BitInt(d_fudge); uint16_t size=d_mac.size(); conv.xfr16BitInt(size); conv.xfrBlob(d_mac, size); conv.xfr16BitInt(d_origID); conv.xfr16BitInt(d_eRcode); size=d_otherData.size(); conv.xfr16BitInt(size); if (size>0) conv.xfrBlob(d_otherData, size); ); MXRecordContent::MXRecordContent(uint16_t preference, const string& mxname) : DNSRecordContent(ns_t_mx), d_preference(preference), d_mxname(mxname) { } boilerplate_conv(MX, ns_t_mx, conv.xfr16BitInt(d_preference); conv.xfrLabel(d_mxname, true); ) boilerplate_conv(KX, ns_t_kx, conv.xfr16BitInt(d_preference); conv.xfrLabel(d_exchanger, false); ) boilerplate_conv(IPSECKEY, ns_t_ipseckey, conv.xfr8BitInt(d_preference); conv.xfr8BitInt(d_gatewaytype); conv.xfr8BitInt(d_algorithm); // now we need to determine values switch(d_gatewaytype) { case 0: // NO KEY break; case 1: // IPv4 GW conv.xfrIP(d_ip4); break; case 2: // IPv6 GW conv.xfrIP6(d_ip6); break; case 3: // DNS label conv.xfrLabel(d_gateway, false); break; default: throw MOADNSException("Parsing record content: invalid gateway type"); }; switch(d_algorithm) { case 0: break; case 1: case 2: conv.xfrBlob(d_publickey); break; default: throw MOADNSException("Parsing record content: invalid algorithm type"); } ) boilerplate_conv(DHCID, 49, conv.xfrBlob(d_content); ) boilerplate_conv(AFSDB, ns_t_afsdb, conv.xfr16BitInt(d_subtype); conv.xfrLabel(d_hostname); ) boilerplate_conv(NAPTR, ns_t_naptr, conv.xfr16BitInt(d_order); conv.xfr16BitInt(d_preference); conv.xfrText(d_flags); conv.xfrText(d_services); conv.xfrText(d_regexp); conv.xfrLabel(d_replacement); ) SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target) : DNSRecordContent(ns_t_srv), d_preference(preference), d_weight(weight), d_port(port), d_target(target) {} boilerplate_conv(SRV, ns_t_srv, conv.xfr16BitInt(d_preference); conv.xfr16BitInt(d_weight); conv.xfr16BitInt(d_port); conv.xfrLabel(d_target); ) SOARecordContent::SOARecordContent(const string& mname, const string& rname, const struct soatimes& st) : DNSRecordContent(ns_t_soa), d_mname(mname), d_rname(rname) { d_st=st; } boilerplate_conv(SOA, ns_t_soa, conv.xfrLabel(d_mname, true); conv.xfrLabel(d_rname, true); conv.xfr32BitInt(d_st.serial); conv.xfr32BitInt(d_st.refresh); conv.xfr32BitInt(d_st.retry); conv.xfr32BitInt(d_st.expire); conv.xfr32BitInt(d_st.minimum); ); #undef KEY boilerplate_conv(KEY, ns_t_key, conv.xfr16BitInt(d_flags); conv.xfr8BitInt(d_protocol); conv.xfr8BitInt(d_algorithm); conv.xfrBlob(d_certificate); ); boilerplate_conv(CERT, 37, conv.xfr16BitInt(d_type); if (d_type == 0) throw MOADNSException("CERT type 0 is reserved"); conv.xfr16BitInt(d_tag); conv.xfr8BitInt(d_algorithm); conv.xfrBlob(d_certificate); ) boilerplate_conv(TLSA, 52, conv.xfr8BitInt(d_certusage); conv.xfr8BitInt(d_selector); conv.xfr8BitInt(d_matchtype); conv.xfrHexBlob(d_cert, true); ) #undef DS DSRecordContent::DSRecordContent() : DNSRecordContent(43) {} boilerplate_conv(DS, 43, conv.xfr16BitInt(d_tag); conv.xfr8BitInt(d_algorithm); conv.xfr8BitInt(d_digesttype); conv.xfrHexBlob(d_digest, true); // keep reading across spaces ) DLVRecordContent::DLVRecordContent() : DNSRecordContent(32769) {} boilerplate_conv(DLV,32769 , conv.xfr16BitInt(d_tag); conv.xfr8BitInt(d_algorithm); conv.xfr8BitInt(d_digesttype); conv.xfrHexBlob(d_digest, true); // keep reading across spaces ) boilerplate_conv(SSHFP, 44, conv.xfr8BitInt(d_algorithm); conv.xfr8BitInt(d_fptype); conv.xfrHexBlob(d_fingerprint); ) boilerplate_conv(RRSIG, 46, conv.xfrType(d_type); conv.xfr8BitInt(d_algorithm); conv.xfr8BitInt(d_labels); conv.xfr32BitInt(d_originalttl); conv.xfrTime(d_sigexpire); conv.xfrTime(d_siginception); conv.xfr16BitInt(d_tag); conv.xfrLabel(d_signer); conv.xfrBlob(d_signature); ) RRSIGRecordContent::RRSIGRecordContent() : DNSRecordContent(46) {} boilerplate_conv(DNSKEY, 48, conv.xfr16BitInt(d_flags); conv.xfr8BitInt(d_protocol); conv.xfr8BitInt(d_algorithm); conv.xfrBlob(d_key); ) DNSKEYRecordContent::DNSKEYRecordContent() : DNSRecordContent(48) {} boilerplate_conv(RKEY, 57, conv.xfr16BitInt(d_flags); conv.xfr8BitInt(d_protocol); conv.xfrBlob(d_key); ) RKEYRecordContent::RKEYRecordContent() : DNSRecordContent(57) {} /* EUI48 start */ void EUI48RecordContent::report(void) { regist(1, ns_t_eui48, &make, &make, "EUI48"); } DNSRecordContent* EUI48RecordContent::make(const DNSRecord &dr, PacketReader& pr) { if(dr.d_clen!=6) throw MOADNSException("Wrong size for EUI48 record"); EUI48RecordContent* ret=new EUI48RecordContent(); pr.copyRecord((uint8_t*) &ret->d_eui48, 6); return ret; } DNSRecordContent* EUI48RecordContent::make(const string& zone) { // try to parse EUI48RecordContent *ret=new EUI48RecordContent(); // format is 6 hex bytes and dashes if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", ret->d_eui48, ret->d_eui48+1, ret->d_eui48+2, ret->d_eui48+3, ret->d_eui48+4, ret->d_eui48+5) != 6) { throw MOADNSException("Asked to encode '"+zone+"' as an EUI48 address, but does not parse"); } return ret; } void EUI48RecordContent::toPacket(DNSPacketWriter& pw) { string blob(d_eui48, d_eui48+6); pw.xfrBlob(blob); } string EUI48RecordContent::getZoneRepresentation() const { char tmp[18]; snprintf(tmp,18,"%02x-%02x-%02x-%02x-%02x-%02x", d_eui48[0], d_eui48[1], d_eui48[2], d_eui48[3], d_eui48[4], d_eui48[5]); return tmp; } /* EUI48 end */ /* EUI64 start */ void EUI64RecordContent::report(void) { regist(1, ns_t_eui64, &make, &make, "EUI64"); } DNSRecordContent* EUI64RecordContent::make(const DNSRecord &dr, PacketReader& pr) { if(dr.d_clen!=8) throw MOADNSException("Wrong size for EUI64 record"); EUI64RecordContent* ret=new EUI64RecordContent(); pr.copyRecord((uint8_t*) &ret->d_eui64, 8); return ret; } DNSRecordContent* EUI64RecordContent::make(const string& zone) { // try to parse EUI64RecordContent *ret=new EUI64RecordContent(); // format is 8 hex bytes and dashes if (sscanf(zone.c_str(), "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx", ret->d_eui64, ret->d_eui64+1, ret->d_eui64+2, ret->d_eui64+3, ret->d_eui64+4, ret->d_eui64+5, ret->d_eui64+6, ret->d_eui64+7) != 8) { throw MOADNSException("Asked to encode '"+zone+"' as an EUI64 address, but does not parse"); } return ret; } void EUI64RecordContent::toPacket(DNSPacketWriter& pw) { string blob(d_eui64, d_eui64+8); pw.xfrBlob(blob); } string EUI64RecordContent::getZoneRepresentation() const { char tmp[24]; snprintf(tmp,24,"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", d_eui64[0], d_eui64[1], d_eui64[2], d_eui64[3], d_eui64[4], d_eui64[5], d_eui64[6], d_eui64[7]); return tmp; } /* EUI64 end */ uint16_t DNSKEYRecordContent::getTag() { string data=this->serialize(""); const unsigned char* key=(const unsigned char*)data.c_str(); unsigned int keysize=data.length(); unsigned long ac; /* assumed to be 32 bits or larger */ unsigned int i; /* loop index */ for ( ac = 0, i = 0; i < keysize; ++i ) ac += (i & 1) ? key[i] : key[i] << 8; ac += (ac >> 16) & 0xFFFF; return ac & 0xFFFF; } // "fancy records" boilerplate_conv(URL, QType::URL, conv.xfrLabel(d_url); ) boilerplate_conv(MBOXFW, QType::MBOXFW, conv.xfrLabel(d_mboxfw); ) bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo) { if(mdp.d_header.arcount && !mdp.d_answers.empty()) { BOOST_FOREACH(const MOADNSParser::answers_t::value_type& val, mdp.d_answers) { if(val.first.d_place == DNSRecord::Additional && val.first.d_type == QType::OPT) { eo->d_packetsize=val.first.d_class; EDNS0Record stuff; uint32_t ttl=ntohl(val.first.d_ttl); memcpy(&stuff, &ttl, sizeof(stuff)); eo->d_extRCode=stuff.extRCode; eo->d_version=stuff.version; eo->d_Z = ntohs(stuff.Z); OPTRecordContent* orc = dynamic_cast(val.first.d_content.get()); if(!orc) return false; orc->getData(eo->d_options); return true; } } } return false; } void reportBasicTypes() { ARecordContent::report(); AAAARecordContent::report(); NSRecordContent::report(); CNAMERecordContent::report(); MXRecordContent::report(); SOARecordContent::report(); SRVRecordContent::report(); PTRRecordContent::report(); //DNSRecordContent::regist(3, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT"); TXTRecordContent::report(); DNSRecordContent::regist(1, QType::ANY, 0, 0, "ANY"); } void reportOtherTypes() { AFSDBRecordContent::report(); SPFRecordContent::report(); NAPTRRecordContent::report(); LOCRecordContent::report(); HINFORecordContent::report(); RPRecordContent::report(); KEYRecordContent::report(); DNSKEYRecordContent::report(); RKEYRecordContent::report(); RRSIGRecordContent::report(); DSRecordContent::report(); SSHFPRecordContent::report(); CERTRecordContent::report(); NSECRecordContent::report(); NSEC3RecordContent::report(); NSEC3PARAMRecordContent::report(); TLSARecordContent::report(); DLVRecordContent::report(); DNSRecordContent::regist(0xff, QType::TSIG, &TSIGRecordContent::make, &TSIGRecordContent::make, "TSIG"); //TSIGRecordContent::report(); OPTRecordContent::report(); EUI48RecordContent::report(); EUI64RecordContent::report(); MINFORecordContent::report(); } void reportFancyTypes() { URLRecordContent::report(); MBOXFWRecordContent::report(); } void reportAllTypes() { reportBasicTypes(); reportOtherTypes(); } #if 0 static struct Reporter { Reporter() { reportAllTypes(); } } reporter __attribute__((init_priority(65535))); #endif pdns-3.3/pdns/lua-recursor.cc0000644000014601777760000001406312145413600017461 0ustar00jenkinsnogroup00000000000000#include "lua-recursor.hh" #include "config.h" // to avoid including all of syncres.hh int directResolve(const std::string& qname, const QType& qtype, int qclass, vector& ret); #if !defined(HAVE_LUA) RecursorLua::RecursorLua(const std::string &fname) : PowerDNSLua(fname) { // empty } bool RecursorLua::nxdomain(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return false; } bool RecursorLua::nodata(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return false; } bool RecursorLua::postresolve(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return false; } bool RecursorLua::preresolve(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return false; } #else extern "C" { #undef L /* Include the Lua API header files. */ #include #include #include } #include #include #include #include #include #include #include "logger.hh" #include "namespaces.hh" RecursorLua::RecursorLua(const std::string &fname) : PowerDNSLua(fname) { // empty } int getFakeAAAARecords(const std::string& qname, const std::string& prefix, vector& ret) { int rcode=directResolve(qname, QType(QType::A), 1, ret); ComboAddress prefixAddress(prefix); BOOST_FOREACH(DNSResourceRecord& rr, ret) { if(rr.qtype.getCode() == QType::A && rr.d_place==DNSResourceRecord::ANSWER) { ComboAddress ipv4(rr.content); uint32_t tmp; memcpy((void*)&tmp, &ipv4.sin4.sin_addr.s_addr, 4); // tmp=htonl(tmp); memcpy(((char*)&prefixAddress.sin6.sin6_addr.s6_addr)+12, &tmp, 4); rr.content = prefixAddress.toString(); rr.qtype = QType(QType::AAAA); } } return rcode; } int getFakePTRRecords(const std::string& qname, const std::string& prefix, vector& ret) { /* qname has a reverse ordered IPv6 address, need to extract the underlying IPv4 address from it and turn it into an IPv4 in-addr.arpa query */ ret.clear(); vector parts; stringtok(parts, qname, "."); if(parts.size() < 8) return -1; string newquery; for(int n = 0; n < 4; ++n) { newquery += lexical_cast(strtol(parts[n*2].c_str(), 0, 16) + 16*strtol(parts[n*2+1].c_str(), 0, 16)); newquery.append(1,'.'); } newquery += "in-addr.arpa."; int rcode = directResolve(newquery, QType(QType::PTR), 1, ret); BOOST_FOREACH(DNSResourceRecord& rr, ret) { if(rr.qtype.getCode() == QType::PTR && rr.d_place==DNSResourceRecord::ANSWER) { rr.qname = qname; } } return rcode; } bool RecursorLua::nxdomain(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return passthrough("nxdomain", remote, local, query, qtype, ret, res, variable); } bool RecursorLua::preresolve(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return passthrough("preresolve", remote, local, query, qtype, ret, res, variable); } bool RecursorLua::nodata(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return passthrough("nodata", remote, local, query, qtype, ret, res, variable); } bool RecursorLua::postresolve(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { return passthrough("postresolve", remote, local, query, qtype, ret, res, variable); } bool RecursorLua::passthrough(const string& func, const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector& ret, int& res, bool* variable) { d_variable = false; lua_getglobal(d_lua, func.c_str()); if(!lua_isfunction(d_lua, -1)) { // cerr<<"No such function '"< #include DNSPacketWriter::DNSPacketWriter(vector& content, const string& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) : d_pos(0), d_content(content), d_qname(qname), d_qtype(qtype), d_qclass(qclass), d_canonic(false), d_lowerCase(false) { d_content.clear(); dnsheader dnsheader; memset(&dnsheader, 0, sizeof(dnsheader)); dnsheader.id=0; dnsheader.qdcount=htons(1); dnsheader.opcode=opcode; const uint8_t* ptr=(const uint8_t*)&dnsheader; uint32_t len=d_content.size(); d_content.resize(len + sizeof(dnsheader)); uint8_t* dptr=(&*d_content.begin()) + len; memcpy(dptr, ptr, sizeof(dnsheader)); d_stuff=0; xfrLabel(qname, false); len=d_content.size(); d_content.resize(len + d_record.size() + 4); ptr=&*d_record.begin(); dptr=(&*d_content.begin()) + len; memcpy(dptr, ptr, d_record.size()); len+=d_record.size(); d_record.clear(); qtype=htons(qtype); qclass=htons(qclass); vector::iterator i=d_content.begin()+len; // this works around a gcc 3.4 bug memcpy(&*i, &qtype, 2); i+=2; memcpy(&*i, &qclass, 2); d_stuff=0xffff; d_labelmap.reserve(16); } dnsheader* DNSPacketWriter::getHeader() { return (dnsheader*)&*d_content.begin(); } void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place) { if(!d_record.empty()) commit(); d_recordqname=name; d_recordqtype=qtype; d_recordqclass=qclass; d_recordttl=ttl; d_recordplace=place; d_stuff = 0; d_rollbackmarker=d_content.size(); if(pdns_iequals(d_qname, d_recordqname)) { // don't do the whole label compression thing if we *know* we can get away with "see question" static unsigned char marker[2]={0xc0, 0x0c}; d_content.insert(d_content.end(), (const char *) &marker[0], (const char *) &marker[2]); } else { xfrLabel(d_recordqname, true); d_content.insert(d_content.end(), d_record.begin(), d_record.end()); d_record.clear(); } d_stuff = sizeof(dnsrecordheader); // this is needed to get compressed label offsets right, the dnsrecordheader will be interspersed d_sor=d_content.size() + d_stuff; // start of real record } void DNSPacketWriter::addOpt(int udpsize, int extRCode, int Z, const vector >& options) { uint32_t ttl=0; EDNS0Record stuff; stuff.extRCode=extRCode; stuff.version=0; stuff.Z=htons(Z); memcpy(&ttl, &stuff, sizeof(stuff)); ttl=ntohl(ttl); // will be reversed later on startRecord("", ns_t_opt, ttl, udpsize, ADDITIONAL); for(optvect_t::const_iterator iter = options.begin(); iter != options.end(); ++iter) { xfr16BitInt(iter->first); xfr16BitInt(iter->second.length()); xfrBlob(iter->second); } } void DNSPacketWriter::xfr48BitInt(uint64_t val) { unsigned char bytes[6]; uint16_t theLeft = htons((val >> 32)&0xffffU); uint32_t theRight = htonl(val & 0xffffffffU); memcpy(bytes, (void*)&theLeft, 2); memcpy(bytes+2, (void*)&theRight, 4); d_record.insert(d_record.end(), bytes, bytes + 6); } void DNSPacketWriter::xfr32BitInt(uint32_t val) { int rval=htonl(val); uint8_t* ptr=reinterpret_cast(&rval); d_record.insert(d_record.end(), ptr, ptr+4); } void DNSPacketWriter::xfr16BitInt(uint16_t val) { uint16_t rval=htons(val); uint8_t* ptr=reinterpret_cast(&rval); d_record.insert(d_record.end(), ptr, ptr+2); } void DNSPacketWriter::xfr8BitInt(uint8_t val) { d_record.push_back(val); } /* input: "" -> 0 "blah" -> 4blah "blah" "blah" -> output 4blah4blah "verylongstringlongerthan256....characters" \xffverylongstring\x23characters (autosplit) "blah\"blah" -> 9blah"blah "blah\97" -> 5blahb */ void DNSPacketWriter::xfrText(const string& text, bool) { if(text.empty()) { d_record.push_back(0); return; } vector segments = segmentDNSText(text); BOOST_FOREACH(const string& str, segments) { d_record.push_back(str.length()); d_record.insert(d_record.end(), str.c_str(), str.c_str() + str.length()); } } DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& lmap, const string& label) { DNSPacketWriter::lmap_t::iterator ret; for(ret=lmap.begin(); ret != lmap.end(); ++ret) if(pdns_iequals(ret->first ,label)) break; return ret; } //! tokenize a label into parts, the parts describe a begin offset and an end offset bool labeltokUnescape(labelparts_t& parts, const string& label) { string::size_type epos = label.size(), lpos(0), pos; bool unescapedSomething = false; const char* ptr=label.c_str(); parts.clear(); for(pos = 0 ; pos < epos; ++pos) { if(ptr[pos]=='\\') { pos++; unescapedSomething = true; continue; } if(ptr[pos]=='.') { parts.push_back(make_pair(lpos, pos)); lpos=pos+1; } } if(lpos < pos) parts.push_back(make_pair(lpos, pos)); return unescapedSomething; } // this is the absolute hottest function in the pdns recursor void DNSPacketWriter::xfrLabel(const string& Label, bool compress) { string label = d_lowerCase ? toLower(Label) : Label; labelparts_t parts; if(d_canonic) compress=false; string::size_type labellen = label.size(); if(labellen==1 && label[0]=='.') { // otherwise we encode '..' d_record.push_back(0); return; } bool unescaped=labeltokUnescape(parts, label); // d_stuff is amount of stuff that is yet to be written out - the dnsrecordheader for example unsigned int pos=d_content.size() + d_record.size() + d_stuff; string chopped; bool deDot = labellen && (label[labellen-1]=='.'); // make sure we don't store trailing dots in the labelmap for(labelparts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) { if(deDot) chopped.assign(label.c_str() + i->first, labellen - i->first -1); else chopped.assign(label.c_str() + i->first); lmap_t::iterator li=d_labelmap.end(); // see if we've written out this domain before // cerr<<"Searching for compression pointer to '"<second<second; offset|=0xc000; d_record.push_back((char)(offset >> 8)); d_record.push_back((char)(offset & 0xff)); goto out; // skip trailing 0 in case of compression } if(li==d_labelmap.end() && pos< 16384) { // cerr<<"\tStoring a compression pointer to '"< 16384, won't work } if(unescaped) { string part(label.c_str() + i -> first, i->second - i->first); // FIXME: this relies on the semi-canonical escaped output from getLabelFromContent boost::replace_all(part, "\\.", "."); boost::replace_all(part, "\\032", " "); boost::replace_all(part, "\\\\", "\\"); if(part.size() > 255) throw MOADNSException("DNSPacketWriter::xfrLabel() tried to write an overly large label"); d_record.push_back(part.size()); unsigned int len=d_record.size(); d_record.resize(len + part.size()); memcpy(((&*d_record.begin()) + len), part.c_str(), part.size()); pos+=(part.size())+1; } else { char labelsize=(char)(i->second - i->first); if(!labelsize) // empty label in the middle of name throw MOADNSException("DNSPacketWriter::xfrLabel() found empty label in the middle of name"); d_record.push_back(labelsize); unsigned int len=d_record.size(); d_record.resize(len + i->second - i->first); memcpy(((&*d_record.begin()) + len), label.c_str() + i-> first, i->second - i->first); pos+=(i->second - i->first)+1; } } d_record.push_back(0); out:; } void DNSPacketWriter::xfrBlob(const string& blob, int ) { const uint8_t* ptr=reinterpret_cast(blob.c_str()); d_record.insert(d_record.end(), ptr, ptr+blob.size()); } void DNSPacketWriter::xfrHexBlob(const string& blob, bool keepReading) { xfrBlob(blob); } void DNSPacketWriter::getRecords(string& records) { records.assign(d_content.begin() + d_sor, d_content.end()); } uint32_t DNSPacketWriter::size() { return d_content.size() + d_stuff + d_record.size(); } void DNSPacketWriter::rollback() { d_content.resize(d_rollbackmarker); d_record.clear(); d_stuff=0; } void DNSPacketWriter::commit() { if(d_stuff==0xffff && (d_content.size()!=d_sor || !d_record.empty())) throw MOADNSException("DNSPacketWriter::commit() called without startRecord ever having been called, but a record was added"); // build dnsrecordheader struct dnsrecordheader drh; drh.d_type=htons(d_recordqtype); drh.d_class=htons(d_recordqclass); drh.d_ttl=htonl(d_recordttl); drh.d_clen=htons(d_record.size()); // and write out the header const uint8_t* ptr=(const uint8_t*)&drh; d_content.insert(d_content.end(), ptr, ptr+sizeof(drh)); d_stuff=0; // write out pending d_record d_content.insert(d_content.end(), d_record.begin(), d_record.end()); dnsheader* dh=reinterpret_cast( &*d_content.begin()); switch(d_recordplace) { case ANSWER: dh->ancount = htons(ntohs(dh->ancount) + 1); break; case AUTHORITY: dh->nscount = htons(ntohs(dh->nscount) + 1); break; case ADDITIONAL: dh->arcount = htons(ntohs(dh->arcount) + 1); break; } d_record.clear(); // clear d_record, ready for next record } pdns-3.3/pdns/pdns.in0000755000014601777760000000636012155275020016032 0ustar00jenkinsnogroup00000000000000#!/bin/sh # chkconfig: - 80 75 # description: PDNS is a versatile high performance authoritative nameserver ### BEGIN INIT INFO # Provides: pdns # Required-Start: $remote_fs $network $syslog # Required-Stop: $remote_fs $network $syslog # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: PowerDNS authoritative server # Description: PowerDNS authoritative server ### END INIT INFO set -e prefix=@prefix@ exec_prefix=@exec_prefix@ BINARYPATH=@bindir@ SBINARYPATH=@sbindir@ SOCKETPATH=@socketdir@ [ -f "$SBINARYPATH/pdns_server" ] || exit 0 [ -r /etc/default/pdns ] && . /etc/default/pdns cd $SOCKETPATH suffix=$(basename $0 | cut -d- -f2- -s) if [ -n "$suffix" ] then EXTRAOPTS=--config-name=$suffix PROGNAME=pdns-$suffix else PROGNAME=pdns fi pdns_server="$SBINARYPATH/pdns_server $EXTRAOPTS" doPC() { ret=$($BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null) } NOTRUNNING=0 doPC ping || NOTRUNNING=$? case "$1" in status) if test "$NOTRUNNING" = "0" then doPC status echo $ret else echo "not running" exit 3 fi ;; stop) echo -n "Stopping PowerDNS authoritative nameserver: " if test "$NOTRUNNING" = "0" then doPC quit echo $ret else echo "not running" fi ;; force-stop) echo -n "Stopping PowerDNS authoritative nameserver: " killall -v -9 pdns_server echo "killed" ;; start) echo -n "Starting PowerDNS authoritative nameserver: " if test "$NOTRUNNING" = "0" then echo "already running" else if $pdns_server --daemon --guardian=yes then echo "started" else echo "starting failed" exit 1 fi fi ;; force-reload | restart) echo -n "Restarting PowerDNS authoritative nameserver: " if test "$NOTRUNNING" = "1" then echo "not running, starting" else echo -n stopping and waiting.. doPC quit sleep 3 echo done fi $0 start ;; reload) echo -n "Reloading PowerDNS authoritative nameserver: " if test "$NOTRUNNING" = "0" then doPC cycle echo requested reload else echo not running yet $0 start fi ;; monitor) if test "$NOTRUNNING" = "0" then echo "already running" else $pdns_server --daemon=no --guardian=no --control-console --loglevel=9 fi ;; dump) if test "$NOTRUNNING" = "0" then doPC list echo $ret else echo "not running" fi ;; show) if [ $# -lt 2 ] then echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then echo -n "$2=" doPC show $2 ; echo $ret else echo "not running" fi ;; mrtg) if [ $# -lt 2 ] then echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then doPC show $2 ; echo $ret if [ "$3x" != "x" ] then doPC show $3 ; echo $ret else echo 0 fi doPC uptime ; echo $ret echo PowerDNS daemon else echo "not running" fi ;; cricket) if [ $# -lt 2 ] then echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then doPC show $2 ; echo $ret else echo "not running" fi ;; *) echo pdns [start\|stop\|force-reload\|reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor] ;; esac pdns-3.3/pdns/resolver.hh0000644000014601777760000001037712136555572016734 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include "iputils.hh" #ifndef WIN32 # include # include # include # include # include # include # include # include # undef res_mkquery #endif // WIN32 #include "ahuexception.hh" #include "dns.hh" #include "namespaces.hh" #include "dnsbackend.hh" class ResolverException : public AhuException { public: ResolverException(const string &reason) : AhuException(reason){} }; // make an IPv4 or IPv6 query socket int makeQuerySocket(const ComboAddress& local, bool udpOrTCP); //! Resolver class. Can be used synchronously and asynchronously, over IPv4 and over IPv6 (simultaneously) class Resolver : public boost::noncopyable { public: Resolver(); ~Resolver(); typedef vector res_t; //! synchronously resolve domain|type at IP, store result in result, rcode in ret int resolve(const string &ip, const char *domain, int type, res_t* result); //! only send out a resolution request uint16_t sendResolve(const ComboAddress& remote, const char *domain, int type, bool dnssecOk=false, const string& tsigkeyname="", const string& tsigalgorithm="", const string& tsigsecret=""); //! see if we got a SOA response from our sendResolve bool tryGetSOASerial(string* theirDomain, uint32_t* theirSerial, uint32_t* theirInception, uint32_t* theirExpire, uint16_t* id); //! convenience function that calls resolve above void getSoaSerial(const string &, const string &, uint32_t *); private: int d_sock4, d_sock6; int d_type; int d_timeout; string d_domain; uint16_t d_randomid; ComboAddress d_remote; }; class AXFRRetriever : public boost::noncopyable { public: AXFRRetriever(const ComboAddress& remote, const string& zone, const string& tsigkeyname=string(), const string& tsigalgorithm=string(), const string& tsigsecret=string(), const ComboAddress* laddr = NULL); ~AXFRRetriever(); int getChunk(Resolver::res_t &res); private: void connect(); int getLength(); void timeoutReadn(uint16_t bytes); shared_array d_buf; string d_domain; int d_sock; int d_soacount; ComboAddress d_remote; string d_tsigkeyname; string d_tsigsecret; string d_prevMac; // RFC2845 4.4 string d_signData; uint32_t d_tsigPos; uint d_nonSignedMessages; // RFC2845 4.4 TSIGRecordContent d_trc; }; // class that one day might be more than a function to help you get IP addresses for a nameserver class FindNS { public: vector lookup(const string &name, DNSBackend *B) { vector addresses; struct addrinfo* res; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); for(int n = 0; n < 2; ++n) { hints.ai_family = n ? AF_INET : AF_INET6; ComboAddress remote; remote.sin4.sin_family = AF_INET6; if(!getaddrinfo(name.c_str(), 0, &hints, &res)) { struct addrinfo* address = res; do { memcpy(&remote, address->ai_addr, address->ai_addrlen); addresses.push_back(remote.toString()); } while((address = address->ai_next)); freeaddrinfo(res); } } B->lookup(QType(QType::ANY),name); DNSResourceRecord rr; while(B->get(rr)) if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA) addresses.push_back(rr.content); // SOL if you have a CNAME for an NS return addresses; } }; pdns-3.3/pdns/utility.hh0000644000014601777760000001175712155641611016570 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // Utility class specification. #ifndef UTILITY_HH #define UTILITY_HH #ifndef WIN32 // # include "config.h" #endif // WIN32 #ifdef _MSC_VER # define NEED_POSIX_TYPEDEF # pragma warning (disable:4996) #endif // _MSC_VER #ifdef NEED_POSIX_TYPEDEF typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned long long uint64_t; #endif #ifndef WIN32 # include # include # include # include # include # include # include # include # include # include # include #else typedef int socklen_t; #define _WIN32_WINNT 0x0400 #include #include #include # define WINDOWS_LEAN_AND_MEAN # include # include # include #ifndef ETIMEDOUT # define ETIMEDOUT WSAETIMEDOUT #endif // ETIMEDOUT # define EINPROGRESS WSAEWOULDBLOCK # define snprintf _snprintf #endif // WIN32 #include #include "namespaces.hh" //! A semaphore class. class Semaphore { private: sem_t *m_pSemaphore; #ifdef WIN32 typedef int sem_value_t; //! The semaphore. //! Semaphore counter. long m_counter; #else typedef int sem_value_t; #endif protected: public: //! Default constructor. Semaphore( unsigned int value = 0 ); //! Destructor. ~Semaphore( void ); //! Posts to a semaphore. int post( void ); //! Waits for a semaphore. int wait( void ); //! Tries to wait for a semaphore. int tryWait( void ); //! Retrieves the semaphore value. int getValue( Semaphore::sem_value_t *sval ); }; //! This is a utility class used for platform independant abstraction. class Utility { #ifdef WIN32 private: static int inet_pton4( const char *src, void *dst ); static int inet_pton6( const char *src, void *dst ); static const char *inet_ntop4( const char *src, char *dst, size_t size ); static const char *inet_ntop6( const char *src, char *dst, size_t size ); #endif // WIN32 public: #ifdef WIN32 //! iovec structure for windows. typedef struct { void *iov_base; //!< Base address. size_t iov_len; //!< Number of bytes. } iovec; // A few type defines. typedef DWORD pid_t; typedef SOCKET sock_t; typedef int socklen_t; #else typedef ::iovec iovec; typedef ::pid_t pid_t; typedef int sock_t; typedef ::socklen_t socklen_t; #endif // WIN32 //! Closes a socket. static int closesocket( sock_t socket ); //! Returns the process id of the current process. static pid_t getpid( void ); //! Gets the current time. static int gettimeofday( struct timeval *tv, void *tz = NULL ); //! Converts an address from dot and numbers format to binary data. static int inet_aton( const char *cp, struct in_addr *inp ); //! Converts an address from presentation format to network format. static int inet_pton( int af, const char *src, void *dst ); //! The inet_ntop() function converts an address from network format (usually a struct in_addr or some other binary form, in network byte order) to presentation format. static const char *inet_ntop( int af, const char *src, char *dst, size_t size ); //! Retrieves a gid using a groupname. static int makeGidNumeric( const string & group ); //! Retrieves an uid using an username. static int makeUidNumeric( const string & username ); //! Writes a vector. static int writev( Utility::sock_t socket, const iovec *vector, size_t count ); //! Returns a random number. static long int random( void ); //! Sets the random seed. static void srandom( unsigned int seed ); //! Drops the program's privileges. static void dropPrivs( int uid, int gid ); //! Sets the socket into blocking mode. static bool setBlocking( Utility::sock_t socket ); //! Sets the socket into non-blocking mode. static bool setNonBlocking( Utility::sock_t socket ); //! Marks the socket to be closed on exec(). static bool setCloseOnExec ( Utility::sock_t socket ); //! Sleeps for a number of seconds. static unsigned int sleep( unsigned int seconds ); //! Sleeps for a number of microseconds. static void usleep( unsigned long usec ); static time_t timegm(struct tm *tm); }; #endif // UTILITY_HH pdns-3.3/pdns/dnssecinfra.hh0000644000014601777760000001240212142141727017347 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_DNSSECINFRA_HH #define PDNS_DNSSECINFRA_HH #include "dnsrecords.hh" #include #include #include #include #include "misc.hh" // rules of the road: Algorithm must be set in 'make' for each KeyEngine, and will NEVER change! class DNSCryptoKeyEngine { public: explicit DNSCryptoKeyEngine(unsigned int algorithm) : d_algorithm(algorithm) {} virtual ~DNSCryptoKeyEngine() {}; virtual string getName() const = 0; typedef std::map stormap_t; typedef std::vector > storvector_t; virtual void create(unsigned int bits)=0; virtual storvector_t convertToISCVector() const =0; std::string convertToISC() const ; virtual std::string sign(const std::string& msg) const =0; virtual std::string hash(const std::string& msg) const =0; virtual bool verify(const std::string& msg, const std::string& signature) const =0; virtual std::string getPubKeyHash()const =0; virtual std::string getPublicKeyString()const =0; virtual int getBits() const =0; virtual void fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap)=0; virtual void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) { throw std::runtime_error("Can't import from PEM string"); } virtual void fromPublicKeyString(const std::string& content) = 0; static DNSCryptoKeyEngine* makeFromISCFile(DNSKEYRecordContent& drc, const char* fname); static DNSCryptoKeyEngine* makeFromISCString(DNSKEYRecordContent& drc, const std::string& content); static DNSCryptoKeyEngine* makeFromPEMString(DNSKEYRecordContent& drc, const std::string& raw); static DNSCryptoKeyEngine* makeFromPublicKeyString(unsigned int algorithm, const std::string& raw); static DNSCryptoKeyEngine* make(unsigned int algorithm); typedef DNSCryptoKeyEngine* maker_t(unsigned int algorithm); static void report(unsigned int algorithm, maker_t* maker, bool fallback=false); static std::pair testMakers(unsigned int algorithm, maker_t* creator, maker_t* signer, maker_t* verifier); static void testAll(); static void testOne(int algo); private: typedef std::map makers_t; typedef std::map > allmakers_t; static makers_t& getMakers() { static makers_t s_makers; return s_makers; } static allmakers_t& getAllMakers() { static allmakers_t s_allmakers; return s_allmakers; } protected: const unsigned int d_algorithm; }; struct DNSSECPrivateKey { uint16_t getTag(); const DNSCryptoKeyEngine* getKey() const { return d_key.get(); } void setKey(const shared_ptr key) { d_key = key; } DNSKEYRecordContent getDNSKEY() const; uint8_t d_algorithm; uint16_t d_flags; private: shared_ptr d_key; }; struct CanonicalCompare: public std::binary_function { bool operator()(const std::string& a, const std::string& b) { std::vector avect, bvect; stringtok(avect, a, "."); stringtok(bvect, b, "."); reverse(avect.begin(), avect.end()); reverse(bvect.begin(), bvect.end()); return avect < bvect; } }; bool sharedDNSSECCompare(const boost::shared_ptr& a, const shared_ptr& b); string getMessageForRRSET(const std::string& qname, const RRSIGRecordContent& rrc, std::vector >& signRecords); DSRecordContent makeDSFromDNSKey(const std::string& qname, const DNSKEYRecordContent& drc, int digest=1); int countLabels(const std::string& signQName); class RSAContext; class DNSSECKeeper; struct DNSSECPrivateKey; void fillOutRRSIG(DNSSECPrivateKey& dpk, const std::string& signQName, RRSIGRecordContent& rrc, vector >& toSign); uint32_t getStartOfWeek(); void addSignature(DNSSECKeeper& dk, DNSBackend& db, const std::string& signer, const std::string signQName, const std::string& wildcardname, uint16_t signQType, uint32_t signTTL, DNSPacketWriter::Place signPlace, vector >& toSign, vector& outsigned, uint32_t origTTL); int getRRSIGsForRRSET(DNSSECKeeper& dk, const std::string& signer, const std::string signQName, uint16_t signQType, uint32_t signTTL, vector >& toSign, vector &rrc, bool ksk); std::string hashQNameWithSalt(unsigned int times, const std::string& salt, const std::string& qname); void decodeDERIntegerSequence(const std::string& input, vector& output); class DNSPacket; void addRRSigs(DNSSECKeeper& dk, DNSBackend& db, const std::set& authMap, vector& rrs); string calculateMD5HMAC(const std::string& key_, const std::string& text); string makeTSIGMessageFromTSIGPacket(const string& opacket, unsigned int tsigoffset, const string& keyname, const TSIGRecordContent& trc, const string& previous, bool timersonly, unsigned int dnsHeaderOffset=0); void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyname, const string& tsigsecret, const string& tsigprevious, bool timersonly); #endif pdns-3.3/pdns/dnssecinfra.cc0000644000014601777760000003557212160025353017346 0ustar00jenkinsnogroup00000000000000#include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "statbag.hh" #include "iputils.hh" #include #include #include "dnssecinfra.hh" #include "dnsseckeeper.hh" #ifdef HAVE_LIBPOLARSSL #include #else #include "ext/polarssl-1.1.2/include/polarssl/sha1.h" #endif #include // for 'operator+=()' #include #include "base64.hh" #include "md5.hh" #include "namespaces.hh" using namespace boost::assign; DNSCryptoKeyEngine* DNSCryptoKeyEngine::makeFromISCFile(DNSKEYRecordContent& drc, const char* fname) { string sline, isc; FILE *fp=fopen(fname, "r"); if(!fp) { throw runtime_error("Unable to read file '"+string(fname)+"' for generating DNS Private Key"); } while(stringfgets(fp, sline)) { isc += sline; } fclose(fp); return makeFromISCString(drc, isc); } DNSCryptoKeyEngine* DNSCryptoKeyEngine::makeFromISCString(DNSKEYRecordContent& drc, const std::string& content) { int algorithm = 0; string sline, key, value, raw; std::istringstream str(content); map stormap; while(std::getline(str, sline)) { tie(key,value)=splitField(sline, ':'); trim(value); if(pdns_iequals(key,"algorithm")) { algorithm = atoi(value.c_str()); stormap["algorithm"]=lexical_cast(algorithm); continue; } else if(pdns_iequals(key, "Private-key-format")) continue; raw.clear(); B64Decode(value, raw); stormap[toLower(key)]=raw; } DNSCryptoKeyEngine* dpk=make(algorithm); dpk->fromISCMap(drc, stormap); return dpk; } std::string DNSCryptoKeyEngine::convertToISC() const { typedef map stormap_t; storvector_t stormap = this->convertToISCVector(); ostringstream ret; ret<<"Private-key-format: v1.2\n"; BOOST_FOREACH(const stormap_t::value_type& value, stormap) { if(value.first != "Algorithm") ret<second)(algo); else { throw runtime_error("Request to create key object for unknown algorithm number "+lexical_cast(algo)); } } void DNSCryptoKeyEngine::report(unsigned int algo, maker_t* maker, bool fallback) { getAllMakers()[algo].push_back(maker); if(getMakers().count(algo) && fallback) { return; } getMakers()[algo]=maker; } void DNSCryptoKeyEngine::testAll() { BOOST_FOREACH(const allmakers_t::value_type& value, getAllMakers()) { BOOST_FOREACH(maker_t* creator, value.second) { BOOST_FOREACH(maker_t* signer, value.second) { // multi_map bestSigner, bestVerifier; BOOST_FOREACH(maker_t* verifier, value.second) { try { /* pair res=*/ testMakers(value.first, creator, signer, verifier); } catch(std::exception& e) { cerr< bestSigner, bestVerifier; BOOST_FOREACH(maker_t* verifier, getAllMakers()[algo]) { try { /* pair res=*/testMakers(algo, creator, signer, verifier); } catch(std::exception& e) { cerr< DNSCryptoKeyEngine::testMakers(unsigned int algo, maker_t* creator, maker_t* signer, maker_t* verifier) { shared_ptr dckeCreate(creator(algo)); shared_ptr dckeSign(signer(algo)); shared_ptr dckeVerify(verifier(algo)); cerr<<"Testing algorithm "<getName()<<"' ->'"<getName()<<"' -> '"<getName()<<"' "; unsigned int bits; if(algo <= 10) bits=1024; else if(algo == 12 || algo == 13 || algo == 250) // GOST or nistp256 or ED25519 bits=256; else bits=384; dckeCreate->create(bits); { // FIXME: this block copy/pasted from makeFromISCString DNSKEYRecordContent dkrc; int algorithm = 0; string sline, key, value, raw; std::istringstream str(dckeCreate->convertToISC()); map stormap; while(std::getline(str, sline)) { tie(key,value)=splitField(sline, ':'); trim(value); if(pdns_iequals(key,"algorithm")) { algorithm = atoi(value.c_str()); stormap["algorithm"]=lexical_cast(algorithm); continue; } else if(pdns_iequals(key, "Private-key-format")) continue; raw.clear(); B64Decode(value, raw); stormap[toLower(key)]=raw; } dckeSign->fromISCMap(dkrc, stormap); } string message("Hi! How is life?"); string signature; DTime dt; dt.set(); for(unsigned int n = 0; n < 100; ++n) signature = dckeSign->sign(message); unsigned int udiffSign= dt.udiff()/100, udiffVerify; dckeVerify->fromPublicKeyString(dckeSign->getPublicKeyString()); dt.set(); if(dckeVerify->verify(message, signature)) { udiffVerify = dt.udiff(); cerr<<"Signature & verify ok, signature "<getName()+" with signer "+dckeSign->getName()+" and verifier "+dckeVerify->getName()+" failed"); } return make_pair(udiffSign, udiffVerify); } DNSCryptoKeyEngine* DNSCryptoKeyEngine::makeFromPublicKeyString(unsigned int algorithm, const std::string& content) { DNSCryptoKeyEngine* dpk=make(algorithm); dpk->fromPublicKeyString(content); return dpk; } DNSCryptoKeyEngine* DNSCryptoKeyEngine::makeFromPEMString(DNSKEYRecordContent& drc, const std::string& raw) { BOOST_FOREACH(makers_t::value_type& val, getMakers()) { DNSCryptoKeyEngine* ret=0; try { ret = val.second(val.first); ret->fromPEMString(drc, raw); return ret; } catch(...) { delete ret; // fine if 0 } } return 0; } bool sharedDNSSECCompare(const shared_ptr& a, const shared_ptr& b) { return a->serialize("", true, true) < b->serialize("", true, true); } string getMessageForRRSET(const std::string& qname, const RRSIGRecordContent& rrc, vector >& signRecords) { sort(signRecords.begin(), signRecords.end(), sharedDNSSECCompare); string toHash; toHash.append(const_cast(rrc).serialize("", true, true)); toHash.resize(toHash.size() - rrc.d_signature.length()); // chop off the end, don't sign the signature! BOOST_FOREACH(shared_ptr& add, signRecords) { toHash.append(toLower(simpleCompress(qname, ""))); uint16_t tmp=htons(rrc.d_type); toHash.append((char*)&tmp, 2); tmp=htons(1); // class toHash.append((char*)&tmp, 2); uint32_t ttl=htonl(rrc.d_originalttl); toHash.append((char*)&ttl, 4); string rdata=add->serialize("", true, true); tmp=htons(rdata.length()); toHash.append((char*)&tmp, 2); toHash.append(rdata); } return toHash; } DSRecordContent makeDSFromDNSKey(const std::string& qname, const DNSKEYRecordContent& drc, int digest) { string toHash; toHash.assign(toLower(simpleCompress(qname))); toHash.append(const_cast(drc).serialize("", true, true)); DSRecordContent dsrc; if(digest==1) { shared_ptr dpk(DNSCryptoKeyEngine::make(5)); // gives us SHA1 dsrc.d_digest = dpk->hash(toHash); } else if(digest == 2) { shared_ptr dpk(DNSCryptoKeyEngine::make(8)); // gives us SHA256 dsrc.d_digest = dpk->hash(toHash); } else if(digest == 3) { shared_ptr dpk(DNSCryptoKeyEngine::make(12)); // gives us GOST dsrc.d_digest = dpk->hash(toHash); } else if(digest == 4) { shared_ptr dpk(DNSCryptoKeyEngine::make(14)); // gives us ECDSAP384 dsrc.d_digest = dpk->hash(toHash); } else throw std::runtime_error("Asked to a DS of unkown digest type " + lexical_cast(digest)+"\n"); dsrc.d_algorithm= drc.d_algorithm; dsrc.d_digesttype=digest; dsrc.d_tag=const_cast(drc).getTag(); return dsrc; } DNSKEYRecordContent makeDNSKEYFromDNSCryptoKeyEngine(const DNSCryptoKeyEngine* pk, uint8_t algorithm, uint16_t flags) { DNSKEYRecordContent drc; drc.d_protocol=3; drc.d_algorithm = algorithm; drc.d_flags=flags; drc.d_key = pk->getPublicKeyString(); return drc; } int countLabels(const std::string& signQName) { int count =1; for(string::const_iterator pos = signQName.begin(); pos != signQName.end() ; ++pos) if(*pos == '.' && pos+1 != signQName.end()) count++; if(boost::starts_with(signQName, "*.")) count--; return count; } uint32_t getStartOfWeek() { uint32_t now = time(0); now -= (now % (7*86400)); return now; } std::string hashQNameWithSalt(unsigned int times, const std::string& salt, const std::string& qname) { string toHash; toHash.assign(simpleCompress(toLower(qname))); toHash.append(salt); // cerr<= d_str.length()) { throw eof(); } return (uint8_t) d_str[d_pos++]; } uint32_t getLength() { uint8_t first = getByte(); if(first < 0x80) { return first; } first &= ~0x80; uint32_t len=0; for(int n=0; n < first; ++n) { len *= 0x100; len += getByte(); } return len; } std::string getBytes(unsigned int len) { std::string ret; for(unsigned int n=0; n < len; ++n) ret.append(1, (char)getByte()); return ret; } std::string::size_type getOffset() { return d_pos; } private: const std::string& d_str; std::string::size_type d_pos; }; void decodeDERIntegerSequence(const std::string& input, vector& output) { output.clear(); DEREater de(input); if(de.getByte() != 0x30) throw runtime_error("Not a DER sequence"); unsigned int seqlen=de.getLength(); unsigned int startseq=de.getOffset(); unsigned int len; string ret; try { for(;;) { uint8_t kind = de.getByte(); if(kind != 0x02) throw runtime_error("DER Sequence contained non-INTEGER component: "+lexical_cast((unsigned int)kind) ); len = de.getLength(); ret = de.getBytes(len); output.push_back(ret); } } catch(DEREater::eof& eof) { if(de.getOffset() - startseq != seqlen) throw runtime_error("DER Sequence ended before end of data"); } } string calculateMD5HMAC(const std::string& key_, const std::string& text) { const unsigned char* key=(const unsigned char*)key_.c_str(); unsigned char keyIpad[64]; unsigned char keyOpad[64]; //~ cerr<<"Key: "< signVect; DNSPacketWriter dw(signVect, "", 0); if(!timersonly) { dw.xfrLabel(keyname, false); dw.xfr16BitInt(0xff); // class dw.xfr32BitInt(0); // TTL dw.xfrLabel(trc.d_algoName, false); } uint32_t now = trc.d_time; dw.xfr48BitInt(now); dw.xfr16BitInt(trc.d_fudge); // fudge if(!timersonly) { dw.xfr16BitInt(trc.d_eRcode); // extended rcode dw.xfr16BitInt(trc.d_otherData.length()); // length of 'other' data // dw.xfrBlob(trc->d_otherData); } const vector& signRecord=dw.getRecordBeingWritten(); message.append(&*signRecord.begin(), &*signRecord.end()); return message; } void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyname, const string& tsigsecret, const string& tsigprevious, bool timersonly) { if (trc->d_algoName != "hmac-md5.sig-alg.reg.int.") { L<d_algoName << endl; return; } string toSign; if(!tsigprevious.empty()) { uint16_t len = htons(tsigprevious.length()); toSign.append((char*)&len, 2); toSign.append(tsigprevious); } toSign.append(&*pw.getContent().begin(), &*pw.getContent().end()); // now add something that looks a lot like a TSIG record, but isn't vector signVect; DNSPacketWriter dw(signVect, "", 0); if(!timersonly) { dw.xfrLabel(tsigkeyname, false); dw.xfr16BitInt(0xff); // class dw.xfr32BitInt(0); // TTL dw.xfrLabel(trc->d_algoName, false); } uint32_t now = trc->d_time; dw.xfr48BitInt(now); dw.xfr16BitInt(trc->d_fudge); // fudge if(!timersonly) { dw.xfr16BitInt(trc->d_eRcode); // extended rcode dw.xfr16BitInt(trc->d_otherData.length()); // length of 'other' data // dw.xfrBlob(trc->d_otherData); } const vector& signRecord=dw.getRecordBeingWritten(); toSign.append(&*signRecord.begin(), &*signRecord.end()); trc->d_mac = calculateMD5HMAC(tsigsecret, toSign); // d_trc->d_mac[0]++; // sabotage pw.startRecord(tsigkeyname, QType::TSIG, 0, 0xff, DNSPacketWriter::ADDITIONAL); trc->toPacket(pw); pw.commit(); } pdns-3.3/pdns/dnsbackend.hh0000644000014601777760000002351012145153461017147 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2010 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DNSBACKEND_HH #define DNSBACKEND_HH class DNSPacket; #include "utility.hh" #include #include #include #include #include "ahuexception.hh" #include #include #ifndef WIN32 # include # include #endif // WIN32 #include "qtype.hh" #include "dns.hh" #include #include "namespaces.hh" class DNSBackend; struct DomainInfo { DomainInfo() : backend(0) {} uint32_t id; string zone; vector masters; uint32_t notified_serial; uint32_t serial; time_t last_check; enum {Master,Slave,Native} kind; DNSBackend *backend; bool operator<(const DomainInfo& rhs) const { return zone < rhs.zone; } }; class DNSPacket; //! This virtual base class defines the interface for backends for the ahudns. /** To create a backend, inherit from this class and implement functions for all virtual methods. Methods should not throw an exception if they are sure they did not find the requested data. However, if an error occurred which prevented them temporarily from performing a lockup, they should throw a DBException, which will cause the nameserver to send out a ServFail or take other evasive action. Probably only locking issues should lead to DBExceptions. More serious errors, which may indicate that the database connection is hosed, or a configuration error occurred, should lead to the throwing of an AhuException. This exception will fall straight through the UeberBackend and the PacketHandler and be caught by the Distributor, which will delete your DNSBackend instance and spawn a new one. */ class DNSBackend { public: //! lookup() initiates a lookup. A lookup without results should not throw! virtual void lookup(const QType &qtype, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1)=0; virtual bool get(DNSResourceRecord &)=0; //!< retrieves one DNSResource record, returns false if no more were available //! Initiates a list of the specified domain /** Once initiated, DNSResourceRecord objects can be retrieved using get(). Should return false if the backend does not consider itself responsible for the id passed. \param domain_id ID of which a list is requested */ virtual bool list(const string &target, int domain_id)=0; virtual ~DNSBackend(){}; //! fills the soadata struct with the SOA details. Returns false if there is no SOA. virtual bool getSOA(const string &name, SOAData &soadata, DNSPacket *p=0); //! Calculates a SOA serial for the zone and stores it in the third argument. virtual bool calculateSOASerial(const string& domain, const SOAData& sd, time_t& serial); virtual bool replaceRRSet(uint32_t domain_id, const string& qname, const QType& qt, const vector& rrset) { return false; } // the DNSSEC related (getDomainMetadata has broader uses too) virtual bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { return false; } virtual bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) {return false;} virtual void getAllDomains(vector *domains) { } struct KeyData { unsigned int id; unsigned int flags; bool active; std::string content; }; virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { return false;} virtual bool removeDomainKey(const string& name, unsigned int id) { return false; } virtual int addDomainKey(const string& name, const KeyData& key){ return -1; } virtual bool activateDomainKey(const string& name, unsigned int id) { return false; } virtual bool deactivateDomainKey(const string& name, unsigned int id) { return false; } virtual bool getTSIGKey(const string& name, string* algorithm, string* content) { return false; } virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { std::cerr<<"Default beforeAndAfterAbsolute called!"<& insert, set& erase, bool remove) { return false; } virtual bool nullifyDNSSECOrderNameAndUpdateAuth(uint32_t domain_id, const std::string& qname, bool auth) { return false; } virtual bool nullifyDNSSECOrderNameAndAuth(uint32_t domain_id, const std::string& qname, const std::string& type) { return false; } virtual bool setDNSSECAuthOnDsRecord(uint32_t domain_id, const std::string& qname) { return false; } virtual bool doesDNSSEC() { return false; } // end DNSSEC //! returns true if master ip is master for domain name. virtual bool isMaster(const string &name, const string &ip) { return false; } //! starts the transaction for updating domain qname (FIXME: what is id?) virtual bool startTransaction(const string &qname, int id=-1) { return false; } //! commits the transaction started by startTransaction virtual bool commitTransaction() { return false; } //! aborts the transaction started by strartTransaction, should leave state unaltered virtual bool abortTransaction() { return false; } virtual void reload() { } virtual void rediscover(string* status=0) { } //! feeds a record to a zone, needs a call to startTransaction first virtual bool feedRecord(const DNSResourceRecord &rr, string *ordername=0) { return false; // no problem! } virtual bool feedEnts(int domain_id, set &nonterm) { return false; } virtual bool feedEnts3(int domain_id, const string &domain, set &nonterm, unsigned int times, const string &salt, bool narrow) { return false; } //! if this returns true, DomainInfo di contains information about the domain virtual bool getDomainInfo(const string &domain, DomainInfo &di) { return false; } //! slave capable backends should return a list of slaves that should be rechecked for staleness virtual void getUnfreshSlaveInfos(vector* domains) { } //! get a list of IP addresses that should also be notified for a domain virtual void alsoNotifies(const string &domain, set *ips) { } //! get list of domains that have been changed since their last notification to slaves virtual void getUpdatedMasters(vector* domains) { } //! Called by PowerDNS to inform a backend that a domain has been checked for freshness virtual void setFresh(uint32_t domain_id) { } //! Called by PowerDNS to inform a backend that the changes in the domain have been reported to slaves virtual void setNotified(uint32_t id, uint32_t serial) { } //! Can be called to seed the getArg() function with a prefix void setArgPrefix(const string &prefix); //! determine if ip is a supermaster or a domain virtual bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *account, DNSBackend **db) { return false; } //! called by PowerDNS to create a slave record for a superMaster virtual bool createSlaveDomain(const string &ip, const string &domain, const string &account) { return false; } protected: bool mustDo(const string &key); const string &getArg(const string &key); int getArgAsNum(const string &key); string getRemote(DNSPacket *p); bool getRemote(DNSPacket *p, struct sockaddr *in, Utility::socklen_t *len); private: string d_prefix; }; class BackendFactory { public: BackendFactory(const string &name) : d_name(name) {} virtual ~BackendFactory(){} virtual DNSBackend *make(const string &suffix)=0; virtual DNSBackend *makeMetadataOnly(const string &suffix) { return this->make(suffix); } virtual void declareArguments(const string &suffix=""){} const string &getName() const; protected: void declare(const string &suffix, const string ¶m, const string &explanation, const string &value); private: const string d_name; }; class BackendMakerClass { public: void report(BackendFactory *bf); void launch(const string &instr); vectorall(bool skipBIND=false); void load(const string &module); int numLauncheable(); vector getModules(); private: void load_all(); typedef mapd_repository_t; d_repository_t d_repository; vector >d_instances; }; extern BackendMakerClass &BackendMakers(); //! Exception that can be thrown by a DNSBackend to indicate a failure class DBException : public AhuException { public: DBException(const string &reason) : AhuException(reason){} }; #endif pdns-3.3/pdns/dnsproxy.cc0000644000014601777760000001421712136555572016744 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2004 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation; 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include "dnsproxy.hh" #include "ahuexception.hh" #include #include #include "dns.hh" #include "logger.hh" #include "statbag.hh" extern StatBag S; extern PacketCache PC; DNSProxy::DNSProxy(const string &remote) { pthread_mutex_init(&d_lock,0); d_resanswers=S.getPointer("recursing-answers"); d_resquestions=S.getPointer("recursing-questions"); d_udpanswers=S.getPointer("udp-answers"); ComboAddress remaddr(remote, 53); if((d_sock=socket(remaddr.sin4.sin_family, SOCK_DGRAM,0))<0) throw AhuException(string("socket: ")+strerror(errno)); ComboAddress local; if(remaddr.sin4.sin_family==AF_INET) local = ComboAddress("0.0.0.0"); else local = ComboAddress("::"); int n=0; for(;n<10;n++) { local.sin4.sin_port = htons(10000+( Utility::random()%50000)); if(::bind(d_sock, (struct sockaddr *)&local, local.getSocklen()) >= 0) break; } if(n==10) { Utility::closesocket(d_sock); d_sock=-1; throw AhuException(string("binding dnsproxy socket: ")+strerror(errno)); } if(connect(d_sock, (sockaddr *)&remaddr, remaddr.getSocklen())<0) throw AhuException("Unable to UDP connect to remote nameserver "+remaddr.toStringWithPort()+": "+stringerror()); d_xor=Utility::random()&0xffff; L<parts; stringtok(parts,ips,", \t"); for(vector::const_iterator i=parts.begin(); i!=parts.end();++i) d_ng.addMask(*i); } bool DNSProxy::recurseFor(DNSPacket* p) { return d_ng.match((ComboAddress *)&p->d_remote); } /** returns false if p->remote is not allowed to recurse via us */ bool DNSProxy::sendPacket(DNSPacket *p) { if(!recurseFor(p)) return false; uint16_t id; { Lock l(&d_lock); id=getID_locked(); ConntrackEntry ce; ce.id = p->d.id; ce.remote = p->d_remote; ce.outsock = p->getSocket(); ce.created = time( NULL ); ce.qtype = p->qtype.getCode(); ce.qname = p->qdomain; d_conntrack[id]=ce; } p->d.id=id^d_xor; p->commitD(); const string& buffer = p->getString(); if(send(d_sock,buffer.c_str(), buffer.length() , 0)<0) { // zoom L<second.createdsecond.created) L<second.remote.toStringWithPort()<<" with internal id "<second.id; memcpy(buffer,&d,sizeof(d)); // commit spoofed id DNSPacket p,q; p.parse(buffer,len); q.parse(buffer,len); if(p.qtype.getCode() != i->second.qtype || p.qdomain != i->second.qname) { L<second.outsock, buffer, len, 0, (struct sockaddr*)&i->second.remote, i->second.remote.getSocklen()); PC.insert(&q, &p); i->second.created=0; } } } catch(AhuException &ae) { L< forward S box t_xxx(i,box) => inverse S box 256 32-bit word OR 4 x 256 32-bit word tables: t_xxx(f,n) => forward normal round t_xxx(f,l) => forward last round t_xxx(i,n) => inverse normal round t_xxx(i,l) => inverse last round t_xxx(l,s) => key schedule table t_xxx(i,m) => key schedule table Other variables and tables: t_xxx(r,c) => the rcon table */ #if !defined( _AESTAB_H ) #define _AESTAB_H #define t_dec(m,n) t_##m##n #define t_set(m,n) t_##m##n #define t_use(m,n) t_##m##n #if defined(FIXED_TABLES) # if !defined( __GNUC__ ) && (defined( __MSDOS__ ) || defined( __WIN16__ )) /* make tables far data to avoid using too much DGROUP space (PG) */ # define CONST const far # else # define CONST const # endif #else # define CONST #endif #if defined(__cplusplus) # define EXTERN extern "C" #elif defined(DO_TABLES) # define EXTERN #else # define EXTERN extern #endif #if defined(_MSC_VER) && defined(TABLE_ALIGN) #define ALIGN __declspec(align(TABLE_ALIGN)) #else #define ALIGN #endif #if defined( __WATCOMC__ ) && ( __WATCOMC__ >= 1100 ) # define XP_DIR __cdecl #else # define XP_DIR #endif #if defined(DO_TABLES) && defined(FIXED_TABLES) #define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] = b(e) #define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] = { b(e), b(f), b(g), b(h) } EXTERN ALIGN CONST uint_32t t_dec(r,c)[RC_LENGTH] = rc_data(w0); #else #define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] #define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] EXTERN ALIGN CONST uint_32t t_dec(r,c)[RC_LENGTH]; #endif #if defined( SBX_SET ) d_1(uint_8t, t_dec(s,box), sb_data, h0); #endif #if defined( ISB_SET ) d_1(uint_8t, t_dec(i,box), isb_data, h0); #endif #if defined( FT1_SET ) d_1(uint_32t, t_dec(f,n), sb_data, u0); #endif #if defined( FT4_SET ) d_4(uint_32t, t_dec(f,n), sb_data, u0, u1, u2, u3); #endif #if defined( FL1_SET ) d_1(uint_32t, t_dec(f,l), sb_data, w0); #endif #if defined( FL4_SET ) d_4(uint_32t, t_dec(f,l), sb_data, w0, w1, w2, w3); #endif #if defined( IT1_SET ) d_1(uint_32t, t_dec(i,n), isb_data, v0); #endif #if defined( IT4_SET ) d_4(uint_32t, t_dec(i,n), isb_data, v0, v1, v2, v3); #endif #if defined( IL1_SET ) d_1(uint_32t, t_dec(i,l), isb_data, w0); #endif #if defined( IL4_SET ) d_4(uint_32t, t_dec(i,l), isb_data, w0, w1, w2, w3); #endif #if defined( LS1_SET ) #if defined( FL1_SET ) #undef LS1_SET #else d_1(uint_32t, t_dec(l,s), sb_data, w0); #endif #endif #if defined( LS4_SET ) #if defined( FL4_SET ) #undef LS4_SET #else d_4(uint_32t, t_dec(l,s), sb_data, w0, w1, w2, w3); #endif #endif #if defined( IM1_SET ) d_1(uint_32t, t_dec(i,m), mm_data, v0); #endif #if defined( IM4_SET ) d_4(uint_32t, t_dec(i,m), mm_data, v0, v1, v2, v3); #endif #endif pdns-3.3/pdns/aes/aescrypt.c0000644000014601777760000002407512136555572017320 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #include "aesopt.h" #include "aestab.h" #if defined(__cplusplus) extern "C" { #endif #define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c]) #define so(y,x,c) word_out(y, c, s(x,c)) #if defined(ARRAYS) #define locals(y,x) x[4],y[4] #else #define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3 #endif #define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \ s(y,2) = s(x,2); s(y,3) = s(x,3); #define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3) #define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3) #define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3) #if ( FUNCS_IN_C & ENCRYPTION_IN_C ) /* Visual C++ .Net v7.1 provides the fastest encryption code when using Pentium optimiation with small code but this is poor for decryption so we need to control this with the following VC++ pragmas */ #if defined( _MSC_VER ) && !defined( _WIN64 ) #pragma optimize( "s", on ) #endif /* Given the column (c) of the output state variable, the following macros give the input state variables which are needed in its computation for each row (r) of the state. All the alternative macros give the same end values but expand into different ways of calculating these values. In particular the complex macro used for dynamically variable block sizes is designed to expand to a compile time constant whenever possible but will expand to conditional clauses on some branches (I am grateful to Frank Yellin for this construction) */ #define fwd_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ : r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\ : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))) #if defined(FT4_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c)) #elif defined(FT1_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c)) #else #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c))) #endif #if defined(FL4_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c)) #elif defined(FL1_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c)) #else #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c)) #endif AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) { uint_32t locals(b0, b1); const uint_32t *kp; #if defined( dec_fmvars ) dec_fmvars; /* declare variables for fwd_mcol() if needed */ #endif if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 ) return EXIT_FAILURE; kp = cx->ks; state_in(b0, in, kp); #if (ENC_UNROLL == FULL) switch(cx->inf.b[0]) { case 14 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 12 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 10 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); round(fwd_rnd, b1, b0, kp + 3 * N_COLS); round(fwd_rnd, b0, b1, kp + 4 * N_COLS); round(fwd_rnd, b1, b0, kp + 5 * N_COLS); round(fwd_rnd, b0, b1, kp + 6 * N_COLS); round(fwd_rnd, b1, b0, kp + 7 * N_COLS); round(fwd_rnd, b0, b1, kp + 8 * N_COLS); round(fwd_rnd, b1, b0, kp + 9 * N_COLS); round(fwd_lrnd, b0, b1, kp +10 * N_COLS); } #else #if (ENC_UNROLL == PARTIAL) { uint_32t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) { kp += N_COLS; round(fwd_rnd, b1, b0, kp); kp += N_COLS; round(fwd_rnd, b0, b1, kp); } kp += N_COLS; round(fwd_rnd, b1, b0, kp); #else { uint_32t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) { kp += N_COLS; round(fwd_rnd, b1, b0, kp); l_copy(b0, b1); } #endif kp += N_COLS; round(fwd_lrnd, b0, b1, kp); } #endif state_out(out, b0); return EXIT_SUCCESS; } #endif #if ( FUNCS_IN_C & DECRYPTION_IN_C) /* Visual C++ .Net v7.1 provides the fastest encryption code when using Pentium optimiation with small code but this is poor for decryption so we need to control this with the following VC++ pragmas */ #if defined( _MSC_VER ) && !defined( _WIN64 ) #pragma optimize( "t", on ) #endif /* Given the column (c) of the output state variable, the following macros give the input state variables which are needed in its computation for each row (r) of the state. All the alternative macros give the same end values but expand into different ways of calculating these values. In particular the complex macro used for dynamically variable block sizes is designed to expand to a compile time constant whenever possible but will expand to conditional clauses on some branches (I am grateful to Frank Yellin for this construction) */ #define inv_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ : r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\ : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))) #if defined(IT4_SET) #undef dec_imvars #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c)) #elif defined(IT1_SET) #undef dec_imvars #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c)) #else #define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))) #endif #if defined(IL4_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c)) #elif defined(IL1_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c)) #else #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)) #endif /* This code can work with the decryption key schedule in the */ /* order that is used for encrytpion (where the 1st decryption */ /* round key is at the high end ot the schedule) or with a key */ /* schedule that has been reversed to put the 1st decryption */ /* round key at the low end of the schedule in memory (when */ /* AES_REV_DKS is defined) */ #ifdef AES_REV_DKS #define key_ofs 0 #define rnd_key(n) (kp + n * N_COLS) #else #define key_ofs 1 #define rnd_key(n) (kp - n * N_COLS) #endif AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) { uint_32t locals(b0, b1); #if defined( dec_imvars ) dec_imvars; /* declare variables for inv_mcol() if needed */ #endif const uint_32t *kp; if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 ) return EXIT_FAILURE; kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0); state_in(b0, in, kp); #if (DEC_UNROLL == FULL) kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2)); switch(cx->inf.b[0]) { case 14 * 16: round(inv_rnd, b1, b0, rnd_key(-13)); round(inv_rnd, b0, b1, rnd_key(-12)); case 12 * 16: round(inv_rnd, b1, b0, rnd_key(-11)); round(inv_rnd, b0, b1, rnd_key(-10)); case 10 * 16: round(inv_rnd, b1, b0, rnd_key(-9)); round(inv_rnd, b0, b1, rnd_key(-8)); round(inv_rnd, b1, b0, rnd_key(-7)); round(inv_rnd, b0, b1, rnd_key(-6)); round(inv_rnd, b1, b0, rnd_key(-5)); round(inv_rnd, b0, b1, rnd_key(-4)); round(inv_rnd, b1, b0, rnd_key(-3)); round(inv_rnd, b0, b1, rnd_key(-2)); round(inv_rnd, b1, b0, rnd_key(-1)); round(inv_lrnd, b0, b1, rnd_key( 0)); } #else #if (DEC_UNROLL == PARTIAL) { uint_32t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd) { kp = rnd_key(1); round(inv_rnd, b1, b0, kp); kp = rnd_key(1); round(inv_rnd, b0, b1, kp); } kp = rnd_key(1); round(inv_rnd, b1, b0, kp); #else { uint_32t rnd; for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd) { kp = rnd_key(1); round(inv_rnd, b1, b0, kp); l_copy(b0, b1); } #endif kp = rnd_key(1); round(inv_lrnd, b0, b1, kp); } #endif state_out(out, b0); return EXIT_SUCCESS; } #endif #if defined(__cplusplus) } #endif pdns-3.3/pdns/aes/aes.h0000644000014601777760000001640512136555572016241 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the definitions required to use AES in C. See aesopt.h for optimisation details. */ #ifndef _AES_H #define _AES_H #include /* This include is used to find 8 & 32 bit unsigned integer types */ #include "brg_types.h" #if defined(__cplusplus) extern "C" { #endif #define AES_128 /* if a fast 128 bit key scheduler is needed */ #define AES_192 /* if a fast 192 bit key scheduler is needed */ #define AES_256 /* if a fast 256 bit key scheduler is needed */ #define AES_VAR /* if variable key size scheduler is needed */ #define AES_MODES /* if support is needed for modes */ /* The following must also be set in assembler files if being used */ #define AES_ENCRYPT /* if support for encryption is needed */ #define AES_DECRYPT /* if support for decryption is needed */ #define AES_REV_DKS /* define to reverse decryption key schedule */ #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ #define N_COLS 4 /* the number of columns in the state */ /* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ /* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ /* or 44, 52 or 60 32-bit words. */ #if defined( AES_VAR ) || defined( AES_256 ) #define KS_LENGTH 60 #elif defined( AES_192 ) #define KS_LENGTH 52 #else #define KS_LENGTH 44 #endif #define AES_RETURN INT_RETURN /* the character array 'inf' in the following structures is used */ /* to hold AES context information. This AES code uses cx->inf.b[0] */ /* to hold the number of rounds multiplied by 16. The other three */ /* elements can be used by code that implements additional modes */ typedef union { uint_32t l; uint_8t b[4]; } aes_inf; typedef struct { uint_32t ks[KS_LENGTH]; aes_inf inf; } aes_encrypt_ctx; typedef struct { uint_32t ks[KS_LENGTH]; aes_inf inf; } aes_decrypt_ctx; /* This routine must be called before first use if non-static */ /* tables are being used */ AES_RETURN aes_init(void); /* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ /* those in the range 128 <= key_len <= 256 are given in bits */ #if defined( AES_ENCRYPT ) #if defined( AES_128 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_192 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_256 ) || defined( AES_VAR) AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined( AES_VAR ) AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]); #endif AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); #endif #if defined( AES_DECRYPT ) #if defined( AES_128 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_192 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_256 ) || defined( AES_VAR) AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined( AES_VAR ) AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]); #endif AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); #endif #if defined( AES_MODES ) /* Multiple calls to the following subroutines for multiple block */ /* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */ /* long messages incremantally provided that the context AND the iv */ /* are preserved between all such calls. For the ECB and CBC modes */ /* each individual call within a series of incremental calls must */ /* process only full blocks (i.e. len must be a multiple of 16) but */ /* the CFB, OFB and CTR mode calls can handle multiple incremental */ /* calls of any length. Each mode is reset when a new AES key is */ /* set but ECB and CBC operations can be reset without setting a */ /* new key by setting a new IV value. To reset CFB, OFB and CTR */ /* without setting the key, aes_mode_reset() must be called and the */ /* IV must be set. NOTE: All these calls update the IV on exit so */ /* this has to be reset if a new operation with the same IV as the */ /* previous one is required (or decryption follows encryption with */ /* the same IV array). */ AES_RETURN aes_test_alignment_detection(unsigned int n); AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx cx[1]); AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx cx[1]); AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx cx[1]); AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_decrypt_ctx cx[1]); AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]); AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); #define aes_ofb_encrypt aes_ofb_crypt #define aes_ofb_decrypt aes_ofb_crypt AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx cx[1]); typedef void cbuf_inc(unsigned char *cbuf); #define aes_ctr_encrypt aes_ctr_crypt #define aes_ctr_decrypt aes_ctr_crypt AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]); #endif #if defined(__cplusplus) } #endif #endif pdns-3.3/pdns/aes/aescpp.h0000644000014601777760000001203112136555572016733 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the definitions required to use AES (Rijndael) in C++. */ #ifndef _AESCPP_H #define _AESCPP_H #include "aes.h" #if defined( AES_ENCRYPT ) class AESencrypt { public: aes_encrypt_ctx cx[1]; AESencrypt(void) { aes_init(); }; #if defined(AES_128) AESencrypt(const unsigned char key[]) { aes_encrypt_key128(key, cx); } AES_RETURN key128(const unsigned char key[]) { return aes_encrypt_key128(key, cx); } #endif #if defined(AES_192) AES_RETURN key192(const unsigned char key[]) { return aes_encrypt_key192(key, cx); } #endif #if defined(AES_256) AES_RETURN key256(const unsigned char key[]) { return aes_encrypt_key256(key, cx); } #endif #if defined(AES_VAR) AES_RETURN key(const unsigned char key[], int key_len) { return aes_encrypt_key(key, key_len, cx); } #endif AES_RETURN encrypt(const unsigned char in[], unsigned char out[]) const { return aes_encrypt(in, out, cx); } #ifndef AES_MODES AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const { while(nb--) { aes_encrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } } #endif #ifdef AES_MODES AES_RETURN mode_reset(void) { return aes_mode_reset(cx); } AES_RETURN ecb_encrypt(const unsigned char in[], unsigned char out[], int nb) const { return aes_ecb_encrypt(in, out, nb, cx); } AES_RETURN cbc_encrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) const { return aes_cbc_encrypt(in, out, nb, iv, cx); } AES_RETURN cfb_encrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_cfb_encrypt(in, out, nb, iv, cx); } AES_RETURN cfb_decrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_cfb_decrypt(in, out, nb, iv, cx); } AES_RETURN ofb_crypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) { return aes_ofb_crypt(in, out, nb, iv, cx); } typedef void ctr_fn(unsigned char ctr[]); AES_RETURN ctr_crypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[], ctr_fn cf) { return aes_ctr_crypt(in, out, nb, iv, cf, cx); } #endif }; #endif #if defined( AES_DECRYPT ) class AESdecrypt { public: aes_decrypt_ctx cx[1]; AESdecrypt(void) { aes_init(); }; #if defined(AES_128) AESdecrypt(const unsigned char key[]) { aes_decrypt_key128(key, cx); } AES_RETURN key128(const unsigned char key[]) { return aes_decrypt_key128(key, cx); } #endif #if defined(AES_192) AES_RETURN key192(const unsigned char key[]) { return aes_decrypt_key192(key, cx); } #endif #if defined(AES_256) AES_RETURN key256(const unsigned char key[]) { return aes_decrypt_key256(key, cx); } #endif #if defined(AES_VAR) AES_RETURN key(const unsigned char key[], int key_len) { return aes_decrypt_key(key, key_len, cx); } #endif AES_RETURN decrypt(const unsigned char in[], unsigned char out[]) const { return aes_decrypt(in, out, cx); } #ifndef AES_MODES AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const { while(nb--) { aes_decrypt(in, out, cx), in += AES_BLOCK_SIZE, out += AES_BLOCK_SIZE; } } #endif #ifdef AES_MODES AES_RETURN ecb_decrypt(const unsigned char in[], unsigned char out[], int nb) const { return aes_ecb_decrypt(in, out, nb, cx); } AES_RETURN cbc_decrypt(const unsigned char in[], unsigned char out[], int nb, unsigned char iv[]) const { return aes_cbc_decrypt(in, out, nb, iv, cx); } #endif }; #endif #endif pdns-3.3/pdns/aes/brg_types.h0000644000014601777760000001755212136555572017473 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 The unsigned integer types defined here are of the form uint_t where is the length of the type; for example, the unsigned 32-bit type is 'uint_32t'. These are NOT the same as the 'C99 integer types' that are defined in the inttypes.h and stdint.h headers since attempts to use these types have shown that support for them is still highly variable. However, since the latter are of the form uint_t, a regular expression search and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t') can be used to convert the types used here to the C99 standard types. */ #ifndef _BRG_TYPES_H #define _BRG_TYPES_H #if defined(__cplusplus) extern "C" { #endif #include #if defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) # include # define ptrint_t intptr_t #elif defined( __GNUC__ ) && ( __GNUC__ >= 3 ) # include # define ptrint_t intptr_t #else # define ptrint_t int #endif #ifndef BRG_UI8 # define BRG_UI8 # if UCHAR_MAX == 255u typedef unsigned char uint_8t; # else # error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h # endif #endif #ifndef BRG_UI16 # define BRG_UI16 # if USHRT_MAX == 65535u typedef unsigned short uint_16t; # else # error Please define uint_16t as a 16-bit unsigned short type in brg_types.h # endif #endif #ifndef BRG_UI32 # define BRG_UI32 # if UINT_MAX == 4294967295u # define li_32(h) 0x##h##u typedef unsigned int uint_32t; # elif ULONG_MAX == 4294967295u # define li_32(h) 0x##h##ul typedef unsigned long uint_32t; # elif defined( _CRAY ) # error This code needs 32-bit data types, which Cray machines do not provide # else # error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h # endif #endif #ifndef BRG_UI64 # if defined( __BORLANDC__ ) && !defined( __MSDOS__ ) # define BRG_UI64 # define li_64(h) 0x##h##ui64 typedef unsigned __int64 uint_64t; # elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */ # define BRG_UI64 # define li_64(h) 0x##h##ui64 typedef unsigned __int64 uint_64t; # elif defined( __sun ) && defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful # define BRG_UI64 # define li_64(h) 0x##h##ull typedef unsigned long long uint_64t; # elif defined( __MVS__ ) # define BRG_UI64 # define li_64(h) 0x##h##ull typedef unsigned int long long uint_64t; # elif defined( UINT_MAX ) && UINT_MAX > 4294967295u # if UINT_MAX == 18446744073709551615u # define BRG_UI64 # define li_64(h) 0x##h##u typedef unsigned int uint_64t; # endif # elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u # if ULONG_MAX == 18446744073709551615ul # define BRG_UI64 # define li_64(h) 0x##h##ul typedef unsigned long uint_64t; # endif # elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u # if ULLONG_MAX == 18446744073709551615ull # define BRG_UI64 # define li_64(h) 0x##h##ull typedef unsigned long long uint_64t; # endif # elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u # if ULONG_LONG_MAX == 18446744073709551615ull # define BRG_UI64 # define li_64(h) 0x##h##ull typedef unsigned long long uint_64t; # endif # endif #endif #if !defined( BRG_UI64 ) # if defined( NEED_UINT_64T ) # error Please define uint_64t as an unsigned 64 bit type in brg_types.h # endif #endif #ifndef RETURN_VALUES # define RETURN_VALUES # if defined( DLL_EXPORT ) # if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) # define VOID_RETURN __declspec( dllexport ) void __stdcall # define INT_RETURN __declspec( dllexport ) int __stdcall # elif defined( __GNUC__ ) # define VOID_RETURN __declspec( __dllexport__ ) void # define INT_RETURN __declspec( __dllexport__ ) int # else # error Use of the DLL is only available on the Microsoft, Intel and GCC compilers # endif # elif defined( DLL_IMPORT ) # if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) # define VOID_RETURN __declspec( dllimport ) void __stdcall # define INT_RETURN __declspec( dllimport ) int __stdcall # elif defined( __GNUC__ ) # define VOID_RETURN __declspec( __dllimport__ ) void # define INT_RETURN __declspec( __dllimport__ ) int # else # error Use of the DLL is only available on the Microsoft, Intel and GCC compilers # endif # elif defined( __WATCOMC__ ) # define VOID_RETURN void __cdecl # define INT_RETURN int __cdecl # else # define VOID_RETURN void # define INT_RETURN int # endif #endif /* These defines are used to detect and set the memory alignment of pointers. Note that offsets are in bytes. ALIGN_OFFSET(x,n) return the positive or zero offset of the memory addressed by the pointer 'x' from an address that is aligned on an 'n' byte boundary ('n' is a power of 2) ALIGN_FLOOR(x,n) return a pointer that points to memory that is aligned on an 'n' byte boundary and is not higher than the memory address pointed to by 'x' ('n' is a power of 2) ALIGN_CEIL(x,n) return a pointer that points to memory that is aligned on an 'n' byte boundary and is not lower than the memory address pointed to by 'x' ('n' is a power of 2) */ #define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1)) #define ALIGN_FLOOR(x,n) ((uint_8t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1))) #define ALIGN_CEIL(x,n) ((uint_8t*)(x) + (-((ptrint_t)(x)) & ((n) - 1))) /* These defines are used to declare buffers in a way that allows faster operations on longer variables to be used. In all these defines 'size' must be a power of 2 and >= 8. NOTE that the buffer size is in bytes but the type length is in bits UNIT_TYPEDEF(x,size) declares a variable 'x' of length 'size' bits BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize' bytes defined as an array of variables each of 'size' bits (bsize must be a multiple of size / 8) UNIT_CAST(x,size) casts a variable to a type of length 'size' bits UPTR_CAST(x,size) casts a pointer to a pointer to a varaiable of length 'size' bits */ #define UI_TYPE(size) uint_##size##t #define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x #define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)] #define UNIT_CAST(x,size) ((UI_TYPE(size) )(x)) #define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x)) #if defined(__cplusplus) } #endif #endif pdns-3.3/pdns/aes/dns_random.cc0000644000014601777760000000310312153047714017733 0ustar00jenkinsnogroup00000000000000#include "aescpp.h" #include #include #include #include #include #include #include "dns_random.hh" using namespace std; static aes_encrypt_ctx g_cx; static unsigned char g_counter[16]; static uint32_t g_in; static bool g_initialized; void dns_random_init(const char data[16]) { aes_init(); aes_encrypt_key128((const unsigned char*)data, &g_cx); struct timeval now; gettimeofday(&now, 0); memcpy(g_counter, &now.tv_usec, sizeof(now.tv_usec)); memcpy(g_counter+sizeof(now.tv_usec), &now.tv_sec, sizeof(now.tv_sec)); g_in = getpid() | (getppid()<<16); g_initialized = true; srandom(dns_random(numeric_limits::max())); } static void counterIncrement(unsigned char* counter) { if(!++counter[0]) if(!++counter[1]) if(!++counter[2]) if(!++counter[3]) if(!++counter[4]) if(!++counter[5]) if(!++counter[6]) if(!++counter[7]) if(!++counter[8]) if(!++counter[9]) if(!++counter[10]) if(!++counter[11]) if(!++counter[12]) if(!++counter[13]) if(!++counter[14]) ++counter[15]; } unsigned int dns_random(unsigned int n) { if(!g_initialized) abort(); uint32_t out; aes_ctr_encrypt((unsigned char*) &g_in, (unsigned char*)& out, sizeof(g_in), g_counter, counterIncrement, &g_cx); return out % n; } #if 0 int main() { dns_random_init("0123456789abcdef"); for(int n = 0; n < 16; n++) cerr< #include #include "aesopt.h" #if defined( AES_MODES ) #if defined(__cplusplus) extern "C" { #endif #if defined( _MSC_VER ) && ( _MSC_VER > 800 ) #pragma intrinsic(memcpy) #endif #define BFR_BLOCKS 8 /* These values are used to detect long word alignment in order to */ /* speed up some buffer operations. This facility may not work on */ /* some machines so this define can be commented out if necessary */ #define FAST_BUFFER_OPERATIONS #define lp32(x) ((uint_32t*)(x)) #if defined( USE_VIA_ACE_IF_PRESENT ) #include "aes_via_ace.h" #pragma pack(16) aligned_array(unsigned long, enc_gen_table, 12, 16) = NEH_ENC_GEN_DATA; aligned_array(unsigned long, enc_load_table, 12, 16) = NEH_ENC_LOAD_DATA; aligned_array(unsigned long, enc_hybrid_table, 12, 16) = NEH_ENC_HYBRID_DATA; aligned_array(unsigned long, dec_gen_table, 12, 16) = NEH_DEC_GEN_DATA; aligned_array(unsigned long, dec_load_table, 12, 16) = NEH_DEC_LOAD_DATA; aligned_array(unsigned long, dec_hybrid_table, 12, 16) = NEH_DEC_HYBRID_DATA; /* NOTE: These control word macros must only be used after */ /* a key has been set up because they depend on key size */ #if NEH_KEY_TYPE == NEH_LOAD #define kd_adr(c) ((uint_8t*)(c)->ks) #elif NEH_KEY_TYPE == NEH_GENERATE #define kd_adr(c) ((uint_8t*)(c)->ks + (c)->inf.b[0]) #else #define kd_adr(c) ((uint_8t*)(c)->ks + ((c)->inf.b[0] == 160 ? 160 : 0)) #endif #else #define aligned_array(type, name, no, stride) type name[no] #define aligned_auto(type, name, no, stride) type name[no] #endif #if defined( _MSC_VER ) && _MSC_VER > 1200 #define via_cwd(cwd, ty, dir, len) \ unsigned long* cwd = (dir##_##ty##_table + ((len - 128) >> 4)) #else #define via_cwd(cwd, ty, dir, len) \ aligned_auto(unsigned long, cwd, 4, 16); \ cwd[1] = cwd[2] = cwd[3] = 0; \ cwd[0] = neh_##dir##_##ty##_key(len) #endif /* test the code for detecting and setting pointer alignment */ AES_RETURN aes_test_alignment_detection(unsigned int n) /* 4 <= n <= 16 */ { uint_8t p[16]; uint_32t i, count_eq = 0, count_neq = 0; if(n < 4 || n > 16) return EXIT_FAILURE; for(i = 0; i < n; ++i) { uint_8t *qf = ALIGN_FLOOR(p + i, n), *qh = ALIGN_CEIL(p + i, n); if(qh == qf) ++count_eq; else if(qh == qf + n) ++count_neq; else return EXIT_FAILURE; } return (count_eq != 1 || count_neq != n - 1 ? EXIT_FAILURE : EXIT_SUCCESS); } AES_RETURN aes_mode_reset(aes_encrypt_ctx ctx[1]) { ctx->inf.b[2] = 0; return EXIT_SUCCESS; } AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint_8t *ksp = (uint_8t*)(ctx->ks); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ecb_op5(ksp,cwd,ibuf,obuf,nb); } else { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ecb_op5(ksp,cwd,ip,op,m); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) while(nb--) { if(aes_encrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint_8t *ksp = kd_adr(ctx); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ecb_op5(ksp,cwd,ibuf,obuf,nb); } else { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ecb_op5(ksp,cwd,ip,op,m); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) while(nb--) { if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx ctx[1]) { int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint_8t *ksp = (uint_8t*)(ctx->ks), *ivp = iv; aligned_auto(uint_8t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) { via_cbc_op7(ksp,cwd,ibuf,obuf,nb,ivp,ivp); } else { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cbc_op7(ksp,cwd,ip,op,m,ivp,ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } if(iv != ivp) memcpy(iv, ivp, AES_BLOCK_SIZE); return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(nb--) { lp32(iv)[0] ^= lp32(ibuf)[0]; lp32(iv)[1] ^= lp32(ibuf)[1]; lp32(iv)[2] ^= lp32(ibuf)[2]; lp32(iv)[3] ^= lp32(ibuf)[3]; if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; memcpy(obuf, iv, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else # endif while(nb--) { iv[ 0] ^= ibuf[ 0]; iv[ 1] ^= ibuf[ 1]; iv[ 2] ^= ibuf[ 2]; iv[ 3] ^= ibuf[ 3]; iv[ 4] ^= ibuf[ 4]; iv[ 5] ^= ibuf[ 5]; iv[ 6] ^= ibuf[ 6]; iv[ 7] ^= ibuf[ 7]; iv[ 8] ^= ibuf[ 8]; iv[ 9] ^= ibuf[ 9]; iv[10] ^= ibuf[10]; iv[11] ^= ibuf[11]; iv[12] ^= ibuf[12]; iv[13] ^= ibuf[13]; iv[14] ^= ibuf[14]; iv[15] ^= ibuf[15]; if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; memcpy(obuf, iv, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_decrypt_ctx ctx[1]) { unsigned char tmp[AES_BLOCK_SIZE]; int nb = len >> 4; if(len & (AES_BLOCK_SIZE - 1)) return EXIT_FAILURE; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { uint_8t *ksp = kd_adr(ctx), *ivp = iv; aligned_auto(uint_8t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 ) && !ALIGN_OFFSET( iv, 16 )) { via_cbc_op6(ksp,cwd,ibuf,obuf,nb,ivp); } else { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { int m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb); ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cbc_op6(ksp,cwd,ip,op,m,ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; nb -= m; } } if(iv != ivp) memcpy(iv, ivp, AES_BLOCK_SIZE); return EXIT_SUCCESS; } #endif #if !defined( ASSUME_VIA_ACE_PRESENT ) # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(nb--) { memcpy(tmp, ibuf, AES_BLOCK_SIZE); if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] ^= lp32(iv)[0]; lp32(obuf)[1] ^= lp32(iv)[1]; lp32(obuf)[2] ^= lp32(iv)[2]; lp32(obuf)[3] ^= lp32(iv)[3]; memcpy(iv, tmp, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else # endif while(nb--) { memcpy(tmp, ibuf, AES_BLOCK_SIZE); if(aes_decrypt(ibuf, obuf, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] ^= iv[ 0]; obuf[ 1] ^= iv[ 1]; obuf[ 2] ^= iv[ 2]; obuf[ 3] ^= iv[ 3]; obuf[ 4] ^= iv[ 4]; obuf[ 5] ^= iv[ 5]; obuf[ 6] ^= iv[ 6]; obuf[ 7] ^= iv[ 7]; obuf[ 8] ^= iv[ 8]; obuf[ 9] ^= iv[ 9]; obuf[10] ^= iv[10]; obuf[11] ^= iv[11]; obuf[12] ^= iv[12]; obuf[13] ^= iv[13]; obuf[14] ^= iv[14]; obuf[15] ^= iv[15]; memcpy(iv, tmp, AES_BLOCK_SIZE); ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } #endif return EXIT_SUCCESS; } AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { while(b_pos < AES_BLOCK_SIZE && cnt < len) *obuf++ = iv[b_pos++] ^= *ibuf++, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint_8t *ksp = (uint_8t*)(ctx->ks), *ivp = iv; aligned_auto(uint_8t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_cfb_op7(ksp, cwd, ibuf, obuf, nb, ivp, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cfb_op7(ksp, cwd, ip, op, m, ivp, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] = lp32(iv)[0] ^= lp32(ibuf)[0]; lp32(obuf)[1] = lp32(iv)[1] ^= lp32(ibuf)[1]; lp32(obuf)[2] = lp32(iv)[2] ^= lp32(ibuf)[2]; lp32(obuf)[3] = lp32(iv)[3] ^= lp32(ibuf)[3]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] = iv[ 0] ^= ibuf[ 0]; obuf[ 1] = iv[ 1] ^= ibuf[ 1]; obuf[ 2] = iv[ 2] ^= ibuf[ 2]; obuf[ 3] = iv[ 3] ^= ibuf[ 3]; obuf[ 4] = iv[ 4] ^= ibuf[ 4]; obuf[ 5] = iv[ 5] ^= ibuf[ 5]; obuf[ 6] = iv[ 6] ^= ibuf[ 6]; obuf[ 7] = iv[ 7] ^= ibuf[ 7]; obuf[ 8] = iv[ 8] ^= ibuf[ 8]; obuf[ 9] = iv[ 9] ^= ibuf[ 9]; obuf[10] = iv[10] ^= ibuf[10]; obuf[11] = iv[11] ^= ibuf[11]; obuf[12] = iv[12] ^= ibuf[12]; obuf[13] = iv[13] ^= ibuf[13]; obuf[14] = iv[14] ^= ibuf[14]; obuf[15] = iv[15] ^= ibuf[15]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) *obuf++ = iv[b_pos++] ^= *ibuf++, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = b_pos; return EXIT_SUCCESS; } AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { uint_8t t; while(b_pos < AES_BLOCK_SIZE && cnt < len) t = *ibuf++, *obuf++ = t ^ iv[b_pos], iv[b_pos++] = t, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint_8t *ksp = (uint_8t*)(ctx->ks), *ivp = iv; aligned_auto(uint_8t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, dec, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_cfb_op6(ksp, cwd, ibuf, obuf, nb, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) /* input buffer is not aligned */ memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_cfb_op6(ksp, cwd, ip, op, m, ivp); if(op != obuf) /* output buffer is not aligned */ memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) &&!ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { uint_32t t; assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; t = lp32(ibuf)[0], lp32(obuf)[0] = t ^ lp32(iv)[0], lp32(iv)[0] = t; t = lp32(ibuf)[1], lp32(obuf)[1] = t ^ lp32(iv)[1], lp32(iv)[1] = t; t = lp32(ibuf)[2], lp32(obuf)[2] = t ^ lp32(iv)[2], lp32(iv)[2] = t; t = lp32(ibuf)[3], lp32(obuf)[3] = t ^ lp32(iv)[3], lp32(iv)[3] = t; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { uint_8t t; assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; t = ibuf[ 0], obuf[ 0] = t ^ iv[ 0], iv[ 0] = t; t = ibuf[ 1], obuf[ 1] = t ^ iv[ 1], iv[ 1] = t; t = ibuf[ 2], obuf[ 2] = t ^ iv[ 2], iv[ 2] = t; t = ibuf[ 3], obuf[ 3] = t ^ iv[ 3], iv[ 3] = t; t = ibuf[ 4], obuf[ 4] = t ^ iv[ 4], iv[ 4] = t; t = ibuf[ 5], obuf[ 5] = t ^ iv[ 5], iv[ 5] = t; t = ibuf[ 6], obuf[ 6] = t ^ iv[ 6], iv[ 6] = t; t = ibuf[ 7], obuf[ 7] = t ^ iv[ 7], iv[ 7] = t; t = ibuf[ 8], obuf[ 8] = t ^ iv[ 8], iv[ 8] = t; t = ibuf[ 9], obuf[ 9] = t ^ iv[ 9], iv[ 9] = t; t = ibuf[10], obuf[10] = t ^ iv[10], iv[10] = t; t = ibuf[11], obuf[11] = t ^ iv[11], iv[11] = t; t = ibuf[12], obuf[12] = t ^ iv[12], iv[12] = t; t = ibuf[13], obuf[13] = t ^ iv[13], iv[13] = t; t = ibuf[14], obuf[14] = t ^ iv[14], iv[14] = t; t = ibuf[15], obuf[15] = t ^ iv[15], iv[15] = t; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { uint_8t t; if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) t = *ibuf++, *obuf++ = t ^ iv[b_pos], iv[b_pos++] = t, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = b_pos; return EXIT_SUCCESS; } AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, aes_encrypt_ctx ctx[1]) { int cnt = 0, b_pos = (int)ctx->inf.b[2], nb; if(b_pos) /* complete any partial block */ { while(b_pos < AES_BLOCK_SIZE && cnt < len) *obuf++ = iv[b_pos++] ^ *ibuf++, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } if((nb = (len - cnt) >> 4) != 0) /* process whole blocks */ { #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { int m; uint_8t *ksp = (uint_8t*)(ctx->ks), *ivp = iv; aligned_auto(uint_8t, liv, AES_BLOCK_SIZE, 16); via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); if(ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; if(ALIGN_OFFSET( iv, 16 )) /* ensure an aligned iv */ { ivp = liv; memcpy(liv, iv, AES_BLOCK_SIZE); } if(!ALIGN_OFFSET( ibuf, 16 ) && !ALIGN_OFFSET( obuf, 16 )) { via_ofb_op6(ksp, cwd, ibuf, obuf, nb, ivp); ibuf += nb * AES_BLOCK_SIZE; obuf += nb * AES_BLOCK_SIZE; cnt += nb * AES_BLOCK_SIZE; } else /* input, output or both are unaligned */ { aligned_auto(uint_8t, buf, BFR_BLOCKS * AES_BLOCK_SIZE, 16); uint_8t *ip, *op; while(nb) { m = (nb > BFR_BLOCKS ? BFR_BLOCKS : nb), nb -= m; ip = (ALIGN_OFFSET( ibuf, 16 ) ? buf : ibuf); op = (ALIGN_OFFSET( obuf, 16 ) ? buf : obuf); if(ip != ibuf) memcpy(buf, ibuf, m * AES_BLOCK_SIZE); via_ofb_op6(ksp, cwd, ip, op, m, ivp); if(op != obuf) memcpy(obuf, buf, m * AES_BLOCK_SIZE); ibuf += m * AES_BLOCK_SIZE; obuf += m * AES_BLOCK_SIZE; cnt += m * AES_BLOCK_SIZE; } } if(ivp != iv) memcpy(iv, ivp, AES_BLOCK_SIZE); } #else # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( iv, 4 )) while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; lp32(obuf)[0] = lp32(iv)[0] ^ lp32(ibuf)[0]; lp32(obuf)[1] = lp32(iv)[1] ^ lp32(ibuf)[1]; lp32(obuf)[2] = lp32(iv)[2] ^ lp32(ibuf)[2]; lp32(obuf)[3] = lp32(iv)[3] ^ lp32(ibuf)[3]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } else # endif while(cnt + AES_BLOCK_SIZE <= len) { assert(b_pos == 0); if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; obuf[ 0] = iv[ 0] ^ ibuf[ 0]; obuf[ 1] = iv[ 1] ^ ibuf[ 1]; obuf[ 2] = iv[ 2] ^ ibuf[ 2]; obuf[ 3] = iv[ 3] ^ ibuf[ 3]; obuf[ 4] = iv[ 4] ^ ibuf[ 4]; obuf[ 5] = iv[ 5] ^ ibuf[ 5]; obuf[ 6] = iv[ 6] ^ ibuf[ 6]; obuf[ 7] = iv[ 7] ^ ibuf[ 7]; obuf[ 8] = iv[ 8] ^ ibuf[ 8]; obuf[ 9] = iv[ 9] ^ ibuf[ 9]; obuf[10] = iv[10] ^ ibuf[10]; obuf[11] = iv[11] ^ ibuf[11]; obuf[12] = iv[12] ^ ibuf[12]; obuf[13] = iv[13] ^ ibuf[13]; obuf[14] = iv[14] ^ ibuf[14]; obuf[15] = iv[15] ^ ibuf[15]; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; cnt += AES_BLOCK_SIZE; } #endif } while(cnt < len) { if(!b_pos && aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(cnt < len && b_pos < AES_BLOCK_SIZE) *obuf++ = iv[b_pos++] ^ *ibuf++, cnt++; b_pos = (b_pos == AES_BLOCK_SIZE ? 0 : b_pos); } ctx->inf.b[2] = b_pos; return EXIT_SUCCESS; } #define BFR_LENGTH (BFR_BLOCKS * AES_BLOCK_SIZE) AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx ctx[1]) { uint_8t *ip; int i, blen, b_pos = (int)(ctx->inf.b[2]); #if defined( USE_VIA_ACE_IF_PRESENT ) aligned_auto(uint_8t, buf, BFR_LENGTH, 16); if(ctx->inf.b[1] == 0xff && ALIGN_OFFSET( ctx, 16 )) return EXIT_FAILURE; #else uint_8t buf[BFR_LENGTH]; #endif if(b_pos) { memcpy(buf, cbuf, AES_BLOCK_SIZE); if(aes_ecb_encrypt(buf, buf, AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; while(b_pos < AES_BLOCK_SIZE && len) *obuf++ = *ibuf++ ^ buf[b_pos++], --len; if(len) ctr_inc(cbuf), b_pos = 0; } while(len) { blen = (len > BFR_LENGTH ? BFR_LENGTH : len), len -= blen; for(i = 0, ip = buf; i < (blen >> 4); ++i) { memcpy(ip, cbuf, AES_BLOCK_SIZE); ctr_inc(cbuf); ip += AES_BLOCK_SIZE; } if(blen & (AES_BLOCK_SIZE - 1)) memcpy(ip, cbuf, AES_BLOCK_SIZE), i++; #if defined( USE_VIA_ACE_IF_PRESENT ) if(ctx->inf.b[1] == 0xff) { via_cwd(cwd, hybrid, enc, 2 * ctx->inf.b[0] - 192); via_ecb_op5((ctx->ks),cwd,buf,buf,i); } else #endif if(aes_ecb_encrypt(buf, buf, i * AES_BLOCK_SIZE, ctx) != EXIT_SUCCESS) return EXIT_FAILURE; i = 0; ip = buf; # ifdef FAST_BUFFER_OPERATIONS if(!ALIGN_OFFSET( ibuf, 4 ) && !ALIGN_OFFSET( obuf, 4 ) && !ALIGN_OFFSET( ip, 4 )) while(i + AES_BLOCK_SIZE <= blen) { lp32(obuf)[0] = lp32(ibuf)[0] ^ lp32(ip)[0]; lp32(obuf)[1] = lp32(ibuf)[1] ^ lp32(ip)[1]; lp32(obuf)[2] = lp32(ibuf)[2] ^ lp32(ip)[2]; lp32(obuf)[3] = lp32(ibuf)[3] ^ lp32(ip)[3]; i += AES_BLOCK_SIZE; ip += AES_BLOCK_SIZE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } else #endif while(i + AES_BLOCK_SIZE <= blen) { obuf[ 0] = ibuf[ 0] ^ ip[ 0]; obuf[ 1] = ibuf[ 1] ^ ip[ 1]; obuf[ 2] = ibuf[ 2] ^ ip[ 2]; obuf[ 3] = ibuf[ 3] ^ ip[ 3]; obuf[ 4] = ibuf[ 4] ^ ip[ 4]; obuf[ 5] = ibuf[ 5] ^ ip[ 5]; obuf[ 6] = ibuf[ 6] ^ ip[ 6]; obuf[ 7] = ibuf[ 7] ^ ip[ 7]; obuf[ 8] = ibuf[ 8] ^ ip[ 8]; obuf[ 9] = ibuf[ 9] ^ ip[ 9]; obuf[10] = ibuf[10] ^ ip[10]; obuf[11] = ibuf[11] ^ ip[11]; obuf[12] = ibuf[12] ^ ip[12]; obuf[13] = ibuf[13] ^ ip[13]; obuf[14] = ibuf[14] ^ ip[14]; obuf[15] = ibuf[15] ^ ip[15]; i += AES_BLOCK_SIZE; ip += AES_BLOCK_SIZE; ibuf += AES_BLOCK_SIZE; obuf += AES_BLOCK_SIZE; } while(i++ < blen) *obuf++ = *ibuf++ ^ ip[b_pos++]; } ctx->inf.b[2] = b_pos; return EXIT_SUCCESS; } #if defined(__cplusplus) } #endif #endif pdns-3.3/pdns/aes/brg_endian.h0000644000014601777760000001251412136555572017556 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #ifndef _BRG_ENDIAN_H #define _BRG_ENDIAN_H #define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ #define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ /* Include files where endian defines and byteswap functions may reside */ #if defined( __sun ) # include #elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) # include #elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \ defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) # include #elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) # if !defined( __MINGW32__ ) && !defined( _AIX ) # include # if !defined( __BEOS__ ) # include # endif # endif #endif /* Now attempt to set the define for platform byte order using any */ /* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */ /* seem to encompass most endian symbol definitions */ #if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN ) # if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN ) # if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( _BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( _LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN ) # if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( __BIG_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( __LITTLE_ENDIAN ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif #if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ ) # if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__ # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN # elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__ # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN # endif #elif defined( __BIG_ENDIAN__ ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif defined( __LITTLE_ENDIAN__ ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #endif /* if the platform byte order could not be determined, then try to */ /* set this define using common machine defines */ #if !defined(PLATFORM_BYTE_ORDER) #if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ defined( vax ) || defined( vms ) || defined( VMS ) || \ defined( __VMS ) || defined( _M_X64 ) # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \ defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX ) # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #elif 0 /* **** EDIT HERE IF NECESSARY **** */ # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN #elif 0 /* **** EDIT HERE IF NECESSARY **** */ # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN #else # error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order #endif #endif #endif pdns-3.3/pdns/aes/aesopt.h0000644000014601777760000006451212136555572016766 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the compilation options for AES (Rijndael) and code that is common across encryption, key scheduling and table generation. OPERATION These source code files implement the AES algorithm Rijndael designed by Joan Daemen and Vincent Rijmen. This version is designed for the standard block size of 16 bytes and for key sizes of 128, 192 and 256 bits (16, 24 and 32 bytes). This version is designed for flexibility and speed using operations on 32-bit words rather than operations on bytes. It can be compiled with either big or little endian internal byte order but is faster when the native byte order for the processor is used. THE CIPHER INTERFACE The cipher interface is implemented as an array of bytes in which lower AES bit sequence indexes map to higher numeric significance within bytes. uint_8t (an unsigned 8-bit type) uint_32t (an unsigned 32-bit type) struct aes_encrypt_ctx (structure for the cipher encryption context) struct aes_decrypt_ctx (structure for the cipher decryption context) AES_RETURN the function return type C subroutine calls: AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); IMPORTANT NOTE: If you are using this C interface with dynamic tables make sure that you call aes_init() before AES is used so that the tables are initialised. C++ aes class subroutines: Class AESencrypt for encryption Construtors: AESencrypt(void) AESencrypt(const unsigned char *key) - 128 bit key Members: AES_RETURN key128(const unsigned char *key) AES_RETURN key192(const unsigned char *key) AES_RETURN key256(const unsigned char *key) AES_RETURN encrypt(const unsigned char *in, unsigned char *out) const Class AESdecrypt for encryption Construtors: AESdecrypt(void) AESdecrypt(const unsigned char *key) - 128 bit key Members: AES_RETURN key128(const unsigned char *key) AES_RETURN key192(const unsigned char *key) AES_RETURN key256(const unsigned char *key) AES_RETURN decrypt(const unsigned char *in, unsigned char *out) const */ #if !defined( _AESOPT_H ) #define _AESOPT_H #if defined( __cplusplus ) #include "aescpp.h" #else #include "aes.h" #endif /* PLATFORM SPECIFIC INCLUDES */ #include "brg_endian.h" /* CONFIGURATION - THE USE OF DEFINES Later in this section there are a number of defines that control the operation of the code. In each section, the purpose of each define is explained so that the relevant form can be included or excluded by setting either 1's or 0's respectively on the branches of the related #if clauses. The following local defines should not be changed. */ #define ENCRYPTION_IN_C 1 #define DECRYPTION_IN_C 2 #define ENC_KEYING_IN_C 4 #define DEC_KEYING_IN_C 8 #define NO_TABLES 0 #define ONE_TABLE 1 #define FOUR_TABLES 4 #define NONE 0 #define PARTIAL 1 #define FULL 2 /* --- START OF USER CONFIGURED OPTIONS --- */ /* 1. BYTE ORDER WITHIN 32 BIT WORDS The fundamental data processing units in Rijndael are 8-bit bytes. The input, output and key input are all enumerated arrays of bytes in which bytes are numbered starting at zero and increasing to one less than the number of bytes in the array in question. This enumeration is only used for naming bytes and does not imply any adjacency or order relationship from one byte to another. When these inputs and outputs are considered as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte. In this implementation bits are numbered from 0 to 7 starting at the numerically least significant end of each byte (bit n represents 2^n). However, Rijndael can be implemented more efficiently using 32-bit words by packing bytes into words so that bytes 4*n to 4*n+3 are placed into word[n]. While in principle these bytes can be assembled into words in any positions, this implementation only supports the two formats in which bytes in adjacent positions within words also have adjacent byte numbers. This order is called big-endian if the lowest numbered bytes in words have the highest numeric significance and little-endian if the opposite applies. This code can work in either order irrespective of the order used by the machine on which it runs. Normally the internal byte order will be set to the order of the processor on which the code is to be run but this define can be used to reverse this in special situations WARNING: Assembler code versions rely on PLATFORM_BYTE_ORDER being set. This define will hence be redefined later (in section 4) if necessary */ #if 1 # define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER #elif 0 # define ALGORITHM_BYTE_ORDER IS_LITTLE_ENDIAN #elif 0 # define ALGORITHM_BYTE_ORDER IS_BIG_ENDIAN #else # error The algorithm byte order is not defined #endif /* 2. VIA ACE SUPPORT */ #if defined( __GNUC__ ) && defined( __i386__ ) \ || defined( _WIN32 ) && defined( _M_IX86 ) \ && !(defined( _WIN64 ) || defined( _WIN32_WCE ) || defined( _MSC_VER ) && ( _MSC_VER <= 800 )) # define VIA_ACE_POSSIBLE #endif /* Define this option if support for the VIA ACE is required. This uses inline assembler instructions and is only implemented for the Microsoft, Intel and GCC compilers. If VIA ACE is known to be present, then defining ASSUME_VIA_ACE_PRESENT will remove the ordinary encryption/decryption code. If USE_VIA_ACE_IF_PRESENT is defined then VIA ACE will be used if it is detected (both present and enabled) but the normal AES code will also be present. When VIA ACE is to be used, all AES encryption contexts MUST be 16 byte aligned; other input/output buffers do not need to be 16 byte aligned but there are very large performance gains if this can be arranged. VIA ACE also requires the decryption key schedule to be in reverse order (which later checks below ensure). */ #if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( USE_VIA_ACE_IF_PRESENT ) # define USE_VIA_ACE_IF_PRESENT #endif #if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( ASSUME_VIA_ACE_PRESENT ) # define ASSUME_VIA_ACE_PRESENT # endif /* 3. ASSEMBLER SUPPORT This define (which can be on the command line) enables the use of the assembler code routines for encryption, decryption and key scheduling as follows: ASM_X86_V1C uses the assembler (aes_x86_v1.asm) with large tables for encryption and decryption and but with key scheduling in C ASM_X86_V2 uses assembler (aes_x86_v2.asm) with compressed tables for encryption, decryption and key scheduling ASM_X86_V2C uses assembler (aes_x86_v2.asm) with compressed tables for encryption and decryption and but with key scheduling in C ASM_AMD64_C uses assembler (aes_amd64.asm) with compressed tables for encryption and decryption and but with key scheduling in C Change one 'if 0' below to 'if 1' to select the version or define as a compilation option. */ #if 0 && !defined( ASM_X86_V1C ) # define ASM_X86_V1C #elif 0 && !defined( ASM_X86_V2 ) # define ASM_X86_V2 #elif 0 && !defined( ASM_X86_V2C ) # define ASM_X86_V2C #elif 0 && !defined( ASM_AMD64_C ) # define ASM_AMD64_C #endif #if (defined ( ASM_X86_V1C ) || defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) \ && !defined( _M_IX86 ) || defined( ASM_AMD64_C ) && !defined( _M_X64 ) # error Assembler code is only available for x86 and AMD64 systems #endif /* 4. FAST INPUT/OUTPUT OPERATIONS. On some machines it is possible to improve speed by transferring the bytes in the input and output arrays to and from the internal 32-bit variables by addressing these arrays as if they are arrays of 32-bit words. On some machines this will always be possible but there may be a large performance penalty if the byte arrays are not aligned on the normal word boundaries. On other machines this technique will lead to memory access errors when such 32-bit word accesses are not properly aligned. The option SAFE_IO avoids such problems but will often be slower on those machines that support misaligned access (especially so if care is taken to align the input and output byte arrays on 32-bit word boundaries). If SAFE_IO is not defined it is assumed that access to byte arrays as if they are arrays of 32-bit words will not cause problems when such accesses are misaligned. */ #if 1 && !defined( _MSC_VER ) # define SAFE_IO #endif /* 5. LOOP UNROLLING The code for encryption and decrytpion cycles through a number of rounds that can be implemented either in a loop or by expanding the code into a long sequence of instructions, the latter producing a larger program but one that will often be much faster. The latter is called loop unrolling. There are also potential speed advantages in expanding two iterations in a loop with half the number of iterations, which is called partial loop unrolling. The following options allow partial or full loop unrolling to be set independently for encryption and decryption */ #if 1 # define ENC_UNROLL FULL #elif 0 # define ENC_UNROLL PARTIAL #else # define ENC_UNROLL NONE #endif #if 1 # define DEC_UNROLL FULL #elif 0 # define DEC_UNROLL PARTIAL #else # define DEC_UNROLL NONE #endif #if 1 # define ENC_KS_UNROLL #endif #if 1 # define DEC_KS_UNROLL #endif /* 6. FAST FINITE FIELD OPERATIONS If this section is included, tables are used to provide faster finite field arithmetic (this has no effect if FIXED_TABLES is defined). */ #if 1 # define FF_TABLES #endif /* 7. INTERNAL STATE VARIABLE FORMAT The internal state of Rijndael is stored in a number of local 32-bit word varaibles which can be defined either as an array or as individual names variables. Include this section if you want to store these local varaibles in arrays. Otherwise individual local variables will be used. */ #if 1 # define ARRAYS #endif /* 8. FIXED OR DYNAMIC TABLES When this section is included the tables used by the code are compiled statically into the binary file. Otherwise the subroutine aes_init() must be called to compute them before the code is first used. */ #if 1 && !(defined( _MSC_VER ) && ( _MSC_VER <= 800 )) # define FIXED_TABLES #endif /* 9. MASKING OR CASTING FROM LONGER VALUES TO BYTES In some systems it is better to mask longer values to extract bytes rather than using a cast. This option allows this choice. */ #if 0 # define to_byte(x) ((uint_8t)(x)) #else # define to_byte(x) ((x) & 0xff) #endif /* 10. TABLE ALIGNMENT On some sytsems speed will be improved by aligning the AES large lookup tables on particular boundaries. This define should be set to a power of two giving the desired alignment. It can be left undefined if alignment is not needed. This option is specific to the Microsft VC++ compiler - it seems to sometimes cause trouble for the VC++ version 6 compiler. */ #if 1 && defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) # define TABLE_ALIGN 32 #endif /* 11. REDUCE CODE AND TABLE SIZE This replaces some expanded macros with function calls if AES_ASM_V2 or AES_ASM_V2C are defined */ #if 1 && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) # define REDUCE_CODE_SIZE #endif /* 12. TABLE OPTIONS This cipher proceeds by repeating in a number of cycles known as 'rounds' which are implemented by a round function which can optionally be speeded up using tables. The basic tables are each 256 32-bit words, with either one or four tables being required for each round function depending on how much speed is required. The encryption and decryption round functions are different and the last encryption and decrytpion round functions are different again making four different round functions in all. This means that: 1. Normal encryption and decryption rounds can each use either 0, 1 or 4 tables and table spaces of 0, 1024 or 4096 bytes each. 2. The last encryption and decryption rounds can also use either 0, 1 or 4 tables and table spaces of 0, 1024 or 4096 bytes each. Include or exclude the appropriate definitions below to set the number of tables used by this implementation. */ #if 1 /* set tables for the normal encryption round */ # define ENC_ROUND FOUR_TABLES #elif 0 # define ENC_ROUND ONE_TABLE #else # define ENC_ROUND NO_TABLES #endif #if 1 /* set tables for the last encryption round */ # define LAST_ENC_ROUND FOUR_TABLES #elif 0 # define LAST_ENC_ROUND ONE_TABLE #else # define LAST_ENC_ROUND NO_TABLES #endif #if 1 /* set tables for the normal decryption round */ # define DEC_ROUND FOUR_TABLES #elif 0 # define DEC_ROUND ONE_TABLE #else # define DEC_ROUND NO_TABLES #endif #if 1 /* set tables for the last decryption round */ # define LAST_DEC_ROUND FOUR_TABLES #elif 0 # define LAST_DEC_ROUND ONE_TABLE #else # define LAST_DEC_ROUND NO_TABLES #endif /* The decryption key schedule can be speeded up with tables in the same way that the round functions can. Include or exclude the following defines to set this requirement. */ #if 1 # define KEY_SCHED FOUR_TABLES #elif 0 # define KEY_SCHED ONE_TABLE #else # define KEY_SCHED NO_TABLES #endif /* ---- END OF USER CONFIGURED OPTIONS ---- */ /* VIA ACE support is only available for VC++ and GCC */ #if !defined( _MSC_VER ) && !defined( __GNUC__ ) # if defined( ASSUME_VIA_ACE_PRESENT ) # undef ASSUME_VIA_ACE_PRESENT # endif # if defined( USE_VIA_ACE_IF_PRESENT ) # undef USE_VIA_ACE_IF_PRESENT # endif #endif #if defined( ASSUME_VIA_ACE_PRESENT ) && !defined( USE_VIA_ACE_IF_PRESENT ) # define USE_VIA_ACE_IF_PRESENT #endif #if defined( USE_VIA_ACE_IF_PRESENT ) && !defined ( AES_REV_DKS ) # define AES_REV_DKS #endif /* Assembler support requires the use of platform byte order */ #if ( defined( ASM_X86_V1C ) || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) ) \ && (ALGORITHM_BYTE_ORDER != PLATFORM_BYTE_ORDER) # undef ALGORITHM_BYTE_ORDER # define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER #endif /* In this implementation the columns of the state array are each held in 32-bit words. The state array can be held in various ways: in an array of words, in a number of individual word variables or in a number of processor registers. The following define maps a variable name x and a column number c to the way the state array variable is to be held. The first define below maps the state into an array x[c] whereas the second form maps the state into a number of individual variables x0, x1, etc. Another form could map individual state colums to machine register names. */ #if defined( ARRAYS ) # define s(x,c) x[c] #else # define s(x,c) x##c #endif /* This implementation provides subroutines for encryption, decryption and for setting the three key lengths (separately) for encryption and decryption. Since not all functions are needed, masks are set up here to determine which will be implemented in C */ #if !defined( AES_ENCRYPT ) # define EFUNCS_IN_C 0 #elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) # define EFUNCS_IN_C ENC_KEYING_IN_C #elif !defined( ASM_X86_V2 ) # define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C ) #else # define EFUNCS_IN_C 0 #endif #if !defined( AES_DECRYPT ) # define DFUNCS_IN_C 0 #elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \ || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) # define DFUNCS_IN_C DEC_KEYING_IN_C #elif !defined( ASM_X86_V2 ) # define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C ) #else # define DFUNCS_IN_C 0 #endif #define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C ) /* END OF CONFIGURATION OPTIONS */ #define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2)) /* Disable or report errors on some combinations of options */ #if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES # undef LAST_ENC_ROUND # define LAST_ENC_ROUND NO_TABLES #elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES # undef LAST_ENC_ROUND # define LAST_ENC_ROUND ONE_TABLE #endif #if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE # undef ENC_UNROLL # define ENC_UNROLL NONE #endif #if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES # undef LAST_DEC_ROUND # define LAST_DEC_ROUND NO_TABLES #elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES # undef LAST_DEC_ROUND # define LAST_DEC_ROUND ONE_TABLE #endif #if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE # undef DEC_UNROLL # define DEC_UNROLL NONE #endif #if defined( bswap32 ) # define aes_sw32 bswap32 #elif defined( bswap_32 ) # define aes_sw32 bswap_32 #else # define brot(x,n) (((uint_32t)(x) << n) | ((uint_32t)(x) >> (32 - n))) # define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00)) #endif /* upr(x,n): rotates bytes within words by n positions, moving bytes to higher index positions with wrap around into low positions ups(x,n): moves bytes by n positions to higher index positions in words but without wrap around bval(x,n): extracts a byte from a word WARNING: The definitions given here are intended only for use with unsigned variables and with shift counts that are compile time constants */ #if ( ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN ) # define upr(x,n) (((uint_32t)(x) << (8 * (n))) | ((uint_32t)(x) >> (32 - 8 * (n)))) # define ups(x,n) ((uint_32t) (x) << (8 * (n))) # define bval(x,n) to_byte((x) >> (8 * (n))) # define bytes2word(b0, b1, b2, b3) \ (((uint_32t)(b3) << 24) | ((uint_32t)(b2) << 16) | ((uint_32t)(b1) << 8) | (b0)) #endif #if ( ALGORITHM_BYTE_ORDER == IS_BIG_ENDIAN ) # define upr(x,n) (((uint_32t)(x) >> (8 * (n))) | ((uint_32t)(x) << (32 - 8 * (n)))) # define ups(x,n) ((uint_32t) (x) >> (8 * (n))) # define bval(x,n) to_byte((x) >> (24 - 8 * (n))) # define bytes2word(b0, b1, b2, b3) \ (((uint_32t)(b0) << 24) | ((uint_32t)(b1) << 16) | ((uint_32t)(b2) << 8) | (b3)) #endif #if defined( SAFE_IO ) # define word_in(x,c) bytes2word(((const uint_8t*)(x)+4*c)[0], ((const uint_8t*)(x)+4*c)[1], \ ((const uint_8t*)(x)+4*c)[2], ((const uint_8t*)(x)+4*c)[3]) # define word_out(x,c,v) { ((uint_8t*)(x)+4*c)[0] = bval(v,0); ((uint_8t*)(x)+4*c)[1] = bval(v,1); \ ((uint_8t*)(x)+4*c)[2] = bval(v,2); ((uint_8t*)(x)+4*c)[3] = bval(v,3); } #elif ( ALGORITHM_BYTE_ORDER == PLATFORM_BYTE_ORDER ) # define word_in(x,c) (*((uint_32t*)(x)+(c))) # define word_out(x,c,v) (*((uint_32t*)(x)+(c)) = (v)) #else # define word_in(x,c) aes_sw32(*((uint_32t*)(x)+(c))) # define word_out(x,c,v) (*((uint_32t*)(x)+(c)) = aes_sw32(v)) #endif /* the finite field modular polynomial and elements */ #define WPOLY 0x011b #define BPOLY 0x1b /* multiply four bytes in GF(2^8) by 'x' {02} in parallel */ #define m1 0x80808080 #define m2 0x7f7f7f7f #define gf_mulx(x) ((((x) & m2) << 1) ^ ((((x) & m1) >> 7) * BPOLY)) /* The following defines provide alternative definitions of gf_mulx that might give improved performance if a fast 32-bit multiply is not available. Note that a temporary variable u needs to be defined where gf_mulx is used. #define gf_mulx(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6)) #define m4 (0x01010101 * BPOLY) #define gf_mulx(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4) */ /* Work out which tables are needed for the different options */ #if defined( ASM_X86_V1C ) # if defined( ENC_ROUND ) # undef ENC_ROUND # endif # define ENC_ROUND FOUR_TABLES # if defined( LAST_ENC_ROUND ) # undef LAST_ENC_ROUND # endif # define LAST_ENC_ROUND FOUR_TABLES # if defined( DEC_ROUND ) # undef DEC_ROUND # endif # define DEC_ROUND FOUR_TABLES # if defined( LAST_DEC_ROUND ) # undef LAST_DEC_ROUND # endif # define LAST_DEC_ROUND FOUR_TABLES # if defined( KEY_SCHED ) # undef KEY_SCHED # define KEY_SCHED FOUR_TABLES # endif #endif #if ( FUNCS_IN_C & ENCRYPTION_IN_C ) || defined( ASM_X86_V1C ) # if ENC_ROUND == ONE_TABLE # define FT1_SET # elif ENC_ROUND == FOUR_TABLES # define FT4_SET # else # define SBX_SET # endif # if LAST_ENC_ROUND == ONE_TABLE # define FL1_SET # elif LAST_ENC_ROUND == FOUR_TABLES # define FL4_SET # elif !defined( SBX_SET ) # define SBX_SET # endif #endif #if ( FUNCS_IN_C & DECRYPTION_IN_C ) || defined( ASM_X86_V1C ) # if DEC_ROUND == ONE_TABLE # define IT1_SET # elif DEC_ROUND == FOUR_TABLES # define IT4_SET # else # define ISB_SET # endif # if LAST_DEC_ROUND == ONE_TABLE # define IL1_SET # elif LAST_DEC_ROUND == FOUR_TABLES # define IL4_SET # elif !defined(ISB_SET) # define ISB_SET # endif #endif #if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) # if ((FUNCS_IN_C & ENC_KEYING_IN_C) || (FUNCS_IN_C & DEC_KEYING_IN_C)) # if KEY_SCHED == ONE_TABLE # if !defined( FL1_SET ) && !defined( FL4_SET ) # define LS1_SET # endif # elif KEY_SCHED == FOUR_TABLES # if !defined( FL4_SET ) # define LS4_SET # endif # elif !defined( SBX_SET ) # define SBX_SET # endif # endif # if (FUNCS_IN_C & DEC_KEYING_IN_C) # if KEY_SCHED == ONE_TABLE # define IM1_SET # elif KEY_SCHED == FOUR_TABLES # define IM4_SET # elif !defined( SBX_SET ) # define SBX_SET # endif # endif #endif /* generic definitions of Rijndael macros that use tables */ #define no_table(x,box,vf,rf,c) bytes2word( \ box[bval(vf(x,0,c),rf(0,c))], \ box[bval(vf(x,1,c),rf(1,c))], \ box[bval(vf(x,2,c),rf(2,c))], \ box[bval(vf(x,3,c),rf(3,c))]) #define one_table(x,op,tab,vf,rf,c) \ ( tab[bval(vf(x,0,c),rf(0,c))] \ ^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \ ^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \ ^ op(tab[bval(vf(x,3,c),rf(3,c))],3)) #define four_tables(x,tab,vf,rf,c) \ ( tab[0][bval(vf(x,0,c),rf(0,c))] \ ^ tab[1][bval(vf(x,1,c),rf(1,c))] \ ^ tab[2][bval(vf(x,2,c),rf(2,c))] \ ^ tab[3][bval(vf(x,3,c),rf(3,c))]) #define vf1(x,r,c) (x) #define rf1(r,c) (r) #define rf2(r,c) ((8+r-c)&3) /* perform forward and inverse column mix operation on four bytes in long word x in */ /* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */ #if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))) #if defined( FM4_SET ) /* not currently used */ # define fwd_mcol(x) four_tables(x,t_use(f,m),vf1,rf1,0) #elif defined( FM1_SET ) /* not currently used */ # define fwd_mcol(x) one_table(x,upr,t_use(f,m),vf1,rf1,0) #else # define dec_fmvars uint_32t g2 # define fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1)) #endif #if defined( IM4_SET ) # define inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0) #elif defined( IM1_SET ) # define inv_mcol(x) one_table(x,upr,t_use(i,m),vf1,rf1,0) #else # define dec_imvars uint_32t g2, g4, g9 # define inv_mcol(x) (g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \ (x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1)) #endif #if defined( FL4_SET ) # define ls_box(x,c) four_tables(x,t_use(f,l),vf1,rf2,c) #elif defined( LS4_SET ) # define ls_box(x,c) four_tables(x,t_use(l,s),vf1,rf2,c) #elif defined( FL1_SET ) # define ls_box(x,c) one_table(x,upr,t_use(f,l),vf1,rf2,c) #elif defined( LS1_SET ) # define ls_box(x,c) one_table(x,upr,t_use(l,s),vf1,rf2,c) #else # define ls_box(x,c) no_table(x,t_use(s,box),vf1,rf2,c) #endif #endif #if defined( ASM_X86_V1C ) && defined( AES_DECRYPT ) && !defined( ISB_SET ) # define ISB_SET #endif #endif pdns-3.3/pdns/aes/aeskey.c0000644000014601777760000004041012136555572016736 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #include "aesopt.h" #include "aestab.h" #ifdef USE_VIA_ACE_IF_PRESENT # include "aes_via_ace.h" #endif #if defined(__cplusplus) extern "C" { #endif /* Initialise the key schedule from the user supplied key. The key length can be specified in bytes, with legal values of 16, 24 and 32, or in bits, with legal values of 128, 192 and 256. These values correspond with Nk values of 4, 6 and 8 respectively. The following macros implement a single cycle in the key schedule generation process. The number of cycles needed for each cx->n_col and nk value is: nk = 4 5 6 7 8 ------------------------------ cx->n_col = 4 10 9 8 7 7 cx->n_col = 5 14 11 10 9 9 cx->n_col = 6 19 15 12 11 11 cx->n_col = 7 21 19 16 13 14 cx->n_col = 8 29 23 19 17 14 */ #if defined( REDUCE_CODE_SIZE ) # define ls_box ls_sub uint_32t ls_sub(const uint_32t t, const uint_32t n); # define inv_mcol im_sub uint_32t im_sub(const uint_32t x); # ifdef ENC_KS_UNROLL # undef ENC_KS_UNROLL # endif # ifdef DEC_KS_UNROLL # undef DEC_KS_UNROLL # endif #endif #if (FUNCS_IN_C & ENC_KEYING_IN_C) #if defined(AES_128) || defined( AES_VAR ) #define ke4(k,i) \ { k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ k[4*(i)+5] = ss[1] ^= ss[0]; \ k[4*(i)+6] = ss[2] ^= ss[1]; \ k[4*(i)+7] = ss[3] ^= ss[2]; \ } AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint_32t ss[4]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); #ifdef ENC_KS_UNROLL ke4(cx->ks, 0); ke4(cx->ks, 1); ke4(cx->ks, 2); ke4(cx->ks, 3); ke4(cx->ks, 4); ke4(cx->ks, 5); ke4(cx->ks, 6); ke4(cx->ks, 7); ke4(cx->ks, 8); #else { uint_32t i; for(i = 0; i < 9; ++i) ke4(cx->ks, i); } #endif ke4(cx->ks, 9); cx->inf.l = 0; cx->inf.b[0] = 10 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_192) || defined( AES_VAR ) #define kef6(k,i) \ { k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ k[6*(i)+ 7] = ss[1] ^= ss[0]; \ k[6*(i)+ 8] = ss[2] ^= ss[1]; \ k[6*(i)+ 9] = ss[3] ^= ss[2]; \ } #define ke6(k,i) \ { kef6(k,i); \ k[6*(i)+10] = ss[4] ^= ss[3]; \ k[6*(i)+11] = ss[5] ^= ss[4]; \ } AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint_32t ss[6]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); cx->ks[4] = ss[4] = word_in(key, 4); cx->ks[5] = ss[5] = word_in(key, 5); #ifdef ENC_KS_UNROLL ke6(cx->ks, 0); ke6(cx->ks, 1); ke6(cx->ks, 2); ke6(cx->ks, 3); ke6(cx->ks, 4); ke6(cx->ks, 5); ke6(cx->ks, 6); #else { uint_32t i; for(i = 0; i < 7; ++i) ke6(cx->ks, i); } #endif kef6(cx->ks, 7); cx->inf.l = 0; cx->inf.b[0] = 12 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_256) || defined( AES_VAR ) #define kef8(k,i) \ { k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ k[8*(i)+ 9] = ss[1] ^= ss[0]; \ k[8*(i)+10] = ss[2] ^= ss[1]; \ k[8*(i)+11] = ss[3] ^= ss[2]; \ } #define ke8(k,i) \ { kef8(k,i); \ k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \ k[8*(i)+13] = ss[5] ^= ss[4]; \ k[8*(i)+14] = ss[6] ^= ss[5]; \ k[8*(i)+15] = ss[7] ^= ss[6]; \ } AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]) { uint_32t ss[8]; cx->ks[0] = ss[0] = word_in(key, 0); cx->ks[1] = ss[1] = word_in(key, 1); cx->ks[2] = ss[2] = word_in(key, 2); cx->ks[3] = ss[3] = word_in(key, 3); cx->ks[4] = ss[4] = word_in(key, 4); cx->ks[5] = ss[5] = word_in(key, 5); cx->ks[6] = ss[6] = word_in(key, 6); cx->ks[7] = ss[7] = word_in(key, 7); #ifdef ENC_KS_UNROLL ke8(cx->ks, 0); ke8(cx->ks, 1); ke8(cx->ks, 2); ke8(cx->ks, 3); ke8(cx->ks, 4); ke8(cx->ks, 5); #else { uint_32t i; for(i = 0; i < 6; ++i) ke8(cx->ks, i); } #endif kef8(cx->ks, 6); cx->inf.l = 0; cx->inf.b[0] = 14 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined( AES_VAR ) AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) { switch(key_len) { case 16: case 128: return aes_encrypt_key128(key, cx); case 24: case 192: return aes_encrypt_key192(key, cx); case 32: case 256: return aes_encrypt_key256(key, cx); default: return EXIT_FAILURE; } } #endif #endif #if (FUNCS_IN_C & DEC_KEYING_IN_C) /* this is used to store the decryption round keys */ /* in forward or reverse order */ #ifdef AES_REV_DKS #define v(n,i) ((n) - (i) + 2 * ((i) & 3)) #else #define v(n,i) (i) #endif #if DEC_ROUND == NO_TABLES #define ff(x) (x) #else #define ff(x) inv_mcol(x) #if defined( dec_imvars ) #define d_vars dec_imvars #endif #endif #if defined(AES_128) || defined( AES_VAR ) #define k4e(k,i) \ { k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \ k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \ k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \ k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \ } #if 1 #define kdf4(k,i) \ { ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \ ss[1] = ss[1] ^ ss[3]; \ ss[2] = ss[2] ^ ss[3]; \ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ ss[i % 4] ^= ss[4]; \ ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \ ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \ } #define kd4(k,i) \ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \ ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \ k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \ k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \ k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \ k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \ } #define kdl4(k,i) \ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \ k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \ k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \ k[v(40,(4*(i))+6)] = ss[0]; \ k[v(40,(4*(i))+7)] = ss[1]; \ } #else #define kdf4(k,i) \ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \ } #define kd4(k,i) \ { ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \ } #define kdl4(k,i) \ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \ } #endif AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint_32t ss[5]; #if defined( d_vars ) d_vars; #endif cx->ks[v(40,(0))] = ss[0] = word_in(key, 0); cx->ks[v(40,(1))] = ss[1] = word_in(key, 1); cx->ks[v(40,(2))] = ss[2] = word_in(key, 2); cx->ks[v(40,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL kdf4(cx->ks, 0); kd4(cx->ks, 1); kd4(cx->ks, 2); kd4(cx->ks, 3); kd4(cx->ks, 4); kd4(cx->ks, 5); kd4(cx->ks, 6); kd4(cx->ks, 7); kd4(cx->ks, 8); kdl4(cx->ks, 9); #else { uint_32t i; for(i = 0; i < 10; ++i) k4e(cx->ks, i); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 10 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 10 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_192) || defined( AES_VAR ) #define k6ef(k,i) \ { k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \ k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \ k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \ k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \ } #define k6e(k,i) \ { k6ef(k,i); \ k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \ k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \ } #define kdf6(k,i) \ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \ } #define kd6(k,i) \ { ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \ } #define kdl6(k,i) \ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \ } AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint_32t ss[7]; #if defined( d_vars ) d_vars; #endif cx->ks[v(48,(0))] = ss[0] = word_in(key, 0); cx->ks[v(48,(1))] = ss[1] = word_in(key, 1); cx->ks[v(48,(2))] = ss[2] = word_in(key, 2); cx->ks[v(48,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL ss[4] = word_in(key, 4); cx->ks[v(48,(4))] = ff(ss[4]); ss[5] = word_in(key, 5); cx->ks[v(48,(5))] = ff(ss[5]); kdf6(cx->ks, 0); kd6(cx->ks, 1); kd6(cx->ks, 2); kd6(cx->ks, 3); kd6(cx->ks, 4); kd6(cx->ks, 5); kd6(cx->ks, 6); kdl6(cx->ks, 7); #else cx->ks[v(48,(4))] = ss[4] = word_in(key, 4); cx->ks[v(48,(5))] = ss[5] = word_in(key, 5); { uint_32t i; for(i = 0; i < 7; ++i) k6e(cx->ks, i); k6ef(cx->ks, 7); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 12 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 12 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #if defined(AES_256) || defined( AES_VAR ) #define k8ef(k,i) \ { k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \ k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \ k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \ k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \ } #define k8e(k,i) \ { k8ef(k,i); \ k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \ k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \ k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \ k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \ } #define kdf8(k,i) \ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \ ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \ } #define kd8(k,i) \ { ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \ ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \ ss[8] = ls_box(ss[3],0); \ ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \ } #define kdl8(k,i) \ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \ } #if 0 AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]) { uint_32t ss[9]; #if defined( d_vars ) d_vars; #endif cx->ks[v(56,(0))] = ss[0] = word_in(key, 0); cx->ks[v(56,(1))] = ss[1] = word_in(key, 1); cx->ks[v(56,(2))] = ss[2] = word_in(key, 2); cx->ks[v(56,(3))] = ss[3] = word_in(key, 3); #ifdef DEC_KS_UNROLL ss[4] = word_in(key, 4); cx->ks[v(56,(4))] = ff(ss[4]); ss[4] = word_in(key, 5); cx->ks[v(56,(5))] = ff(ss[5]); ss[4] = word_in(key, 6); cx->ks[v(56,(6))] = ff(ss[6]); ss[4] = word_in(key, 7); cx->ks[v(56,(7))] = ff(ss[7]); kdf8(cx->ks, 0); kd8(cx->ks, 1); kd8(cx->ks, 2); kd8(cx->ks, 3); kd8(cx->ks, 4); kd8(cx->ks, 5); kdl8(cx->ks, 6); #else cx->ks[v(56,(4))] = ss[4] = word_in(key, 4); cx->ks[v(56,(5))] = ss[5] = word_in(key, 5); cx->ks[v(56,(6))] = ss[6] = word_in(key, 6); cx->ks[v(56,(7))] = ss[7] = word_in(key, 7); { uint_32t i; for(i = 0; i < 6; ++i) k8e(cx->ks, i); k8ef(cx->ks, 6); #if !(DEC_ROUND == NO_TABLES) for(i = N_COLS; i < 14 * N_COLS; ++i) cx->ks[i] = inv_mcol(cx->ks[i]); #endif } #endif cx->inf.l = 0; cx->inf.b[0] = 14 * 16; #ifdef USE_VIA_ACE_IF_PRESENT if(VIA_ACE_AVAILABLE) cx->inf.b[1] = 0xff; #endif return EXIT_SUCCESS; } #endif #endif #if defined( AES_VAR ) #if 0 AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) { switch(key_len) { case 16: case 128: return aes_decrypt_key128(key, cx); case 24: case 192: return aes_decrypt_key192(key, cx); case 32: case 256: return aes_decrypt_key256(key, cx); default: return EXIT_FAILURE; } } #endif #endif #endif #if defined(__cplusplus) } #endif pdns-3.3/pdns/aes/aestab.c0000644000014601777760000003555112136555572016726 0ustar00jenkinsnogroup00000000000000/* --------------------------------------------------------------------------- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 */ #define DO_TABLES #include "aes.h" #include "aesopt.h" #if defined(FIXED_TABLES) #define sb_data(w) {\ w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } #define isb_data(w) {\ w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\ w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\ w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\ w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\ w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\ w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\ w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\ w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\ w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\ w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\ w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\ w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\ w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\ w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\ w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\ w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\ w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\ w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\ w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\ w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\ w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\ w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\ w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\ w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\ w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\ w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\ w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\ w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\ w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\ w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\ w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\ w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) } #define mm_data(w) {\ w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\ w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\ w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\ w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\ w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\ w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\ w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\ w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\ w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\ w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\ w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\ w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\ w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\ w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\ w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\ w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\ w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\ w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\ w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\ w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\ w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\ w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\ w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\ w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\ w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\ w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\ w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\ w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\ w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\ w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\ w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\ w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) } #define rc_data(w) {\ w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\ w(0x1b), w(0x36) } #define h0(x) (x) #define w0(p) bytes2word(p, 0, 0, 0) #define w1(p) bytes2word(0, p, 0, 0) #define w2(p) bytes2word(0, 0, p, 0) #define w3(p) bytes2word(0, 0, 0, p) #define u0(p) bytes2word(f2(p), p, p, f3(p)) #define u1(p) bytes2word(f3(p), f2(p), p, p) #define u2(p) bytes2word(p, f3(p), f2(p), p) #define u3(p) bytes2word(p, p, f3(p), f2(p)) #define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p)) #define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p)) #define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p)) #define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p)) #endif #if defined(FIXED_TABLES) || !defined(FF_TABLES) #define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY)) #define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY)) #define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \ ^ (((x>>5) & 4) * WPOLY)) #define f3(x) (f2(x) ^ x) #define f9(x) (f8(x) ^ x) #define fb(x) (f8(x) ^ f2(x) ^ x) #define fd(x) (f8(x) ^ f4(x) ^ x) #define fe(x) (f8(x) ^ f4(x) ^ f2(x)) #else #define f2(x) ((x) ? pow[log[x] + 0x19] : 0) #define f3(x) ((x) ? pow[log[x] + 0x01] : 0) #define f9(x) ((x) ? pow[log[x] + 0xc7] : 0) #define fb(x) ((x) ? pow[log[x] + 0x68] : 0) #define fd(x) ((x) ? pow[log[x] + 0xee] : 0) #define fe(x) ((x) ? pow[log[x] + 0xdf] : 0) #define fi(x) ((x) ? pow[ 255 - log[x]] : 0) #endif #include "aestab.h" #if defined(__cplusplus) extern "C" { #endif #if defined(FIXED_TABLES) /* implemented in case of wrong call for fixed tables */ AES_RETURN aes_init(void) { return EXIT_SUCCESS; } #else /* dynamic table generation */ #if !defined(FF_TABLES) /* Generate the tables for the dynamic table option It will generally be sensible to use tables to compute finite field multiplies and inverses but where memory is scarse this code might sometimes be better. But it only has effect during initialisation so its pretty unimportant in overall terms. */ /* return 2 ^ (n - 1) where n is the bit number of the highest bit set in x with x in the range 1 < x < 0x00000200. This form is used so that locals within fi can be bytes rather than words */ static uint_8t hibit(const uint_32t x) { uint_8t r = (uint_8t)((x >> 1) | (x >> 2)); r |= (r >> 2); r |= (r >> 4); return (r + 1) >> 1; } /* return the inverse of the finite field element x */ static uint_8t fi(const uint_8t x) { uint_8t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0; if(x < 2) return x; for(;;) { if(!n1) return v1; while(n2 >= n1) { n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2); } if(!n2) return v2; while(n1 >= n2) { n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1); } } } #endif /* The forward and inverse affine transformations used in the S-box */ #define fwd_affine(x) \ (w = (uint_32t)x, w ^= (w<<1)^(w<<2)^(w<<3)^(w<<4), 0x63^(uint_8t)(w^(w>>8))) #define inv_affine(x) \ (w = (uint_32t)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(uint_8t)(w^(w>>8))) static int init = 0; AES_RETURN aes_init(void) { uint_32t i, w; #if defined(FF_TABLES) uint_8t pow[512], log[256]; if(init) return EXIT_SUCCESS; /* log and power tables for GF(2^8) finite field with WPOLY as modular polynomial - the simplest primitive root is 0x03, used here to generate the tables */ i = 0; w = 1; do { pow[i] = (uint_8t)w; pow[i + 255] = (uint_8t)w; log[w] = (uint_8t)i++; w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0); } while (w != 1); #else if(init) return EXIT_SUCCESS; #endif for(i = 0, w = 1; i < RC_LENGTH; ++i) { t_set(r,c)[i] = bytes2word(w, 0, 0, 0); w = f2(w); } for(i = 0; i < 256; ++i) { uint_8t b; b = fwd_affine(fi((uint_8t)i)); w = bytes2word(f2(b), b, b, f3(b)); #if defined( SBX_SET ) t_set(s,box)[i] = b; #endif #if defined( FT1_SET ) /* tables for a normal encryption round */ t_set(f,n)[i] = w; #endif #if defined( FT4_SET ) t_set(f,n)[0][i] = w; t_set(f,n)[1][i] = upr(w,1); t_set(f,n)[2][i] = upr(w,2); t_set(f,n)[3][i] = upr(w,3); #endif w = bytes2word(b, 0, 0, 0); #if defined( FL1_SET ) /* tables for last encryption round (may also */ t_set(f,l)[i] = w; /* be used in the key schedule) */ #endif #if defined( FL4_SET ) t_set(f,l)[0][i] = w; t_set(f,l)[1][i] = upr(w,1); t_set(f,l)[2][i] = upr(w,2); t_set(f,l)[3][i] = upr(w,3); #endif #if defined( LS1_SET ) /* table for key schedule if t_set(f,l) above is*/ t_set(l,s)[i] = w; /* not of the required form */ #endif #if defined( LS4_SET ) t_set(l,s)[0][i] = w; t_set(l,s)[1][i] = upr(w,1); t_set(l,s)[2][i] = upr(w,2); t_set(l,s)[3][i] = upr(w,3); #endif b = fi(inv_affine((uint_8t)i)); w = bytes2word(fe(b), f9(b), fd(b), fb(b)); #if defined( IM1_SET ) /* tables for the inverse mix column operation */ t_set(i,m)[b] = w; #endif #if defined( IM4_SET ) t_set(i,m)[0][b] = w; t_set(i,m)[1][b] = upr(w,1); t_set(i,m)[2][b] = upr(w,2); t_set(i,m)[3][b] = upr(w,3); #endif #if defined( ISB_SET ) t_set(i,box)[i] = b; #endif #if defined( IT1_SET ) /* tables for a normal decryption round */ t_set(i,n)[i] = w; #endif #if defined( IT4_SET ) t_set(i,n)[0][i] = w; t_set(i,n)[1][i] = upr(w,1); t_set(i,n)[2][i] = upr(w,2); t_set(i,n)[3][i] = upr(w,3); #endif w = bytes2word(b, 0, 0, 0); #if defined( IL1_SET ) /* tables for last decryption round */ t_set(i,l)[i] = w; #endif #if defined( IL4_SET ) t_set(i,l)[0][i] = w; t_set(i,l)[1][i] = upr(w,1); t_set(i,l)[2][i] = upr(w,2); t_set(i,l)[3][i] = upr(w,3); #endif } init = 1; return EXIT_SUCCESS; } #endif #if defined(__cplusplus) } #endif pdns-3.3/pdns/signingpipe.hh0000644000014601777760000000304512136555572017401 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_SIGNINGPIPE #define PDNS_SIGNINGPIPE #include #include #include #include "dnsseckeeper.hh" #include "dns.hh" using std::string; using std::vector; void writeLStringToSocket(int fd, const pdns::string& msg); bool readLStringFromSocket(int fd, string& msg); /** input: DNSResourceRecords ordered in qname,qtype (we emit a signature chunk on a break) * output: "chunks" of those very same DNSResourceRecords, interleaved with signatures */ class ChunkedSigningPipe { public: typedef vector rrset_t; typedef rrset_t chunk_t; // for now ChunkedSigningPipe(const std::string& signerName, bool mustSign, const pdns::string& servers=pdns::string(), unsigned int numWorkers=3); ~ChunkedSigningPipe(); bool submit(const DNSResourceRecord& rr); chunk_t getChunk(bool final=false); int d_queued; AtomicCounter d_signed; int d_outstanding; unsigned int getReady(); private: void flushToSign(); void dedupRRSet(); void sendRRSetToWorker(); // dispatch RRSET to worker void addSignedToChunks(chunk_t* signedChunk); pair, vector > waitForRW(bool rd, bool wr, int seconds); void worker(int n, int fd); static void* helperWorker(void* p); rrset_t* d_rrsetToSign; std::deque< std::vector > d_chunks; string d_signer; chunk_t::size_type d_maxchunkrecords; std::vector d_sockets; std::set d_eof; unsigned int d_numworkers; vector d_tids; bool d_mustSign; bool d_final; int d_submitted; }; #endif pdns-3.3/pdns/ltmain.sh0000644000014601777760000042316612136555572016376 0ustar00jenkinsnogroup00000000000000# ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 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. # Check that we have a working $echo. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell, and then maybe $echo will work. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <&2 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 fi # Global variables. mode=$default_mode nonopt= prev= prevopt= run= show="$echo" show_help= execute_dlfiles= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" # Parse our command line options once, thoroughly. while test $# -gt 0 do arg="$1" shift case $arg in -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; *) eval "$prev=\$arg" ;; esac prev= prevopt= continue fi # Have we seen a non-optional argument yet? case $arg in --help) show_help=yes ;; --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" exit 0 ;; --config) sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 exit 0 ;; --debug) echo "$progname: enabling shell trace mode" set -x ;; --dry-run | -n) run=: ;; --features) echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit 0 ;; --finish) mode="finish" ;; --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; --preserve-dup-deps) duplicate_deps="yes" ;; --quiet | --silent) show=: ;; -dlopen) prevopt="-dlopen" prev=execute_dlfiles ;; -*) $echo "$modename: unrecognized option \`$arg'" 1>&2 $echo "$help" 1>&2 exit 1 ;; *) nonopt="$arg" break ;; esac done if test -n "$prevopt"; then $echo "$modename: option \`$prevopt' requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then case $nonopt in *cc | *++ | gcc* | *-gcc*) mode=link for arg do case $arg in -c) mode=compile break ;; esac done ;; *db | *dbx | *strace | *truss) mode=execute ;; *install*|cp|mv) mode=install ;; *rm) mode=uninstall ;; *) # If we have no mode, but dlfiles were specified, then do execute mode. test -n "$execute_dlfiles" && mode=execute # Just use the default operation mode. if test -z "$mode"; then if test -n "$nonopt"; then $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 else $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 fi fi ;; esac fi # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then $echo "$modename: unrecognized option \`-dlopen'" 1>&2 $echo "$help" 1>&2 exit 1 fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$modename --help --mode=$mode' for more information." # These modes are in order of execution frequency so that they run quickly. case $mode in # libtool compile mode compile) modename="$modename: compile" # Get the compilation command and the source file. base_compile= prev= lastarg= srcfile="$nonopt" suppress_output= user_target=no for arg do case $prev in "") ;; xcompiler) # Aesthetically quote the previous argument. prev= lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac # Add the previous argument to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi continue ;; esac # Accept any command-line options. case $arg in -o) if test "$user_target" != "no"; then $echo "$modename: you cannot specify \`-o' more than once" 1>&2 exit 1 fi user_target=next ;; -static) build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; -Xcompiler) prev=xcompiler continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac lastarg="$lastarg $arg" done IFS="$save_ifs" lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` # Add the arguments to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi continue ;; esac case $user_target in next) # The next one is the -o target name user_target=yes continue ;; yes) # We got the output file user_target=set libobj="$arg" continue ;; esac # Accept the current argument as the source file. lastarg="$srcfile" srcfile="$arg" # Aesthetically quote the previous argument. # Backslashify any backslashes, double quotes, and dollar signs. # These are the only characters that are still specially # interpreted inside of double-quoted scrings. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $lastarg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac # Add the previous argument to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi done case $user_target in set) ;; no) # Get the name of the library object. libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` ;; *) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit 1 ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo xform='[cCFSfmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; *.ads) xform=ads ;; *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` case $libobj in *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; *) $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 exit 1 ;; esac if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 exit 1 fi # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $libobj" else removelist="$libobj" fi $run $rm $removelist trap "$run $rm $removelist; exit 1" 1 2 15 # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2*) pic_mode=default ;; esac if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit 1" 1 2 15 else need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $run ln "$0" "$lockfile" 2>/dev/null; do $show "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi echo $srcfile > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then # All platforms use -DPIC, to notify preprocessed assembler code. command="$base_compile $srcfile $pic_flag -DPIC" else # Don't build PIC code command="$base_compile $srcfile" fi if test "$build_old_libs" = yes; then lo_libobj="$libobj" dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$libobj"; then dir="$objdir" else dir="$dir/$objdir" fi libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` if test -d "$dir"; then $show "$rm $libobj" $run $rm $libobj else $show "$mkdir $dir" $run $mkdir $dir status=$? if test $status -ne 0 && test ! -d $dir; then exit $status fi fi fi if test "$compiler_o_lo" = yes; then output_obj="$libobj" command="$command -o $output_obj" elif test "$compiler_c_o" = yes; then output_obj="$obj" command="$command -o $output_obj" fi $run $rm "$output_obj" $show "$command" if $run eval "$command"; then : else test -n "$output_obj" && $run $rm $removelist exit 1 fi if test "$need_locks" = warn && test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi # Just move the object if needed, then go on to compile the next one if test x"$output_obj" != x"$libobj"; then $show "$mv $output_obj $libobj" if $run $mv $output_obj $libobj; then : else error=$? $run $rm $removelist exit $error fi fi # If we have no pic_flag, then copy the object into place and finish. if (test -z "$pic_flag" || test "$pic_mode" != default) && test "$build_old_libs" = yes; then # Rename the .lo from within objdir to obj if test -f $obj; then $show $rm $obj $run $rm $obj fi $show "$mv $libobj $obj" if $run $mv $libobj $obj; then : else error=$? $run $rm $removelist exit $error fi xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` # Now arrange that obj and lo_libobj become the same file $show "(cd $xdir && $LN_S $baseobj $libobj)" if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then # Unlock the critical section if it was locked if test "$need_locks" != no; then $run $rm "$lockfile" fi exit 0 else error=$? $run $rm $removelist exit $error fi fi # Allow error messages only from the first compilation. suppress_output=' >/dev/null 2>&1' fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $srcfile" else # All platforms use -DPIC, to notify preprocessed assembler code. command="$base_compile $srcfile $pic_flag -DPIC" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" output_obj="$obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" $run $rm "$output_obj" $show "$command" if $run eval "$command"; then : else $run $rm $removelist exit 1 fi if test "$need_locks" = warn && test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi # Just move the object if needed if test x"$output_obj" != x"$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else error=$? $run $rm $removelist exit $error fi fi # Create an invalid libtool object if no PIC, so that we do not # accidentally link it into a program. if test "$build_libtool_libs" != yes; then $show "echo timestamp > $libobj" $run eval "echo timestamp > \$libobj" || exit $? else # Move the .lo from within objdir $show "$mv $libobj $lo_libobj" if $run $mv $libobj $lo_libobj; then : else error=$? $run $rm $removelist exit $error fi fi fi # Unlock the critical section if it was locked if test "$need_locks" != no; then $run $rm "$lockfile" fi exit 0 ;; # libtool link mode link | relink) modename="$modename: link" case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invokation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args="$nonopt" compile_command="$nonopt" finalize_command="$nonopt" compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` avoid_version=no dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= # We need to know -static, to get the right output filenames. for arg do case $arg in -all-static | -static) if test "X$arg" = "X-all-static"; then if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi else if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi fi build_libtool_libs=no build_old_libs=yes prefer_static_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test $# -gt 0; do arg="$1" shift case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test ;; *) qarg=$arg ;; esac libtool_args="$libtool_args $qarg" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit 1 fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= compile_command="$compile_command $wl$qarg" finalize_command="$finalize_command $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n $prev prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: more than one -exported-symbols argument is not allowed" exit 1 fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | no/*-*-nonstopux*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; esac continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 exit 1 fi dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-pw32* | *-*-beos*) # These systems don't actually have a C or math library (as such) continue ;; *-*-mingw* | *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; -module) module=yes continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # The PATH hackery in wrapper scripts is required on Windows # in order for the loader to find any dlls it needs. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -o) prev=output ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Wl,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $wl$flag" linker_flags="$linker_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; *.lo | *.$objext) # A library or standard object. if test "$prev" = dlfiles; then # This file was specified with -dlopen. if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $arg" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` prev= else case $arg in *.lo) libobjs="$libobjs $arg" ;; *) objs="$objs $arg" ;; esac fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` if test "X$output_objdir" = "X$output"; then output_objdir="$objdir" else output_objdir="$output_objdir/$objdir" fi # Create the object directory. if test ! -d $output_objdir; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir status=$? if test $status -ne 0 && test ! -d $output_objdir; then exit $status fi fi # Determine the type of output case $output in "") $echo "$modename: you must specify an output file" 1>&2 $echo "$help" 1>&2 exit 1 ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if test "X$duplicate_deps" = "Xyes" ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 exit 1 ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do if test $linkmode = prog; then # Determine which files to process case $pass in dlopen) libs="$dlfiles" save_deplibs="$deplibs" # Collect dlpreopened libraries deplibs= ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi for deplib in $libs; do lib= found=no case $deplib in -l*) if test $linkmode = oldlib && test $linkmode = obj; then $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 continue fi if test $pass = conv; then deplibs="$deplib $deplibs" continue fi name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do # Search the libtool library lib="$searchdir/lib${name}.la" if test -f "$lib"; then found=yes break fi done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test $pass = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) if test $pass = conv; then deplibs="$deplib $deplibs" continue fi if test $pass = scan; then deplibs="$deplib $deplibs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi ;; *) $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 ;; esac # linkmode continue ;; # -L -R*) if test $pass = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test $pass = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) if test "$deplibs_check_method" != pass_all; then echo echo "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not used here." else echo echo "*** Warning: Linking the shared library $output against the" echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) if test $pass != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test $found = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib'" 1>&2 exit 1 fi # Check to see that this really is a libtool archive. if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." dlname= dlopen= dlpreopen= libdir= library_names= old_library= # If the library was installed with an old release of libtool, # it will not redefine variable installed. installed=yes # Read the .la file case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test $linkmode = oldlib && test $linkmode = obj; }; then # Add dl[pre]opened files of deplib test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test $pass = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit 1 fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test $linkmode != prog && test $linkmode != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit 1 fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit 1 fi # This library was specified with -dlopen. if test $pass = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit 1 fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. dlprefiles="$dlprefiles $lib" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 abs_ladir="$ladir" fi ;; esac laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then $echo "$modename: warning: library \`$lib' was moved." 1>&2 dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. if test $pass = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit 1 fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test $linkmode = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" fi continue fi if test $linkmode = prog && test $pass != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? if test $linkalldeplibs = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... link_static=no # Whether the deplib will be linked statically if test -n "$library_names" && { test "$prefer_static_libs" = no || test -z "$old_library"; }; then # Link against this shared library if test "$linkmode,$pass" = "prog,link" || { test $linkmode = lib && test $hardcode_into_libs = yes; }; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac if test $linkmode = prog; then # We need to hardcode the library path if test -n "$shlibpath_var"; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; *) temp_rpath="$temp_rpath $dir" ;; esac fi fi fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names realname="$2" shift; shift libname=`eval \\$echo \"$libname_spec\"` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin*) major=`expr $current - $age` versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" soname=`echo $soroot | sed -e 's/^.*\///'` newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' eval cmds=\"$extract_expsyms_cmds\" for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' eval cmds=\"$old_archive_from_expsyms_cmds\" for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n $old_archive_from_expsyms_cmds if test $linkmode = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then $echo "$modename: configuration error: unsupported hardcode properties" exit 1 fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test $linkmode = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && \ test "$hardcode_minus_L" != yes && \ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test $linkmode = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" add="-l$name" fi if test $linkmode = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test $linkmode = prog; then if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi # Try to link the static library # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo echo "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else convenience="$convenience $dir/$old_library" old_convenience="$old_convenience $dir/$old_library" deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test $linkmode = lib; then if test -n "$dependency_libs" && { test $hardcode_into_libs != yes || test $build_old_libs = yes || test $link_static = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test $link_all_deplibs != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$deplib" && dir="." # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" fi ;; esac if grep "^installed=no" $deplib > /dev/null; then path="-L$absdir/$objdir" else eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 fi if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi path="-L$absdir" fi ;; *) continue ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$deplibs $path" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test $pass = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test $pass != dlopen; then test $pass != scan && dependency_libs="$newdependency_libs" if test $pass != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do case $deplib in -L*) new_libs="$deplib $new_libs" ;; *) case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi if test "$pass" = "conv" && { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then libs="$deplibs" # reset libs deplibs= fi done # for pass if test $linkmode = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 fi if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 fi # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` eval libname=\"$libname_spec\" ;; *) if test "$module" = no; then $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 $echo "$help" 1>&2 exit 1 fi if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit 1 else echo echo "*** Warning: Linking the shared library $output against the non-libtool" echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi if test "$dlself" != no; then $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 fi set dummy $rpath if test $# -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. libext=al oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 fi else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 IFS="$save_ifs" if test -n "$8"; then $echo "$modename: too many parameters to \`-version-info'" 1>&2 $echo "$help" 1>&2 exit 1 fi current="$2" revision="$3" age="$4" # Check that each of the things are valid numbers. case $current in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac case $revision in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac case $age in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac if test $age -gt $current; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header major=.`expr $current - $age` versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current"; ;; irix | nonstopux) case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" major=`expr $current - $age + 1` # Add in all the interfaces that we are compatible with. loop=$revision while test $loop != 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" ;; osf) major=`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test $loop != 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. major=`expr $current - $age` versuffix="-$major" ;; *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= verstring="0.0" case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring="" ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi if test "$mode" != relink; then # Remove our outputs. $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. for path in $notinst_path; do lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test $hardcode_into_libs != yes || test $build_old_libs = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. ;; *) # Add libc to deplibs on all other systems if necessary. if test $build_libtool_need_lc = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behaviour. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $rm conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | sed 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ | sed 10q \ | egrep "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done if test -n "$a_deplib" ; then droppeddeps=yes echo echo "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then echo "*** with $libname but no candidates were found. (...for file magic test)" else echo "*** with $libname and none of the candidates passed a file format test" echo "*** using a file magic. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check below in file_magic test if eval echo \"$potent_lib\" 2>/dev/null \ | sed 10q \ | egrep "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done if test -n "$a_deplib" ; then droppeddeps=yes echo echo "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then echo "*** with $libname but no candidates were found. (...for regex pattern test)" else echo "*** with $libname and none of the candidates passed a file format test" echo "*** using a regex pattern. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | grep . >/dev/null; then echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" echo "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test $allow_undefined = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test $hardcode_into_libs = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi test -z "$dlname" && dlname=$soname lib="$output_objdir/$realname" for link do linknames="$linknames $link" done # Ensure that we have .o objects for linkers which dislike .lo # (e.g. aix) in case we are running --disable-static for obj in $libobjs; do xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` if test ! -f $xdir/$oldobj; then $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? fi done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols eval cmds=\"$export_symbols_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" if test -n "$export_symbols_regex"; then $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" for xlib in $convenience; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` done fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval cmds=\"$archive_expsym_cmds\" else eval cmds=\"$archive_cmds\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? exit 0 fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 fi case $output in *.lo) if test -n "$objs$old_deplibs"; then $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 exit 1 fi libobj="$output" obj=`$echo "X$output" | $Xsed -e "$lo2o"` ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $run $rm $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" else gentop="$output_objdir/${obj}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" for xlib in $convenience; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` done fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" eval cmds=\"$reload_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit 0 fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. $show "echo timestamp > $libobj" $run eval "echo timestamp > $libobj" || exit $? exit 0 fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" eval cmds=\"$reload_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" else # Just create a symlink. $show $rm $libobj $run $rm $libobj xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$libobj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` $show "(cd $xdir && $LN_S $oldobj $baseobj)" $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? fi if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit 0 ;; prog) case $host in *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi if test "$preload" = yes; then if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && test "$dlopen_self_static" = unknown; then $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." fi fi case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 fi fi if test -n "$dlsyms"; then case $dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${outputname}.nm" $show "$rm $nlist ${nlist}S ${nlist}T" $run $rm "$nlist" "${nlist}S" "${nlist}T" # Parse the name list into a source file. $show "creating $output_objdir/$dlsyms" test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ #ifdef __cplusplus extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ #define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then $show "generating symbol list for \`$output'" test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for arg in $progfiles; do $show "extracting global C symbols from \`$arg'" $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$output.exp" $run $rm $export_symbols $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' else $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' fi fi for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" name=`echo "$arg" | sed -e 's%^.*/%%'` $run eval 'echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -z "$run"; then # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ #undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr address; } lt_preloaded_symbols[] = {\ " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" $echo >> "$output_objdir/$dlsyms" "\ {0, (lt_ptr) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " fi pic_flag_for_symtable= case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DPIC";; esac esac # Now compile the dynamic symbol file. $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 exit 1 ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi if test $need_relink = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" status=$? # Delete the generated files. if test -n "$dlsyms"; then $show "$rm $output_objdir/${outputname}S.${objext}" $run $rm "$output_objdir/${outputname}S.${objext}" fi exit $status fi if test -n "$shlibpath_var"; then # We should set the shlibpath_var rpath= for dir in $temp_rpath; do case $dir in [\\/]* | [A-Za-z]:[\\/]*) # Absolute path. rpath="$rpath$dir:" ;; *) # Relative path: add a thisdir entry. rpath="$rpath\$thisdir/$dir:" ;; esac done temp_rpath="$rpath" fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $run $rm $output # Link the executable and exit $show "$link_command" $run eval "$link_command" || exit $? exit 0 fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname $show "$link_command" $run eval "$link_command" || exit $? # Now create the wrapper script. $show "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi # Quote $echo for shipping. if test "X$echo" = "X$SHELL $0 --fallback-echo"; then case $0 in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; *) qecho="$SHELL `pwd`/$0 --fallback-echo";; esac qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if our run command is non-null. if test -z "$run"; then # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) output=`echo $output|sed 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe ;; *) exeext= ;; esac $rm $output trap "$rm $output; exit 1" 1 2 15 $echo > $output "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variable: notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then echo=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then # Yippee, \$echo works! : else # Restart under the correct shell, and then maybe \$echo will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` done # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $mkdir \"\$progdir\" else $rm \"\$progdir/\$file\" fi" echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit 1 fi fi $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $rm \"\$progdir/\$program\"; $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } $rm \"\$progdir/\$file\" fi" else echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi echo >> $output "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $echo >> $output "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $echo >> $output "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $echo >> $output "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # win32 systems need to use the prog path for dll # lookup to work *-*-cygwin* | *-*-pw32*) $echo >> $output "\ exec \$progdir/\$program \${1+\"\$@\"} " ;; # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ exec \$progdir\\\\\$program \${1+\"\$@\"} " ;; *) $echo >> $output "\ # Export the path to the program. PATH=\"\$progdir:\$PATH\" export PATH exec \$program \${1+\"\$@\"} " ;; esac $echo >> $output "\ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" exit 1 fi else # The program doesn't exist. \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " chmod +x $output fi exit 0 ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" # Add in members from convenience archives. for xlib in $addlibs; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` done fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then eval cmds=\"$old_archive_from_new_cmds\" else # Ensure that we have .o objects in place in case we decided # not to build a shared library, and have fallen back to building # static libs even though --disable-static was passed! for oldobj in $oldobjs; do if test ! -f $oldobj; then xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$oldobj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` $show "(cd $xdir && ${LN_S} $obj $baseobj)" $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? fi done eval cmds=\"$old_archive_cmds\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$generated"; then $show "${rm}r$generated" $run ${rm}r$generated fi # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" $show "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` # Only create the output if not a dry run. if test -z "$run"; then for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 fi newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi newdlfiles="$newdlfiles $libdir/$name" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi newdlprefiles="$newdlprefiles $libdir/$name" done dlprefiles="$newdlprefiles" fi $rm $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test $need_relink = yes; then $echo >> $output "\ relink_command=\"$relink_command\"" fi done fi # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? ;; esac exit 0 ;; # libtool install mode install) modename="$modename: install" # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$arg " arg="$1" shift else install_prog= arg="$nonopt" fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$install_prog$arg" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest="$arg" continue fi case $arg in -d) isdir=yes ;; -f) prev="-f" ;; -g) prev="-g" ;; -m) prev="-m" ;; -o) prev="-o" ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest="$arg" continue fi ;; esac # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$install_prog $arg" done if test -z "$install_prog"; then $echo "$modename: you must specify an install program" 1>&2 $echo "$help" 1>&2 exit 1 fi if test -n "$prev"; then $echo "$modename: the \`$prev' option requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi if test -z "$files"; then if test -z "$dest"; then $echo "$modename: no file or destination specified" 1>&2 else $echo "$modename: you must specify a destination" 1>&2 fi $echo "$help" 1>&2 exit 1 fi # Strip any trailing slash from the destination. dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` test "X$destdir" = "X$dest" && destdir=. destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` # Not a directory, so check to see that there is only one file specified. set dummy $files if test $# -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit 1 fi fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit 1 fi library_names= old_library= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" if test -n "$relink_command"; then $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 continue fi fi # See the names of the shared library. set dummy $library_names if test -n "$2"; then realname="$2" shift shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. $show "$install_prog $dir/$srcname $destdir/$realname" $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$striplib $destdir/$realname" $run eval "$striplib $destdir/$realname" || exit $? fi if test $# -gt 0; then # Delete the old symlinks, and create new ones. for linkname do if test "$linkname" != "$realname"; then $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" fi done fi # Do each command in the postinstall commands. lib="$destdir/$realname" eval cmds=\"$postinstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i $show "$install_prog $instname $destdir/$name" $run eval "$install_prog $instname $destdir/$name" || exit $? # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` ;; *.$objext) staticdest="$destfile" destfile= ;; *) $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac # Install the libtool object if requested. if test -n "$destfile"; then $show "$install_prog $file $destfile" $run eval "$install_prog $file $destfile" || exit $? fi # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` $show "$install_prog $staticobj $staticdest" $run eval "$install_prog \$staticobj \$staticdest" || exit $? fi exit 0 ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) wrapper=`echo $file | sed -e 's,.exe$,,'` ;; *) wrapper=$file ;; esac if (sed -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $wrapper ;; *) . ./$wrapper ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit 1 fi finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then # If there is no directory component, then add one. case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac fi libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 finalize=no fi done relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $wrapper ;; *) . ./$wrapper ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then tmpdir="/tmp" test -n "$TMPDIR" && tmpdir="$TMPDIR" tmpdir="$tmpdir/libtool-$$" if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : else $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 continue fi file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 ${rm}r "$tmpdir" continue fi file="$outputname" else $echo "$modename: warning: cannot relink \`$file'" 1>&2 fi else # Install the binary that we compiled earlier. file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyways case $install_prog,$host in /usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) destfile=`echo $destfile | sed -e 's,.exe$,,'` ;; esac ;; esac $show "$install_prog$stripme $file $destfile" $run eval "$install_prog\$stripme \$file \$destfile" || exit $? test -n "$outputname" && ${rm}r "$tmpdir" ;; esac done for file in $staticlibs; do name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` # Set up the ranlib parameters. oldlib="$destdir/$name" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. eval cmds=\"$old_postinstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$future_libdirs"; then $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 fi if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $0 --finish$current_libdirs' else exit 0 fi ;; # libtool finish mode finish) modename="$modename: finish" libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. eval cmds=\"$finish_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" done IFS="$save_ifs" fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $run eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. test "$show" = ":" && exit 0 echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do echo " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" echo "more information, such as the ld(1) and ld.so(8) manual pages." echo "----------------------------------------------------------------------" exit 0 ;; # libtool execute mode execute) modename="$modename: execute" # The first argument is the command name. cmd="$nonopt" if test -z "$cmd"; then $echo "$modename: you must specify a COMMAND" 1>&2 $echo "$help" exit 1 fi # Handle -dlopen flags immediately. for file in $execute_dlfiles; do if test ! -f "$file"; then $echo "$modename: \`$file' is not a file" 1>&2 $echo "$help" 1>&2 exit 1 fi dir= case $file in *.la) # Check to see that this really is a libtool archive. if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit 1 fi # Read the libtool library. dlname= library_names= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" continue fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 exit 1 fi ;; *.lo) # Just add the directory containing the .lo file. dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. ;; *) $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` args="$args \"$file\"" done if test -z "$run"; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved enviroment variables if test "${save_LC_ALL+set}" = set; then LC_ALL="$save_LC_ALL"; export LC_ALL fi if test "${save_LANG+set}" = set; then LANG="$save_LANG"; export LANG fi # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi $echo "$cmd$args" exit 0 fi ;; # libtool clean and uninstall mode clean | uninstall) modename="$modename: $mode" rm="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) rm="$rm $arg"; rmforce=yes ;; -*) rm="$rm $arg" ;; *) files="$files $arg" ;; esac done if test -z "$rm"; then $echo "$modename: you must specify an RM program" 1>&2 $echo "$help" 1>&2 exit 1 fi rmdirs= for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. objdir="$objdir" else objdir="$dir/$objdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` test $mode = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test $mode = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if (test -L "$file") >/dev/null 2>&1 \ || (test -h "$file") >/dev/null 2>&1 \ || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" if test $mode = uninstall; then if test -n "$library_names"; then # Do each command in the postuninstall commands. eval cmds=\"$postuninstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" if test $? != 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. eval cmds=\"$old_postuninstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" if test $? != 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. fi fi ;; *.lo) if test "$build_old_libs" = yes; then oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` rmfiles="$rmfiles $dir/$oldobj" fi ;; *) # Do a test to see if this is a libtool program. if test $mode = clean && (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$file rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi fi ;; esac $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then $show "rmdir $dir" $run rmdir $dir >/dev/null 2>&1 fi done exit $exit_status ;; "") $echo "$modename: you must specify a MODE" 1>&2 $echo "$generic_help" 1>&2 exit 1 ;; esac if test -z "$exec_cmd"; then $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$generic_help" 1>&2 exit 1 fi fi # test -z "$show_help" if test -n "$exec_cmd"; then eval exec $exec_cmd exit 1 fi # We need to display help for each of the modes. case $mode in "") $echo \ "Usage: $modename [OPTION]... [MODE-ARG]... Provide generalized library-building support services. --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --finish same as \`--mode=finish' --help display this help message and exit --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages --version print version information MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE." exit 0 ;; clean) $echo \ "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $echo \ "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $echo \ "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $echo \ "Usage: $modename [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $echo \ "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $echo \ "Usage: $modename [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -static do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $echo \ "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac echo $echo "Try \`$modename --help' for more information about other modes." exit 0 # Local Variables: # mode:shell-script # sh-indentation:2 # End: pdns-3.3/pdns/inflighter.cc0000644000014601777760000001460612136555572017213 0ustar00jenkinsnogroup00000000000000#include #include #include #include #include #include #include #include #include "iputils.hh" #include "statbag.hh" #include #include "namespaces.hh" using namespace boost::multi_index; struct TimeTag{}; template class Inflighter { public: Inflighter(Container& c, SenderReceiver& sr) : d_container(c), d_sr(sr), d_init(false) { d_burst = 2; d_maxInFlight = 5; d_timeoutSeconds = 3; d_unexpectedResponse = d_timeouts = 0; } void init() { d_iter = d_container.begin(); d_init=true; } bool run(); //!< keep calling this as long as it returns 1, or if it throws an exception unsigned int d_maxInFlight; unsigned int d_timeoutSeconds; int d_burst; uint64_t getTimeouts() { return d_timeouts; } uint64_t getUnexpecteds() { return d_unexpectedResponse; } private: struct TTDItem { typename Container::iterator iter; typename SenderReceiver::Identifier id; struct timeval sentTime, ttd; }; typedef multi_index_container< TTDItem, indexed_by< ordered_unique< member >, ordered_non_unique< tag, member > > >ttdwatch_t; Container& d_container; SenderReceiver& d_sr; ttdwatch_t d_ttdWatch; typename Container::iterator d_iter; bool d_init; uint64_t d_unexpectedResponse, d_timeouts; }; template bool Inflighter::run() { if(!d_init) init(); for(;;) { int burst = 0; // 'send' as many items as allowed, limited by 'max in flight' and our burst parameter (which limits query rate growth) while(d_iter != d_container.end() && d_ttdWatch.size() < d_maxInFlight) { TTDItem ttdi; ttdi.iter = d_iter++; ttdi.id = d_sr.send(*ttdi.iter); gettimeofday(&ttdi.sentTime, 0); ttdi.ttd = ttdi.sentTime; ttdi.ttd.tv_sec += d_timeoutSeconds; if(d_ttdWatch.count(ttdi.id)) { // cerr<<"DUPLICATE INSERT!"<sentTime.tv_sec) + (now.tv_usec - ival->sentTime.tv_usec); d_sr.deliverAnswer(*ival->iter, answer, usec); // deliver to sender/receiver d_ttdWatch.erase(ival); break; // we can send new questions! } else { // cerr<<"UNEXPECTED ANSWER: "< 10000 */ ) { // no new responses, time for some cleanup of the ttdWatch struct timeval now; gettimeofday(&now, 0); typedef typename ttdwatch_t::template index::type waiters_by_ttd_index_t; waiters_by_ttd_index_t& waiters_index = boost::multi_index::get(d_ttdWatch); // this provides a list of items sorted by age for(typename waiters_by_ttd_index_t::iterator valiter = waiters_index.begin(); valiter != waiters_index.end(); ) { if(valiter->ttd.tv_sec < now.tv_sec || (valiter->ttd.tv_sec == now.tv_sec && valiter->ttd.tv_usec < now.tv_usec)) { d_sr.deliverTimeout(valiter->id); // so backend can release id waiters_index.erase(valiter++); // cerr<<"Have timeout for id="<< valiter->id < 0) { char buf[512]; int len = recv(d_socket, buf, sizeof(buf), 0); string msg(buf, len); if(sscanf(msg.c_str(), "%d %d", &id, &i) != 2) { throw runtime_error("Invalid input"); } return 1; } return 0; } void deliverAnswer(int& i, int j) { cerr<<"We sent "< numbers; SendReceive sr; Inflighter, SendReceive> inflighter(numbers, sr); for(int n=0; n < 100; ++n) numbers.push_back(n*n); for(;;) { try { inflighter.run(); break; } catch(exception& e) { cerr<<"Caught exception: "< # Created: 1993-05-16 # Public domain # $Id$ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here pdns-3.3/pdns/version.cc0000644000014601777760000000357312155272633016541 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "logger.hh" #include "version.hh" #include "version_generated.h" static string productName(""); string compilerVersion() { #if defined(__clang__) return string("clang "__clang_version__); #elif defined(__GNUC__) return string("gcc "__VERSION__); #elif defined(_MSC_VER) return string("MSVC "<<_MSC_VER); #endif // add other compilers here return string("Unknown compiler"); } void showProductVersion() { theL()< #include #include #include #include "dnsrecords.hh" #define CASE_L(type, inval, zoneval, lineval, broken) case_t(type, std::string(inval), std::string(zoneval), std::string(lineval, sizeof(lineval)-1), broken) #define CASE_S(type, zoneval, lineval, broken) CASE_L(type, zoneval, zoneval, lineval, broken) BOOST_AUTO_TEST_SUITE(test_dnsrecords_cc) #define REC_CHECK_EQUAL(a,b) { if (val.get<4>()) { BOOST_WARN_EQUAL(a,b); } else { BOOST_CHECK_EQUAL(a,b); } } #define REC_CHECK_MESSAGE(cond,msg) { if (val.get<4>()) { BOOST_WARN_MESSAGE(cond,msg); } else { BOOST_CHECK_MESSAGE(cond,msg); } } typedef enum { zone, wire } case_type_enum_t; BOOST_AUTO_TEST_CASE(test_record_types) { // tuple contains typedef boost::tuple case_t; typedef std::list cases_t; reportAllTypes(); MRRecordContent::report(); IPSECKEYRecordContent::report(); KXRecordContent::report(); URLRecordContent::report(); MBOXFWRecordContent::report(); DHCIDRecordContent::report(); TSIGRecordContent::report(); // NB!!! WHEN ADDING A TEST MAKE SURE YOU PUT IT NEXT TO IT'S KIND // TO MAKE SURE TEST NUMBERING DOES NOT BREAK // why yes, they are unordered by name, how nice of you to notice cases_t cases = boost::assign::list_of (CASE_S(QType::A, "127.0.0.1", "\x7F\x00\x00\x01",false)) // local nameserver (CASE_L(QType::NS, "ns.rec.test", "ns.rec.test.", "\x02ns\xc0\x11",false)) // non-local nameserver (CASE_S(QType::NS, "ns.example.com.", "\x02ns\x07""example\x03""com\x00",false)) // local alias (CASE_L(QType::CNAME, "name.rec.test", "name.rec.test.", "\x04name\xc0\x11",false)) // non-local alias (CASE_S(QType::CNAME, "name.example.com.", "\x04name\x07""example\x03""com\x00",false)) // local names (CASE_S(QType::SOA, "ns.rec.test. hostmaster.test.rec. 2013051201 3600 3600 604800 120", "\x02ns\xc0\x11\x0ahostmaster\x04test\x03rec\x00\x77\xfc\xb9\x41\x00\x00\x0e\x10\x00\x00\x0e\x10\x00\x09\x3a\x80\x00\x00\x00\x78",false)) // local name without dots (CASE_L(QType::SOA, "ns.rec.test hostmaster.test.rec 2013051201 3600 3600 604800 120", "ns.rec.test. hostmaster.test.rec. 2013051201 3600 3600 604800 120", "\x02ns\xc0\x11\x0ahostmaster\x04test\x03rec\x00\x77\xfc\xb9\x41\x00\x00\x0e\x10\x00\x00\x0e\x10\x00\x09\x3a\x80\x00\x00\x00\x78",false)) // non-local names (CASE_S(QType::SOA, "ns.example.com. hostmaster.example.com. 2013051201 3600 3600 604800 120", "\x02ns\x07""example\x03""com\x00\x0ahostmaster\xc0\x28\x77\xfc\xb9\x41\x00\x00\x0e\x10\x00\x00\x0e\x10\x00\x09\x3a\x80\x00\x00\x00\x78",false)) // BROKEN TESTS (2) (deprecated) // local name (CASE_S(QType::MR, "newmailbox.rec.test.", "\x0anewmailbox\xc0\x11",false)) // non-local name (CASE_S(QType::MR, "newmailbox.example.com.", "\x0anewmailbox\x07""example\x03""com\x00",false)) // local name (CASE_L(QType::PTR, "ptr.rec.test", "ptr.rec.test.", "\x03ptr\xc0\x11",false)) // non-local name (CASE_L(QType::PTR, "ptr.example.com", "ptr.example.com.", "\x03ptr\x07""example\x03""com\x00",false)) (CASE_S(QType::HINFO, "\"i686\" \"Linux\"", "\x04i686\x05Linux",false)) (CASE_L(QType::HINFO, "i686 \"Linux\"", "\"i686\" \"Linux\"", "\x04i686\x05Linux",true)) (CASE_L(QType::HINFO, "\"i686\" Linux", "\"i686\" \"Linux\"", "\x04i686\x05Linux",false)) (CASE_L(QType::HINFO, "i686 Linux", "\"i686\" \"Linux\"", "\x04i686\x05Linux",true)) // local name (CASE_S(QType::MX, "10 mx.rec.test.", "\x00\x0a\02mx\xc0\x11",false)) // non-local name (CASE_S(QType::MX, "20 mx.example.com.", "\x00\x14\02mx\x07""example\x03""com\x00",false)) (CASE_S(QType::TXT, "\"short text\"", "\x0ashort text",false)) (CASE_S(QType::TXT, "\"long record test 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" \"2222222222\"", "\xff""long record test 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\x0a""2222222222",false)) (CASE_L(QType::TXT, "\"long record test 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222\"", "\"long record test 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\" \"2222222222\"", "\xff""long record test 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\x0a""2222222222",false)) (CASE_L(QType::TXT, "\"\\195\\133LAND ISLANDS\"", "\"\\195\\133LAND ISLANDS\"", "\x0e\xc3\x85LAND ISLANDS", false)) (CASE_L(QType::TXT, "\"\xc3\x85LAND ISLANDS\"", "\"\\195\\133LAND ISLANDS\"", "\x0e\xc3\x85LAND ISLANDS", false)) (CASE_L(QType::TXT, "\"nonbreakingtxt\"", "\"nonbreakingtxt\"", "\x0enonbreakingtxt",false)) // local name (CASE_S(QType::RP, "admin.rec.test. admin-info.rec.test.", "\x05""admin\x03rec\x04test\x00\x0a""admin-info\x03rec\x04test\x00",false)) // non-local name (CASE_S(QType::RP, "admin.example.com. admin-info.example.com.", "\x05""admin\x07""example\x03""com\x00\x0a""admin-info\x07""example\x03""com\x00",false)) // local name (CASE_S(QType::AFSDB, "1 afs-server.rec.test.", "\x00\x01\x0a""afs-server\x03rec\x04test\x00",false)) // non-local name (CASE_S(QType::AFSDB, "1 afs-server.example.com.", "\x00\x01\x0a""afs-server\x07""example\x03""com\x00",false)) // deprecated (and i don't know what i am doing wrong) (CASE_S(QType::KEY, "0 3 3 V19hwufL6LJARVIxzHDyGdvZ7dbQE0Kyl18yPIWj/sbCcsBbz7zO6Q2qgdzmWI3OvGNne2nxflhorhefKIMsUg==", "\x00\x00\x03\x03\x57\x5f\x61\xc2\xe7\xcb\xe8\xb2\x40\x45\x52\x31\xcc\x70\xf2\x19\xdb\xd9\xed\xd6\xd0\x13\x42\xb2\x97\x5f\x32\x3c\x85\xa3\xfe\xc6\xc2\x72\xc0\x5b\xcf\xbc\xce\xe9\x0d\xaa\x81\xdc\xe6\x58\x8d\xce\xbc\x63\x67\x7b\x69\xf1\x7e\x58\x68\xae\x17\x9f\x28\x83\x2c\x52",false)) (CASE_L(QType::LOC, "32 7 19 S 116 2 25 E", "32 7 19.000 S 116 2 25.000 E 0.00m 1.00m 10000.00m 10.00m", "\x00\x12\x16\x13\x79\x1b\x7d\x28\x98\xe6\x48\x68\x00\x98\x96\x80",false)) (CASE_L(QType::LOC, "32 7 19 S 116 2 25 E 10m", "32 7 19.000 S 116 2 25.000 E 10.00m 1.00m 10000.00m 10.00m", "\x00\x12\x16\x13\x79\x1b\x7d\x28\x98\xe6\x48\x68\x00\x98\x9a\x68",false)) (CASE_L(QType::LOC, "42 21 54 N 71 06 18 W -24m 30m", "42 21 54.000 N 71 6 18.000 W -24.00m 30.00m 10000.00m 10.00m", "\x00\x33\x16\x13\x89\x17\x2d\xd0\x70\xbe\x15\xf0\x00\x98\x8d\x20",false)) (CASE_L(QType::LOC, "42 21 43.952 N 71 5 6.344 W -24m 1m 200m", "42 21 43.952 N 71 5 6.344 W -24.00m 1.00m 200.00m 10.00m", "\x00\x12\x24\x13\x89\x17\x06\x90\x70\xbf\x2d\xd8\x00\x98\x8d\x20",false)) (CASE_S(QType::AAAA, "fe80::250:56ff:fe9b:114", "\xFE\x80\x00\x00\x00\x00\x00\x00\x02\x50\x56\xFF\xFE\x9B\x01\x14",false)) (CASE_S(QType::AAAA, "2a02:1b8:10:2::151", "\x2a\x02\x01\xb8\x00\x10\x00\x02\x00\x00\x00\x00\x00\x00\x01\x51",false)) (CASE_S(QType::AAAA, "::1", "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01",false)) // local name (CASE_S(QType::SRV, "10 10 5060 sip.rec.test.", "\x00\x0a\x00\x0a\x13\xc4\x03sip\x03rec\x04test\x00",false)) // non-local name (CASE_S(QType::SRV, "10 10 5060 sip.example.com.", "\x00\x0a\x00\x0a\x13\xc4\x03sip\x07""example\x03""com\x00",false)) (CASE_S(QType::NAPTR, "100 10 \"\" \"\" \"/urn:cid:.+@([^\\\\.]+\\\\.)(.*)$/\\\\2/i\" .", "\x00\x64\x00\x0a\x00\x00\x20/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\x00",false)) (CASE_S(QType::NAPTR, "100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.rec.test.", "\x00\x64\x00\x32\x01s\x10http+I2L+I2C+I2R\x00\x05_http\x04_tcp\x03rec\x04test\x00",false)) (CASE_S(QType::KX, "10 mail.rec.test.", "\x00\x0a\x04mail\x03rec\x04test\x00",false)) // X.509 as per PKIX (CASE_S(QType::CERT, "1 0 0 MIIB9DCCAV2gAwIBAgIJAKxUfFVXhw7HMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNVBAMMCHJlYy50ZXN0MB4XDTEzMDUxMjE5NDgwOVoXDTEzMDYxMTE5NDgwOVowEzERMA8GA1UEAwwIcmVjLnRlc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANKCu5aN/ewOXRPfzAo27XMXhYFCThCjfInTAUIEkzs6jBFZ/eyyIa/kFoiD0tAKwfFfykYU+9XgXeLjetD7rYt3SN3bzzCznoBGbGHHM0Fecrn0LV+tC/NfBB61Yx7e0AMUxmxIeLNRQW5ca5CW8qcIiiQ4fl0BScUjc5+E9QLHAgMBAAGjUDBOMB0GA1UdDgQWBBRzcVu/2bwrgkES+FhYbxZqr7mUgjAfBgNVHSMEGDAWgBRzcVu/2bwrgkES+FhYbxZqr7mUgjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAFVQ8dZBOasOhsWzA/xpAV0WdsqVkxBxrkGIRlbHHBFqOBOOz2MFSzUNx4mDy0qDKI28gcWmWaVsxoQ9VFLD6YRJuUoM8MDNcZDJbKpfDumjvvfnUAK+SiM2c4Ur3xpf0wanCA60/q2bOtFiB0tfAH6RVuIgMC3qjHAIaKEld+fE", "\x00\x01\x00\x00\x00\x30\x82\x01\xf4\x30\x82\x01\x5d\xa0\x03\x02\x01\x02\x02\x09\x00\xac\x54\x7c\x55\x57\x87\x0e\xc7\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x1e\x17\x0d\x31\x33\x30\x35\x31\x32\x31\x39\x34\x38\x30\x39\x5a\x17\x0d\x31\x33\x30\x36\x31\x31\x31\x39\x34\x38\x30\x39\x5a\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x81\x81\x00\x55\x50\xf1\xd6\x41\x39\xab\x0e\x86\xc5\xb3\x03\xfc\x69\x01\x5d\x16\x76\xca\x95\x93\x10\x71\xae\x41\x88\x46\x56\xc7\x1c\x11\x6a\x38\x13\x8e\xcf\x63\x05\x4b\x35\x0d\xc7\x89\x83\xcb\x4a\x83\x28\x8d\xbc\x81\xc5\xa6\x59\xa5\x6c\xc6\x84\x3d\x54\x52\xc3\xe9\x84\x49\xb9\x4a\x0c\xf0\xc0\xcd\x71\x90\xc9\x6c\xaa\x5f\x0e\xe9\xa3\xbe\xf7\xe7\x50\x02\xbe\x4a\x23\x36\x73\x85\x2b\xdf\x1a\x5f\xd3\x06\xa7\x08\x0e\xb4\xfe\xad\x9b\x3a\xd1\x62\x07\x4b\x5f\x00\x7e\x91\x56\xe2\x20\x30\x2d\xea\x8c\x70\x08\x68\xa1\x25\x77\xe7\xc4",false)) (CASE_L(QType::DS, "20642 8 2 04443ABE7E94C3985196BEAE5D548C727B044DDA5151E60D7CD76A9F D931D00E", "20642 8 2 04443abe7e94c3985196beae5d548c727b044dda5151e60d7cd76a9fd931d00e", "\x50\xa2\x08\x02\x04\x44\x3a\xbe\x7e\x94\xc3\x98\x51\x96\xbe\xae\x5d\x54\x8c\x72\x7b\x04\x4d\xda\x51\x51\xe6\x0d\x7c\xd7\x6a\x9f\xd9\x31\xd0\x0e",false)) (CASE_L(QType::DS, "20642 8 2 04443ABE7E94C3985196BEAE5D548C727B044DDA5151E60D7CD76A9F D931D00E", "20642 8 2 04443abe7e94c3985196beae5d548c727b044dda5151e60d7cd76a9fd931d00e", "\x50\xa2\x08\x02\x04\x44\x3a\xbe\x7e\x94\xc3\x98\x51\x96\xbe\xae\x5d\x54\x8c\x72\x7b\x04\x4d\xda\x51\x51\xe6\x0d\x7c\xd7\x6a\x9f\xd9\x31\xd0\x0e",false)) (CASE_S(QType::SSHFP, "1 1 aa65e3415a50d9b3519c2b17aceb815fc2538d88", "\x01\x01\xaa\x65\xe3\x41\x5a\x50\xd9\xb3\x51\x9c\x2b\x17\xac\xeb\x81\x5f\xc2\x53\x8d\x88",false)) // as per RFC4025 (CASE_S(QType::IPSECKEY, "255 0 0", "\xff\x00\x00",false)) (CASE_S(QType::IPSECKEY, "255 0 1 V19hwufL6LJARVIxzHDyGdvZ7dbQE0Kyl18yPIWj/sbCcsBbz7zO6Q2qgdzmWI3OvGNne2nxflhorhefKIMsUg==", "\xff\x00\x01\x57\x5f\x61\xc2\xe7\xcb\xe8\xb2\x40\x45\x52\x31\xcc\x70\xf2\x19\xdb\xd9\xed\xd6\xd0\x13\x42\xb2\x97\x5f\x32\x3c\x85\xa3\xfe\xc6\xc2\x72\xc0\x5b\xcf\xbc\xce\xe9\x0d\xaa\x81\xdc\xe6\x58\x8d\xce\xbc\x63\x67\x7b\x69\xf1\x7e\x58\x68\xae\x17\x9f\x28\x83\x2c\x52",false)) (CASE_S(QType::IPSECKEY, "255 1 0 127.0.0.1", "\xff\x01\x00\x7f\x00\x00\x01", false)) (CASE_S(QType::IPSECKEY, "255 2 0 fe80::250:56ff:fe9b:114", "\xff\x02\x00\xFE\x80\x00\x00\x00\x00\x00\x00\x02\x50\x56\xFF\xFE\x9B\x01\x14", false)) (CASE_S(QType::IPSECKEY, "10 1 1 127.0.0.1 V19hwufL6LJARVIxzHDyGdvZ7dbQE0Kyl18yPIWj/sbCcsBbz7zO6Q2qgdzmWI3OvGNne2nxflhorhefKIMsUg==", "\x0a\x01\x01\x7f\x00\x00\x01\x57\x5f\x61\xc2\xe7\xcb\xe8\xb2\x40\x45\x52\x31\xcc\x70\xf2\x19\xdb\xd9\xed\xd6\xd0\x13\x42\xb2\x97\x5f\x32\x3c\x85\xa3\xfe\xc6\xc2\x72\xc0\x5b\xcf\xbc\xce\xe9\x0d\xaa\x81\xdc\xe6\x58\x8d\xce\xbc\x63\x67\x7b\x69\xf1\x7e\x58\x68\xae\x17\x9f\x28\x83\x2c\x52", false)) (CASE_S(QType::IPSECKEY, "10 2 1 fe80::250:56ff:fe9b:114 V19hwufL6LJARVIxzHDyGdvZ7dbQE0Kyl18yPIWj/sbCcsBbz7zO6Q2qgdzmWI3OvGNne2nxflhorhefKIMsUg==", "\x0a\x02\x01\xFE\x80\x00\x00\x00\x00\x00\x00\x02\x50\x56\xFF\xFE\x9B\x01\x14\x57\x5f\x61\xc2\xe7\xcb\xe8\xb2\x40\x45\x52\x31\xcc\x70\xf2\x19\xdb\xd9\xed\xd6\xd0\x13\x42\xb2\x97\x5f\x32\x3c\x85\xa3\xfe\xc6\xc2\x72\xc0\x5b\xcf\xbc\xce\xe9\x0d\xaa\x81\xdc\xe6\x58\x8d\xce\xbc\x63\x67\x7b\x69\xf1\x7e\x58\x68\xae\x17\x9f\x28\x83\x2c\x52", false)) (CASE_S(QType::IPSECKEY, "10 3 1 gw.rec.test. V19hwufL6LJARVIxzHDyGdvZ7dbQE0Kyl18yPIWj/sbCcsBbz7zO6Q2qgdzmWI3OvGNne2nxflhorhefKIMsUg==", "\x0a\x03\x01\x02gw\x03rec\x04test\x00\x57\x5f\x61\xc2\xe7\xcb\xe8\xb2\x40\x45\x52\x31\xcc\x70\xf2\x19\xdb\xd9\xed\xd6\xd0\x13\x42\xb2\x97\x5f\x32\x3c\x85\xa3\xfe\xc6\xc2\x72\xc0\x5b\xcf\xbc\xce\xe9\x0d\xaa\x81\xdc\xe6\x58\x8d\xce\xbc\x63\x67\x7b\x69\xf1\x7e\x58\x68\xae\x17\x9f\x28\x83\x2c\x52",false)) (CASE_S(QType::RRSIG, "SOA 8 3 300 20130523000000 20130509000000 54216 rec.test. ecWKD/OsdAiXpbM/sgPT82KVD/WiQnnqcxoJgiH3ixHa+LOAcYU7FG7V4BRRJxLriY1e0rB2gAs3kCel9D4bzfK6wAqG4Di/eHUgHptRlaR2ycELJ4t1pjzrnuGiIzA1wM2izRmeE+Xoy1367Qu0pOz5DLzTfQITWFsB2iUzN4Y=", "\x00\x06\x08\x03\x00\x00\x01\x2c\x51\x9d\x5c\x00\x51\x8a\xe7\x00\xd3\xc8\x03\x72\x65\x63\x04\x74\x65\x73\x74\x00\x79\xc5\x8a\x0f\xf3\xac\x74\x08\x97\xa5\xb3\x3f\xb2\x03\xd3\xf3\x62\x95\x0f\xf5\xa2\x42\x79\xea\x73\x1a\x09\x82\x21\xf7\x8b\x11\xda\xf8\xb3\x80\x71\x85\x3b\x14\x6e\xd5\xe0\x14\x51\x27\x12\xeb\x89\x8d\x5e\xd2\xb0\x76\x80\x0b\x37\x90\x27\xa5\xf4\x3e\x1b\xcd\xf2\xba\xc0\x0a\x86\xe0\x38\xbf\x78\x75\x20\x1e\x9b\x51\x95\xa4\x76\xc9\xc1\x0b\x27\x8b\x75\xa6\x3c\xeb\x9e\xe1\xa2\x23\x30\x35\xc0\xcd\xa2\xcd\x19\x9e\x13\xe5\xe8\xcb\x5d\xfa\xed\x0b\xb4\xa4\xec\xf9\x0c\xbc\xd3\x7d\x02\x13\x58\x5b\x01\xda\x25\x33\x37\x86",false)) (CASE_S(QType::NSEC, "a.rec.test. A NS SOA MX AAAA RRSIG NSEC DNSKEY", "\x01""a\x03rec\x04test\x00\x00\x07\x62\x01\x00\x08\x00\x03\x80",false)) (CASE_S(QType::DNSKEY, "257 3 5 AwEAAZVtlHc8O4TVmlGx/PGJTc7hbVjMR7RywxLuAm1dqgyHvgNRD7chYLsALOdZKW6VRvusbyhoOPilnh8XpucBDqjGD6lIemsURz7drZEqcLupVA0TPxXABZ6auJ3jumqIhSOcLj9rpSwI4xuWt0yu6LR9tL2q8+A0yEZxcAaKS+Wq0fExJ93NxgXl1/fY+JcYQvonjd31GxXXef9uf0exXyzowh5h8+IIBETU+ZiYVB5BqiwkICZL/OX57idm99ycA2/tIen66F8u2ueTvgPcecnoqHvW0MtLQKzeNmqdGNthHhV5di0SZdMZQeo/izs68uN2WzqQDZy9Ec2JwBTbxWE=", "\x01\x01\x03\x05\x03\x01\x00\x01\x95\x6d\x94\x77\x3c\x3b\x84\xd5\x9a\x51\xb1\xfc\xf1\x89\x4d\xce\xe1\x6d\x58\xcc\x47\xb4\x72\xc3\x12\xee\x02\x6d\x5d\xaa\x0c\x87\xbe\x03\x51\x0f\xb7\x21\x60\xbb\x00\x2c\xe7\x59\x29\x6e\x95\x46\xfb\xac\x6f\x28\x68\x38\xf8\xa5\x9e\x1f\x17\xa6\xe7\x01\x0e\xa8\xc6\x0f\xa9\x48\x7a\x6b\x14\x47\x3e\xdd\xad\x91\x2a\x70\xbb\xa9\x54\x0d\x13\x3f\x15\xc0\x05\x9e\x9a\xb8\x9d\xe3\xba\x6a\x88\x85\x23\x9c\x2e\x3f\x6b\xa5\x2c\x08\xe3\x1b\x96\xb7\x4c\xae\xe8\xb4\x7d\xb4\xbd\xaa\xf3\xe0\x34\xc8\x46\x71\x70\x06\x8a\x4b\xe5\xaa\xd1\xf1\x31\x27\xdd\xcd\xc6\x05\xe5\xd7\xf7\xd8\xf8\x97\x18\x42\xfa\x27\x8d\xdd\xf5\x1b\x15\xd7\x79\xff\x6e\x7f\x47\xb1\x5f\x2c\xe8\xc2\x1e\x61\xf3\xe2\x08\x04\x44\xd4\xf9\x98\x98\x54\x1e\x41\xaa\x2c\x24\x20\x26\x4b\xfc\xe5\xf9\xee\x27\x66\xf7\xdc\x9c\x03\x6f\xed\x21\xe9\xfa\xe8\x5f\x2e\xda\xe7\x93\xbe\x03\xdc\x79\xc9\xe8\xa8\x7b\xd6\xd0\xcb\x4b\x40\xac\xde\x36\x6a\x9d\x18\xdb\x61\x1e\x15\x79\x76\x2d\x12\x65\xd3\x19\x41\xea\x3f\x8b\x3b\x3a\xf2\xe3\x76\x5b\x3a\x90\x0d\x9c\xbd\x11\xcd\x89\xc0\x14\xdb\xc5\x61",false)) (CASE_S(QType::DHCID, "AAAB92JtyyO73zqENgu9LVua+0PZoeCcKapTw4asbYmx5F4=", "\x00\x00\x01\xf7\x62\x6d\xcb\x23\xbb\xdf\x3a\x84\x36\x0b\xbd\x2d\x5b\x9a\xfb\x43\xd9\xa1\xe0\x9c\x29\xaa\x53\xc3\x86\xac\x6d\x89\xb1\xe4\x5e",false)) (CASE_S(QType::DHCID, "AAEB92JtyyO73zqENgu9LVua+0PZoeCcKapTw4asbYmx5F4=", "\x00\x01\x01\xf7\x62\x6d\xcb\x23\xbb\xdf\x3a\x84\x36\x0b\xbd\x2d\x5b\x9a\xfb\x43\xd9\xa1\xe0\x9c\x29\xaa\x53\xc3\x86\xac\x6d\x89\xb1\xe4\x5e",false)) (CASE_S(QType::DHCID, "AAIB92JtyyO73zqENgu9LVua+0PZoeCcKapTw4asbYmx5F4=", "\x00\x02\x01\xf7\x62\x6d\xcb\x23\xbb\xdf\x3a\x84\x36\x0b\xbd\x2d\x5b\x9a\xfb\x43\xd9\xa1\xe0\x9c\x29\xaa\x53\xc3\x86\xac\x6d\x89\xb1\xe4\x5e",false)) (CASE_S(QType::NSEC3, "1 1 1 f00b RPF1JGFCCNFA7STPTIJ9FPFNM40A4FLL NS SOA RRSIG DNSKEY NSEC3PARAM", "\x01\x01\x00\x01\x02\xf0\x0b\x14\xde\x5e\x19\xc1\xec\x65\xde\xa3\xf3\xb9\xec\xa6\x97\xe5\xf7\xb1\x00\xa2\x3e\xb5\x00\x07\x22\x00\x00\x00\x00\x02\x90",false)) (CASE_S(QType::NSEC3PARAM, "1 0 1 f00b", "\x01\x00\x00\x01\x02\xf0\x0b",false)) (CASE_S(QType::TLSA, "0 0 0 308201f43082015da003020102020900ac547c5557870ec7300d06092a864886f70d010105050030133111300f06035504030c087265632e74657374301e170d3133303531323139343830395a170d3133303631313139343830395a30133111300f06035504030c087265632e7465737430819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001a350304e301d0603551d0e0416041473715bbfd9bc2b824112f858586f166aafb99482301f0603551d2304183016801473715bbfd9bc2b824112f858586f166aafb99482300c0603551d13040530030101ff300d06092a864886f70d0101050500038181005550f1d64139ab0e86c5b303fc69015d1676ca95931071ae41884656c71c116a38138ecf63054b350dc78983cb4a83288dbc81c5a659a56cc6843d5452c3e98449b94a0cf0c0cd7190c96caa5f0ee9a3bef7e75002be4a233673852bdf1a5fd306a7080eb4fead9b3ad162074b5f007e9156e220302dea8c700868a12577e7c4", "\x00\x00\x00\x30\x82\x01\xf4\x30\x82\x01\x5d\xa0\x03\x02\x01\x02\x02\x09\x00\xac\x54\x7c\x55\x57\x87\x0e\xc7\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x1e\x17\x0d\x31\x33\x30\x35\x31\x32\x31\x39\x34\x38\x30\x39\x5a\x17\x0d\x31\x33\x30\x36\x31\x31\x31\x39\x34\x38\x30\x39\x5a\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x81\x81\x00\x55\x50\xf1\xd6\x41\x39\xab\x0e\x86\xc5\xb3\x03\xfc\x69\x01\x5d\x16\x76\xca\x95\x93\x10\x71\xae\x41\x88\x46\x56\xc7\x1c\x11\x6a\x38\x13\x8e\xcf\x63\x05\x4b\x35\x0d\xc7\x89\x83\xcb\x4a\x83\x28\x8d\xbc\x81\xc5\xa6\x59\xa5\x6c\xc6\x84\x3d\x54\x52\xc3\xe9\x84\x49\xb9\x4a\x0c\xf0\xc0\xcd\x71\x90\xc9\x6c\xaa\x5f\x0e\xe9\xa3\xbe\xf7\xe7\x50\x02\xbe\x4a\x23\x36\x73\x85\x2b\xdf\x1a\x5f\xd3\x06\xa7\x08\x0e\xb4\xfe\xad\x9b\x3a\xd1\x62\x07\x4b\x5f\x00\x7e\x91\x56\xe2\x20\x30\x2d\xea\x8c\x70\x08\x68\xa1\x25\x77\xe7\xc4",false)) (CASE_S(QType::TLSA, "0 1 0 30819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001", "\x00\x01\x00\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01",false)) (CASE_S(QType::TLSA, "1 0 0 308201f43082015da003020102020900ac547c5557870ec7300d06092a864886f70d010105050030133111300f06035504030c087265632e74657374301e170d3133303531323139343830395a170d3133303631313139343830395a30133111300f06035504030c087265632e7465737430819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001a350304e301d0603551d0e0416041473715bbfd9bc2b824112f858586f166aafb99482301f0603551d2304183016801473715bbfd9bc2b824112f858586f166aafb99482300c0603551d13040530030101ff300d06092a864886f70d0101050500038181005550f1d64139ab0e86c5b303fc69015d1676ca95931071ae41884656c71c116a38138ecf63054b350dc78983cb4a83288dbc81c5a659a56cc6843d5452c3e98449b94a0cf0c0cd7190c96caa5f0ee9a3bef7e75002be4a233673852bdf1a5fd306a7080eb4fead9b3ad162074b5f007e9156e220302dea8c700868a12577e7c4", "\x01\x00\x00\x30\x82\x01\xf4\x30\x82\x01\x5d\xa0\x03\x02\x01\x02\x02\x09\x00\xac\x54\x7c\x55\x57\x87\x0e\xc7\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x1e\x17\x0d\x31\x33\x30\x35\x31\x32\x31\x39\x34\x38\x30\x39\x5a\x17\x0d\x31\x33\x30\x36\x31\x31\x31\x39\x34\x38\x30\x39\x5a\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x81\x81\x00\x55\x50\xf1\xd6\x41\x39\xab\x0e\x86\xc5\xb3\x03\xfc\x69\x01\x5d\x16\x76\xca\x95\x93\x10\x71\xae\x41\x88\x46\x56\xc7\x1c\x11\x6a\x38\x13\x8e\xcf\x63\x05\x4b\x35\x0d\xc7\x89\x83\xcb\x4a\x83\x28\x8d\xbc\x81\xc5\xa6\x59\xa5\x6c\xc6\x84\x3d\x54\x52\xc3\xe9\x84\x49\xb9\x4a\x0c\xf0\xc0\xcd\x71\x90\xc9\x6c\xaa\x5f\x0e\xe9\xa3\xbe\xf7\xe7\x50\x02\xbe\x4a\x23\x36\x73\x85\x2b\xdf\x1a\x5f\xd3\x06\xa7\x08\x0e\xb4\xfe\xad\x9b\x3a\xd1\x62\x07\x4b\x5f\x00\x7e\x91\x56\xe2\x20\x30\x2d\xea\x8c\x70\x08\x68\xa1\x25\x77\xe7\xc4",false)) (CASE_S(QType::TLSA, "1 1 0 30819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001", "\x01\x01\x00\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01",false)) (CASE_S(QType::TLSA, "1 0 1 6acea2f68b03d9efe97a967e137aca6ac3a89490d532d87806d9e9c257668453", "\x01\x00\x01\x6a\xce\xa2\xf6\x8b\x03\xd9\xef\xe9\x7a\x96\x7e\x13\x7a\xca\x6a\xc3\xa8\x94\x90\xd5\x32\xd8\x78\x06\xd9\xe9\xc2\x57\x66\x84\x53",false)) (CASE_S(QType::TLSA, "1 0 2 e6dce237992803488d11d828b7728deddd4577de73d7d078338c8a45880beddff98e076a28bf8e3068da8e73667b802a721c95d7323b038c60200a430cb6fbd4", "\x01\x00\x02\xe6\xdc\xe2\x37\x99\x28\x03\x48\x8d\x11\xd8\x28\xb7\x72\x8d\xed\xdd\x45\x77\xde\x73\xd7\xd0\x78\x33\x8c\x8a\x45\x88\x0b\xed\xdf\xf9\x8e\x07\x6a\x28\xbf\x8e\x30\x68\xda\x8e\x73\x66\x7b\x80\x2a\x72\x1c\x95\xd7\x32\x3b\x03\x8c\x60\x20\x0a\x43\x0c\xb6\xfb\xd4",false)) (CASE_S(QType::TLSA, "2 0 0 308201f43082015da003020102020900ac547c5557870ec7300d06092a864886f70d010105050030133111300f06035504030c087265632e74657374301e170d3133303531323139343830395a170d3133303631313139343830395a30133111300f06035504030c087265632e7465737430819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001a350304e301d0603551d0e0416041473715bbfd9bc2b824112f858586f166aafb99482301f0603551d2304183016801473715bbfd9bc2b824112f858586f166aafb99482300c0603551d13040530030101ff300d06092a864886f70d0101050500038181005550f1d64139ab0e86c5b303fc69015d1676ca95931071ae41884656c71c116a38138ecf63054b350dc78983cb4a83288dbc81c5a659a56cc6843d5452c3e98449b94a0cf0c0cd7190c96caa5f0ee9a3bef7e75002be4a233673852bdf1a5fd306a7080eb4fead9b3ad162074b5f007e9156e220302dea8c700868a12577e7c4", "\x02\x00\x00\x30\x82\x01\xf4\x30\x82\x01\x5d\xa0\x03\x02\x01\x02\x02\x09\x00\xac\x54\x7c\x55\x57\x87\x0e\xc7\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x1e\x17\x0d\x31\x33\x30\x35\x31\x32\x31\x39\x34\x38\x30\x39\x5a\x17\x0d\x31\x33\x30\x36\x31\x31\x31\x39\x34\x38\x30\x39\x5a\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x81\x81\x00\x55\x50\xf1\xd6\x41\x39\xab\x0e\x86\xc5\xb3\x03\xfc\x69\x01\x5d\x16\x76\xca\x95\x93\x10\x71\xae\x41\x88\x46\x56\xc7\x1c\x11\x6a\x38\x13\x8e\xcf\x63\x05\x4b\x35\x0d\xc7\x89\x83\xcb\x4a\x83\x28\x8d\xbc\x81\xc5\xa6\x59\xa5\x6c\xc6\x84\x3d\x54\x52\xc3\xe9\x84\x49\xb9\x4a\x0c\xf0\xc0\xcd\x71\x90\xc9\x6c\xaa\x5f\x0e\xe9\xa3\xbe\xf7\xe7\x50\x02\xbe\x4a\x23\x36\x73\x85\x2b\xdf\x1a\x5f\xd3\x06\xa7\x08\x0e\xb4\xfe\xad\x9b\x3a\xd1\x62\x07\x4b\x5f\x00\x7e\x91\x56\xe2\x20\x30\x2d\xea\x8c\x70\x08\x68\xa1\x25\x77\xe7\xc4",false)) (CASE_S(QType::TLSA, "2 1 0 30819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001", "\x02\x01\x00\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01",false)) (CASE_S(QType::TLSA, "3 0 0 308201f43082015da003020102020900ac547c5557870ec7300d06092a864886f70d010105050030133111300f06035504030c087265632e74657374301e170d3133303531323139343830395a170d3133303631313139343830395a30133111300f06035504030c087265632e7465737430819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001a350304e301d0603551d0e0416041473715bbfd9bc2b824112f858586f166aafb99482301f0603551d2304183016801473715bbfd9bc2b824112f858586f166aafb99482300c0603551d13040530030101ff300d06092a864886f70d0101050500038181005550f1d64139ab0e86c5b303fc69015d1676ca95931071ae41884656c71c116a38138ecf63054b350dc78983cb4a83288dbc81c5a659a56cc6843d5452c3e98449b94a0cf0c0cd7190c96caa5f0ee9a3bef7e75002be4a233673852bdf1a5fd306a7080eb4fead9b3ad162074b5f007e9156e220302dea8c700868a12577e7c4", "\x03\x00\x00\x30\x82\x01\xf4\x30\x82\x01\x5d\xa0\x03\x02\x01\x02\x02\x09\x00\xac\x54\x7c\x55\x57\x87\x0e\xc7\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x1e\x17\x0d\x31\x33\x30\x35\x31\x32\x31\x39\x34\x38\x30\x39\x5a\x17\x0d\x31\x33\x30\x36\x31\x31\x31\x39\x34\x38\x30\x39\x5a\x30\x13\x31\x11\x30\x0f\x06\x03\x55\x04\x03\x0c\x08\x72\x65\x63\x2e\x74\x65\x73\x74\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16\x04\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30\x16\x80\x14\x73\x71\x5b\xbf\xd9\xbc\x2b\x82\x41\x12\xf8\x58\x58\x6f\x16\x6a\xaf\xb9\x94\x82\x30\x0c\x06\x03\x55\x1d\x13\x04\x05\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x81\x81\x00\x55\x50\xf1\xd6\x41\x39\xab\x0e\x86\xc5\xb3\x03\xfc\x69\x01\x5d\x16\x76\xca\x95\x93\x10\x71\xae\x41\x88\x46\x56\xc7\x1c\x11\x6a\x38\x13\x8e\xcf\x63\x05\x4b\x35\x0d\xc7\x89\x83\xcb\x4a\x83\x28\x8d\xbc\x81\xc5\xa6\x59\xa5\x6c\xc6\x84\x3d\x54\x52\xc3\xe9\x84\x49\xb9\x4a\x0c\xf0\xc0\xcd\x71\x90\xc9\x6c\xaa\x5f\x0e\xe9\xa3\xbe\xf7\xe7\x50\x02\xbe\x4a\x23\x36\x73\x85\x2b\xdf\x1a\x5f\xd3\x06\xa7\x08\x0e\xb4\xfe\xad\x9b\x3a\xd1\x62\x07\x4b\x5f\x00\x7e\x91\x56\xe2\x20\x30\x2d\xea\x8c\x70\x08\x68\xa1\x25\x77\xe7\xc4",false)) (CASE_S(QType::TLSA, "3 1 0 30819f300d06092a864886f70d010101050003818d0030818902818100d282bb968dfdec0e5d13dfcc0a36ed73178581424e10a37c89d3014204933b3a8c1159fdecb221afe4168883d2d00ac1f15fca4614fbd5e05de2e37ad0fbad8b7748dddbcf30b39e80466c61c733415e72b9f42d5fad0bf35f041eb5631eded00314c66c4878b351416e5c6b9096f2a7088a24387e5d0149c523739f84f502c70203010001", "\x03\x01\x00\x30\x81\x9f\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x81\x8d\x00\x30\x81\x89\x02\x81\x81\x00\xd2\x82\xbb\x96\x8d\xfd\xec\x0e\x5d\x13\xdf\xcc\x0a\x36\xed\x73\x17\x85\x81\x42\x4e\x10\xa3\x7c\x89\xd3\x01\x42\x04\x93\x3b\x3a\x8c\x11\x59\xfd\xec\xb2\x21\xaf\xe4\x16\x88\x83\xd2\xd0\x0a\xc1\xf1\x5f\xca\x46\x14\xfb\xd5\xe0\x5d\xe2\xe3\x7a\xd0\xfb\xad\x8b\x77\x48\xdd\xdb\xcf\x30\xb3\x9e\x80\x46\x6c\x61\xc7\x33\x41\x5e\x72\xb9\xf4\x2d\x5f\xad\x0b\xf3\x5f\x04\x1e\xb5\x63\x1e\xde\xd0\x03\x14\xc6\x6c\x48\x78\xb3\x51\x41\x6e\x5c\x6b\x90\x96\xf2\xa7\x08\x8a\x24\x38\x7e\x5d\x01\x49\xc5\x23\x73\x9f\x84\xf5\x02\xc7\x02\x03\x01\x00\x01",false)) (CASE_S(QType::SPF, "\"v=spf1 a:mail.rec.test ~all\"", "\x1bv=spf1 a:mail.rec.test ~all",false)) (CASE_S(QType::EUI48, "00-11-22-33-44-55", "\x00\x11\x22\x33\x44\x55",false)) (CASE_S(QType::EUI64, "00-11-22-33-44-55-66-77", "\x00\x11\x22\x33\x44\x55\x66\x77",false)) //(CASE_S(QType::TSIG, "HMAC-MD5.SIG-ALG.REG.INT. 1368386956 60 16 TkbpD66/Mtgo8GUEFZIwhg== 12345 0 0", "\x08HMAC-MD5\x07SIG-ALG\x03REG\x03INT\x00\x00\x00\x51\x8f\xed\x8c\x00\x3c\x00\x10\x4e\x46\xe9\x0f\xae\xbf\x32\xd8\x28\xf0\x65\x04\x15\x92\x30\x86\x30\x39\x00\x00\x00\x00",false)) //(CASE_S(QType::TSIG, "HMAC-MD5.SIG-ALG.REG.INT. 1368386956 60 16 TkbpD66/Mtgo8GUEFZIwhg== 12345 18 16 TkbpD66/Mtgo8GUEFZIwhg==", "\x08HMAC-MD5\x07SIG-ALG\x03REG\x03INT\x00\x00\x00\x51\x8f\xed\x8c\x00\x3c\x00\x10\x4e\x46\xe9\x0f\xae\xbf\x32\xd8\x28\xf0\x65\x04\x15\x92\x30\x86\x30\x39\x00\x12\x00\x10\x4e\x46\xe9\x0f\xae\xbf\x32\xd8\x28\xf0\x65\x04\x15\x92\x30\x86",true)) /* (CASE_S(QType::URL, "http://server.rec.test/", "\x17http://server.rec.test/",false)) (CASE_S(QType::MBOXFW, "you@yourcompany.com", "line format",false)) (CASE_S(QType::CURL, "http://server.rec.test/", "\x17http://server.rec.test/",false)) (CASE_S(QType::ADDR, "zone format", "line format",false)) */ (CASE_S(QType::DLV, "20642 8 2 04443abe7e94c3985196beae5d548c727b044dda5151e60d7cd76a9fd931d00e", "\x50\xa2\x08\x02\x04\x44\x3a\xbe\x7e\x94\xc3\x98\x51\x96\xbe\xae\x5d\x54\x8c\x72\x7b\x04\x4d\xda\x51\x51\xe6\x0d\x7c\xd7\x6a\x9f\xd9\x31\xd0\x0e",false)) ; int n=0; int lq=-1; BOOST_FOREACH(const cases_t::value_type& val, cases) { QType q(val.get<0>()); if (lq != q.getCode()) n = 0; lq = q.getCode(); n++; BOOST_TEST_CHECKPOINT("Checking record type " << q.getName() << " test #" << n); BOOST_TEST_MESSAGE("Checking record type " << q.getName() << " test #" << n); try { DNSRecordContent *rec; std::string recData; if (q.getCode() != QType::TSIG) { rec = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()); BOOST_CHECK_MESSAGE(rec != NULL, "mastermake( " << q.getCode() << ", 1, " << val.get<1>() << ") returned NULL"); if (rec == NULL) continue; // now verify the record (note that this will be same as *zone* value (except for certain QTypes) switch(q.getCode()) { case QType::NS: case QType::PTR: case QType::MX: case QType::CNAME: case QType::SOA: case QType::TXT: // check *input* value instead REC_CHECK_EQUAL(rec->getZoneRepresentation(), val.get<1>()); break; default: REC_CHECK_EQUAL(rec->getZoneRepresentation(), val.get<2>()); } recData = rec->serialize("rec.test"); } else { boost::shared_ptr rec3 = DNSRecordContent::unserialize("rec.test",q.getCode(),(val.get<3>())); // TSIG special, only works the other way recData = rec3->serialize("rec.test"); } boost::shared_ptr rec2 = DNSRecordContent::unserialize("rec.test",q.getCode(),recData); BOOST_CHECK_MESSAGE(rec2 != NULL, "unserialize(rec.test, " << q.getCode() << ", recData) returned NULL"); if (rec2 == NULL) continue; // now verify the zone representation (here it can be different!) REC_CHECK_EQUAL(rec2->getZoneRepresentation(), val.get<2>()); // and last, check the wire format (using hex format for error readability) string cmpData = makeHexDump(val.get<3>()); recData = makeHexDump(recData); REC_CHECK_EQUAL(recData, cmpData); } catch (std::runtime_error &err) { REC_CHECK_MESSAGE(false, "Failed to verify " << q.getName() << ": " << err.what()); } } } bool test_dnsrecords_cc_predicate( std::runtime_error const &ex ) { return true; } // these *MUST NOT* parse properly! BOOST_AUTO_TEST_CASE(test_record_types_bad_values) { // qtype, value, zone/wire format, broken typedef boost::tuple case_t; typedef std::list cases_t; cases_t cases = boost::assign::list_of (case_t(QType::A, "932.521.256.42", zone, false)) // hollywood IP (case_t(QType::A, "932.521", zone, false)) // truncated IP (case_t(QType::A, "\xca\xec\x00", wire, false)) // truncated wire value (case_t(QType::AAAA, "23:00", zone, false)) // time when this test was written (case_t(QType::AAAA, "23:00::15::43", zone, false)) // double compression (case_t(QType::AAAA, "2a23:00::15::", zone, false)) // ditto (case_t(QType::AAAA, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff", zone, false)) // truncated wire value ; int n=0; int lq=-1; BOOST_FOREACH(const cases_t::value_type& val, cases) { QType q(val.get<0>()); if (lq != q.getCode()) n = 0; lq = q.getCode(); n++; BOOST_TEST_CHECKPOINT("Checking bad value for record type " << q.getName() << " test #" << n); BOOST_TEST_MESSAGE("Checking bad value for record type " << q.getName() << " test #" << n); if (val.get<2>()) { BOOST_WARN_EXCEPTION( DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()), std::runtime_error, test_dnsrecords_cc_predicate ); } else { BOOST_CHECK_EXCEPTION( DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()), std::runtime_error, test_dnsrecords_cc_predicate ); } }; } // special opt record test, because opt is odd BOOST_AUTO_TEST_CASE(test_opt_record_in) { EDNSOpts eo; // test that nsid gets parsed into system std::string packet("\xf0\x01\x01\x00\x00\x01\x00\x01\x00\x00\x00\x01\x03www\x08powerdns\x03""com\x00\x00\x01\x00\x01\x03www\x08powerdns\x03""com\x00\x00\x01\x00\x01\x00\x00\x00\x10\x00\x04\x7f\x00\x00\x01\x00\x00\x29\x05\x00\x00\x00\x00\x00\x00\x0c\x00\x03\x00\x08powerdns",89); OPTRecordContent::report(); MOADNSParser mdp((char*)&*packet.begin(), (unsigned int)packet.size()); getEDNSOpts(mdp, &eo); // this should contain NSID now BOOST_CHECK_EQUAL(eo.d_packetsize, 1280); // it should contain NSID option with value 'powerdns', and nothing else BOOST_CHECK_EQUAL(eo.d_options[0].first, 3); // nsid BOOST_CHECK_EQUAL(eo.d_options[0].second, "powerdns"); } BOOST_AUTO_TEST_CASE(test_opt_record_out) { vector pak; vector > opts; DNSPacketWriter pw(pak, "www.powerdns.com", ns_t_a); pw.startRecord("www.powerdns.com", ns_t_a, 16, 1, DNSPacketWriter::ANSWER); pw.xfrIP(0x0100007f); opts.push_back(pair(3, "powerdns")); pw.addOpt(1280, 0, 0, opts); pw.getHeader()->id = 0x01f0; pw.getHeader()->rd = 1; pw.commit(); // see if we can build a DNS packet that looks like this... std::string packet("\xf0\x01\x01\x00\x00\x01\x00\x01\x00\x00\x00\x01\x03www\x08powerdns\x03""com\x00\x00\x01\x00\x01\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\x10\x00\x04\x7f\x00\x00\x01\x00\x00\x29\x05\x00\x00\x00\x00\x00\x00\x0c\x00\x03\x00\x08powerdns",73); BOOST_CHECK_EQUAL(makeHexDump(std::string(pak.begin(),pak.end())), makeHexDump(packet)); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/randomhelper.cc0000644000014601777760000000165312136555572017536 0ustar00jenkinsnogroup00000000000000#include "misc.hh" #include "logger.hh" #include #include #include #include "dns_random.hh" void seedRandom(const string& source) { L<. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # 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. # Usage: # ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... # * INPUT is the input file # * OUTPUT is file PROG generates # * DESIRED is file we actually want # * PROGRAM is program to run # * ARGS are passed to PROG # Any number of OUTPUT,DESIRED pairs may be used. # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'` echo "got $input_rx" pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname $prog ${1+"$@"} "$input" status=$? if test $status -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # Edit out `#line' or `#' directives. We don't want the # resulting debug information to point at an absolute srcdir; # it is better for it to just mention the .y file with no # path. sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$? else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then status=1 fi fi shift shift first=no done else status=$? fi # Remove the directory. cd .. rm -rf $dirname exit $status pdns-3.3/pdns/recpacketcache.cc0000644000014601777760000000503512136555572020001 0ustar00jenkinsnogroup00000000000000#include #include #include "recpacketcache.hh" #include "cachecleaner.hh" #include "dns.hh" #include "namespaces.hh" #include "lock.hh" RecursorPacketCache::RecursorPacketCache() { d_hits = d_misses = 0; } int RecursorPacketCache::doWipePacketCache(const string& name, uint16_t qtype) { int count=0; for(packetCache_t::iterator iter = d_packetCache.begin(); iter != d_packetCache.end();) { const struct dnsheader* packet = reinterpret_cast((*iter).d_packet.c_str()); if (packet->qdcount > 0) { // find out type const struct dnsrecordheader *header = reinterpret_cast((*iter).d_packet.c_str()+sizeof(struct dnsheader)); uint16_t type = header->d_type; std::string domain=questionExpand((*iter).d_packet.c_str(), (*iter).d_packet.size(), type); if (pdns_iequals(name,domain)) { iter = d_packetCache.erase(iter); count++; } else iter++; } } return count; } bool RecursorPacketCache::getResponsePacket(const std::string& queryPacket, time_t now, std::string* responsePacket, uint32_t* age) { struct Entry e; e.d_packet=queryPacket; packetCache_t::const_iterator iter = d_packetCache.find(e); if(iter == d_packetCache.end()) { d_misses++; return false; } if((uint32_t)now < iter->d_ttd) { // it is fresh! // cerr<<"Fresh for another "<d_ttd - now<<" seconds!"<d_creation; uint16_t id; memcpy(&id, queryPacket.c_str(), 2); *responsePacket = iter->d_packet; responsePacket->replace(0, 2, (char*)&id, 2); d_hits++; moveCacheItemToBack(d_packetCache, iter); return true; } moveCacheItemToFront(d_packetCache, iter); d_misses++; return false; } void RecursorPacketCache::insertResponsePacket(const std::string& responsePacket, time_t now, uint32_t ttl) { struct Entry e; e.d_packet = responsePacket; e.d_ttd = now+ttl; e.d_creation = now; packetCache_t::iterator iter = d_packetCache.find(e); if(iter != d_packetCache.end()) { iter->d_packet = responsePacket; iter->d_ttd = now + ttl; iter->d_creation = now; } else d_packetCache.insert(e); } uint64_t RecursorPacketCache::size() { return d_packetCache.size(); } uint64_t RecursorPacketCache::bytes() { uint64_t sum=0; BOOST_FOREACH(const struct Entry& e, d_packetCache) { sum += sizeof(e) + e.d_packet.length() + 4; } return sum; } void RecursorPacketCache::doPruneTo(unsigned int maxCached) { pruneCollection(d_packetCache, maxCached); } pdns-3.3/pdns/Makefile.am0000644000014601777760000003510412165455411016572 0ustar00jenkinsnogroup00000000000000if HAVE_LIBPOLARSSL AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -I ext/rapidjson/include else AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -Iext/polarssl-1.1.2/include -Iext/rapidjson/include endif AM_CPPFLAGS=-Ibackends/bind $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) if BOTAN110 AM_CPPFLAGS += $(BOTAN110_CFLAGS) endif if BOTAN18 AM_CPPFLAGS += $(BOTAN18_CFLAGS) endif EXTRA_DIST = dnslabeltext.rl dnslabeltext.cc mtasker.cc inflighter.cc docs/pdns_control.8 \ docs/pdns_server.8 docs/zone2sql.8 docs/zone2ldap.8 docs/pdnssec.8 \ docs/dnsreplay.8 docs/dnsscope.8 docs/dnswasher.8 docs/pdnssec.8 docs/zone2ldap.8 \ dnssec.schema.mysql.sql dnssec.schema.pgsql.sql dnssec.schema.sqlite3.sql \ no-dnssec.schema.mysql.sql no-dnssec.schema.pgsql.sql no-dnssec.schema.sqlite3.sql \ bind-dnssec.schema.sqlite3.sql if HAVE_LIBPOLARSSL SUBDIRS= backends else SUBDIRS= ext/polarssl-1.1.2 backends endif BUILT_SOURCES=bind-dnssec.schema.sqlite3.sql.h version_generated.h noinst_SCRIPTS = pdns sysconf_DATA = pdns.conf-dist sbin_PROGRAMS = pdns_server bin_PROGRAMS = pdns_control pdnssec if TOOLS bin_PROGRAMS += dnsbulktest dnsreplay dnsscan dnsscope dnstcpbench dnswasher nproxy nsec3dig endif EXTRA_PROGRAMS=pdns_recursor sdig dnstcpbench tsig-tests speedtest rec_control dnsscope dnsgram \ testrunner dnsreplay \ toysdig dnsdemog dnswasher dnsscan nproxy notify pdnssec dnsbulktest nsec3dig # dnslabel # tcptorture pdns_server_SOURCES=dnspacket.cc nameserver.cc tcpreceiver.hh \ qtype.cc logger.cc arguments.cc packethandler.cc tcpreceiver.cc \ packetcache.cc statbag.cc ahuexception.hh arguments.hh distributor.hh \ dns.hh dnsbackend.hh dnsbackend.cc dnspacket.hh dynmessenger.hh lock.hh logger.hh \ nameserver.hh packetcache.hh packethandler.hh qtype.hh statbag.hh \ ueberbackend.hh pdns.conf-dist ws.hh ws.cc webserver.cc webserver.hh \ session.cc session.hh misc.cc misc.hh receiver.cc ueberbackend.cc \ dynlistener.cc dynlistener.hh dynhandler.cc dynhandler.hh \ resolver.hh resolver.cc slavecommunicator.cc mastercommunicator.cc communicator.cc communicator.hh dnsproxy.cc \ dnsproxy.hh unix_utility.cc common_startup.cc \ utility.hh iputils.hh common_startup.hh unix_semaphore.cc \ backends/bind/bindbackend2.cc backends/bind/binddnssec.cc bind-dnssec.schema.sqlite3.sql.h \ backends/bind/bindparser.cc backends/bind/bindlexer.c \ backends/gsql/gsqlbackend.cc \ backends/gsql/gsqlbackend.hh backends/gsql/ssql.hh \ base64.cc sillyrecords.cc \ base64.hh zoneparser-tng.cc dnsrecords.cc dnswriter.cc \ rcpgenerator.cc dnsparser.cc dns_random.hh aes/aescpp.h \ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ randomhelper.cc namespaces.hh nsecrecords.cc base32.cc dbdnsseckeeper.cc dnssecinfra.cc \ dnsseckeeper.hh dnssecinfra.hh base32.hh dns.cc dnssecsigner.cc polarrsakeyinfra.cc \ md5.hh signingpipe.cc signingpipe.hh dnslabeltext.cc lua-pdns.cc lua-auth.cc lua-auth.hh serialtweaker.cc \ ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh \ version.hh version.cc # pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) -rdynamic pdns_server_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_SERIALIZATION_LIBS) $(LUA_LIBS) $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(MYSQL_lib) if BOTAN110 pdns_server_SOURCES += botan110signers.cc botansigners.cc pdns_server_LDADD += $(BOTAN110_LIBS) -lgmp -lrt endif if BOTAN18 pdns_server_SOURCES += botan18signers.cc botansigners.cc pdns_server_LDADD += $(BOTAN18_LIBS) -lgmp endif if CRYPTOPP pdns_server_SOURCES += cryptoppsigners.cc pdns_server_LDADD += -lcryptopp endif if SQLITE3 pdns_server_SOURCES += ssqlite3.cc ssqlite3.hh endif if ORACLE pdns_server_LDADD += $(ORACLE_LIBS) endif pdnssec_SOURCES=pdnssec.cc dbdnsseckeeper.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc dnssecinfra.cc dnssecinfra.hh \ base32.cc ueberbackend.cc dnsbackend.cc arguments.cc packetcache.cc dnspacket.cc \ backends/bind/bindbackend2.cc backends/bind/binddnssec.cc bind-dnssec.schema.sqlite3.sql.h\ backends/bind/bindparser.cc backends/bind/bindlexer.c \ backends/gsql/gsqlbackend.cc \ backends/gsql/gsqlbackend.hh backends/gsql/ssql.hh zoneparser-tng.cc \ dynlistener.cc dns.cc dnssecsigner.cc polarrsakeyinfra.cc \ signingpipe.cc dnslabeltext.cc ednssubnet.cc cachecleaner.hh \ aes/aescpp.h \ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc json.cc \ serialtweaker.cc pdnssec_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_PROGRAM_OPTIONS_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS) pdnssec_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_PROGRAM_OPTIONS_LIBS) $(BOOST_SERIALIZATION_LIBS) $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(MYSQL_lib) if BOTAN110 pdnssec_SOURCES += botan110signers.cc botansigners.cc pdnssec_LDADD += $(BOTAN110_LIBS) -lgmp -lrt endif if BOTAN18 pdnssec_SOURCES += botan18signers.cc botansigners.cc pdnssec_LDADD += $(BOTAN18_LIBS) -lgmp endif if CRYPTOPP pdnssec_SOURCES += cryptoppsigners.cc pdnssec_LDADD += -lcryptopp endif if SQLITE3 pdnssec_SOURCES += ssqlite3.cc ssqlite3.hh endif if ORACLE pdnssec_LDADD += $(ORACLE_LIBS) endif sdig_SOURCES=sdig.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc dnstcpbench_SOURCES=dnstcpbench.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc dnstcpbench_LDFLAGS=$(BOOST_PROGRAM_OPTIONS_LDFLAGS) dnstcpbench_LDADD=$(BOOST_PROGRAM_OPTIONS_LIBS) nsec3dig_SOURCES=nsec3dig.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc \ dnswriter.hh dnssecinfra.cc \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc nsec3dig_LDFLAGS= -Lext/polarssl-1.1.2/library nsec3dig_LDADD= -lpolarssl toysdig_SOURCES=toysdig.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc \ ednssubnet.cc ednssubnet.hh #tcptorture_SOURCES=tcptorture.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ # misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ # logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc tsig_tests_SOURCES=tsig-tests.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc \ dnssecinfra.cc resolver.cc arguments.cc dns_random.hh aes/aescpp.h \ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ randomhelper.cc dns.cc if HAVE_LIBPOLARSSL tsig_tests_LDFLAGS= else tsig_tests_LDFLAGS= -Lext/polarssl-1.1.2/library endif tsig_tests_LDADD= -lpolarssl speedtest_SOURCES=speedtest.cc dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ qtype.cc sillyrecords.cc logger.cc statbag.cc nsecrecords.cc base32.cc dnswasher_SOURCES=dnswasher.cc misc.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.hh dnswasher_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ dnsbulktest_SOURCES=dnsbulktest.cc misc.cc unix_utility.cc qtype.cc logger.cc statbag.cc dnsparser.cc \ dnsrecords.cc dnswriter.cc dnslabeltext.cc rcpgenerator.cc base32.cc base64.cc sillyrecords.cc nsecrecords.cc dnsbulktest_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_PROGRAM_OPTIONS_LDFLAGS) dnsbulktest_LDADD= $(BOOST_PROGRAM_OPTIONS_LIBS) # unix_utility.cc dnsscan_SOURCES=dnsscan.cc misc.cc qtype.cc anadns.hh \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh \ unix_utility.cc utility.hh sillyrecords.cc nsecrecords.cc base32.cc #socketbench_SOURCES=socketbench.cc qtype.cc misc.cc unix_utility.cc\ # logger.cc statbag.cc epollmplexer.cc dnsreplay_SOURCES=dnsreplay.cc misc.cc qtype.cc anadns.hh \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh \ unix_utility.cc utility.hh sillyrecords.cc nsecrecords.cc base32.cc dnsreplay_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_PROGRAM_OPTIONS_LDFLAGS) dnsreplay_LDADD= $(BOOST_PROGRAM_OPTIONS_LIBS) nproxy_SOURCES=nproxy.cc dnsparser.cc dnsrecords.cc dnsparser.hh \ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh \ sillyrecords.cc selectmplexer.cc mplexer.hh misc.cc nsecrecords.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc base32.cc nproxy_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_PROGRAM_OPTIONS_LDFLAGS) nproxy_LDADD= $(BOOST_PROGRAM_OPTIONS_LIBS) notify_SOURCES=notify.cc dnsparser.cc dnsrecords.cc dnsparser.hh \ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh \ sillyrecords.cc selectmplexer.cc nsecrecords.cc base32.cc misc.cc unix_utility.cc \ logger.cc qtype.cc statbag.cc notify_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_PROGRAM_OPTIONS_LDFLAGS) notify_LDADD= $(BOOST_PROGRAM_OPTIONS_LIBS) dnsscope_SOURCES=dnsscope.cc misc.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc \ base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh rcpgenerator.cc rcpgenerator.hh \ utility.hh dnsparser.hh sillyrecords.cc nsecrecords.cc base32.cc dnsscope_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ dnsgram_SOURCES=dnsgram.cc misc.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc \ base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh rcpgenerator.cc rcpgenerator.hh \ utility.hh dnsparser.hh sillyrecords.cc nsecrecords.cc base32.cc dnsdemog_SOURCES=dnsdemog.cc misc.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc \ base64.cc base64.hh dnswriter.cc dnslabeltext.cc dnswriter.hh rcpgenerator.cc rcpgenerator.hh \ utility.hh dnsparser.hh sillyrecords.cc nsecrecords.cc base32.cc rec_control_SOURCES=rec_channel.cc rec_channel.hh rec_control.cc arguments.cc arguments.hh misc.cc qtype.cc \ unix_utility.cc logger.cc statbag.cc testrunner_SOURCES=testrunner.cc test-misc_hh.cc test-nameserver_cc.cc test-dnsrecords_cc.cc test-base32_cc.cc test-md5_hh.cc \ nameserver.cc misc.cc \ unix_utility.cc logger.cc statbag.cc arguments.cc qtype.cc dnspacket.cc \ dnswriter.cc base64.cc base32.cc dnsrecords.cc dnslabeltext.cc dnsparser.cc \ rcpgenerator.cc ednssubnet.cc nsecrecords.cc sillyrecords.cc dnssecinfra.cc \ test-base64_cc.cc test-iputils_hh.cc test-dns_random_hh.cc aes/dns_random.cc \ aes/aescpp.h \ aes/aescrypt.c aes/aes.h aes/aeskey.c aes/aes_modes.c aes/aesopt.h \ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h test-rcpgenerator_cc.cc testrunner_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) testrunner_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) pdns_recursor_SOURCES=syncres.cc resolver.hh misc.cc unix_utility.cc qtype.cc \ logger.cc statbag.cc arguments.cc lwres.cc pdns_recursor.cc reczones.cc lwres.hh \ mtasker.hh syncres.hh recursor_cache.cc recursor_cache.hh dnsparser.cc \ dnswriter.cc dnslabeltext.cc dnswriter.hh dnsrecords.cc dnsrecords.hh rcpgenerator.cc rcpgenerator.hh \ base64.cc base64.hh zoneparser-tng.cc zoneparser-tng.hh rec_channel.cc rec_channel.hh \ rec_channel_rec.cc selectmplexer.cc epollmplexer.cc sillyrecords.cc htimer.cc htimer.hh \ aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c \ lua-pdns.cc lua-pdns.hh lua-recursor.cc lua-recursor.hh randomhelper.cc \ recpacketcache.cc recpacketcache.hh dns.cc nsecrecords.cc base32.cc cachecleaner.hh json_ws.cc json_ws.hh \ json.cc json.hh version.hh version.cc pdns_recursor_LDFLAGS= $(LUA_LIBS) pdns_recursor_LDADD= pdns_control_SOURCES=dynloader.cc dynmessenger.cc arguments.cc logger.cc statbag.cc \ misc.cc unix_utility.cc qtype.cc pdns_control_LDFLAGS=@THREADFLAGS@ TESTS_ENVIRONMENT = env BOOST_TEST_LOG_LEVEL=message TESTS=testrunner dnslabeltext.cc: dnslabeltext.rl ragel dnslabeltext.rl -o dnslabeltext.cc bind-dnssec.schema.sqlite3.sql.h: bind-dnssec.schema.sqlite3.sql ( echo 'static char sqlCreate[] __attribute__((unused))=' ; sed 's/$$/"/g' bind-dnssec.schema.sqlite3.sql | sed 's/^/"/g' ; echo ';' ) > $@ backends/bind/bindlexer.c: cd backends/bind && $(MAKE) bindlexer.c backends/bind/bindparser.cc: cd backends/bind && $(MAKE) bindparser.cc build_date=$(shell LC_TIME=C date '+%Y%m%d%H%M%S') build_host=$(shell id -u -n)@$(shell hostname -f) if RELEASE_BUILD pdns_version=$(PACKAGE_VERSION) dist_host=$(DIST_HOST) else git_version=$(shell git describe --always --dirty=+ 2>/dev/null) # Do the test in shell, so we don't confuse automake with ifeq/ifneq. pdns_version=$(shell test -z "$(git_version)" && echo UNKNOWN || echo "git-$(git_version)") dist_host=$(build_host) endif version.o: version_generated.h .PHONY: version_generated.h version_generated.h: echo '#ifndef VERSION_GENERATED_H' > $@ echo '#define VERSION_GENERATED_H' >> $@ echo '#define PDNS_VERSION "$(pdns_version)"' >> $@ echo '#define DIST_HOST "$(dist_host)"' >> $@ echo '#define BUILD_DATE "$(build_date)"' >> $@ echo '#define BUILD_HOST "$(build_host)"' >> $@ echo '#endif //!VERSION_GENERATED_H' >> $@ pdns-3.3/pdns/packethandler.cc0000644000014601777760000012715212164462755017667 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "packetcache.hh" #include "utility.hh" #include "base32.hh" #include #include #include #include #include "dnssecinfra.hh" #include "dnsseckeeper.hh" #include "dns.hh" #include "dnsbackend.hh" #include "ueberbackend.hh" #include "dnspacket.hh" #include "nameserver.hh" #include "distributor.hh" #include "logger.hh" #include "arguments.hh" #include "packethandler.hh" #include "statbag.hh" #include "resolver.hh" #include "communicator.hh" #include "dnsproxy.hh" #include "version.hh" #include "common_startup.hh" #if 0 #undef DLOG #define DLOG(x) x #endif AtomicCounter PacketHandler::s_count; extern string s_programname; PacketHandler::PacketHandler():B(s_programname) { ++s_count; d_doFancyRecords = (::arg()["fancy-records"]!="no"); d_doRecursion= ::arg().mustDo("recursor"); d_logDNSDetails= ::arg().mustDo("log-dns-details"); d_doIPv6AdditionalProcessing = ::arg().mustDo("do-ipv6-additional-processing"); string fname= ::arg()["lua-prequery-script"]; if(fname.empty()) { d_pdl = NULL; } else { d_pdl = new AuthLua(fname); } } DNSBackend *PacketHandler::getBackend() { return &B; } PacketHandler::~PacketHandler() { --s_count; DLOG(L<addRecord(rr); } if(pdns_iequals(::arg()["send-root-referral"], "lean")) return; // add the additional stuff rr.ttl=3600000; rr.qtype=QType::A; rr.d_place=DNSResourceRecord::ADDITIONAL; for(char c='a';c<='m';++c) { *templ=c; rr.qname=templ; rr.content=ips[c-'a']; r->addRecord(rr); } } int PacketHandler::findMboxFW(DNSPacket *p, DNSPacket *r, string &target) { DNSResourceRecord rr; bool wedoforward=false; SOAData sd; int zoneId; if(!getAuth(p, &sd, target, &zoneId)) return false; B.lookup(QType(QType::MBOXFW),string("%@")+target,p, zoneId); while(B.get(rr)) wedoforward=true; if(wedoforward) { r->clearRecords(); rr.content=::arg()["smtpredirector"]; rr.priority=25; rr.ttl=7200; rr.qtype=QType::MX; rr.qname=target; r->addRecord(rr); } return wedoforward; } int PacketHandler::findUrl(DNSPacket *p, DNSPacket *r, string &target) { DNSResourceRecord rr; bool found=false; B.lookup(QType(QType::URL),target,p); // search for a URL before we search for an A while(B.get(rr)) { if(!found) r->clearRecords(); found=true; DLOG(L << "Found a URL!" << endl); rr.content=::arg()["urlredirector"]; rr.qtype=QType::A; rr.qname=target; r->addRecord(rr); } if(found) return 1; // now try CURL B.lookup(QType(QType::CURL),target,p); // search for a URL before we search for an A while(B.get(rr)) { if(!found) r->clearRecords(); found=true; DLOG(L << "Found a CURL!" << endl); rr.content=::arg()["urlredirector"]; rr.qtype=1; // A rr.qname=target; rr.ttl=300; r->addRecord(rr); } if(found) return found; return 0; } /** Returns 0 if nothing was found, -1 if an error occured or 1 if the search was satisfied */ int PacketHandler::doFancyRecords(DNSPacket *p, DNSPacket *r, string &target) { DNSResourceRecord rr; if(p->qtype.getCode()==QType::MX) // check if this domain has smtp service from us return findMboxFW(p,r,target); if(p->qtype.getCode()==QType::A) // search for a URL record for an A return findUrl(p,r,target); return 0; } /** This adds DNSKEY records. Returns true if one was added */ bool PacketHandler::addDNSKEY(DNSPacket *p, DNSPacket *r, const SOAData& sd) { DNSResourceRecord rr; bool haveOne=false; DNSSECPrivateKey dpk; DNSSECKeeper::keyset_t keyset = d_dk.getKeys(p->qdomain); BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type value, keyset) { rr.qtype=QType::DNSKEY; rr.ttl=sd.default_ttl; rr.qname=p->qdomain; rr.content=value.first.getDNSKEY().getZoneRepresentation(); rr.auth=true; r->addRecord(rr); haveOne=true; } if(::arg().mustDo("experimental-direct-dnskey")) { B.lookup(QType(QType::DNSKEY), p->qdomain, p, sd.domain_id); while(B.get(rr)) { rr.ttl=sd.default_ttl; r->addRecord(rr); haveOne=true; } } return haveOne; } /** This adds NSEC3PARAM records. Returns true if one was added */ bool PacketHandler::addNSEC3PARAM(DNSPacket *p, DNSPacket *r, const SOAData& sd) { DNSResourceRecord rr; NSEC3PARAMRecordContent ns3prc; if(d_dk.getNSEC3PARAM(p->qdomain, &ns3prc)) { rr.qtype=QType::NSEC3PARAM; rr.ttl=sd.default_ttl; rr.qname=p->qdomain; ns3prc.d_flags = 0; // the NSEC3PARAM 'flag' is defined to always be zero in RFC5155. rr.content=ns3prc.getZoneRepresentation(); rr.auth = true; r->addRecord(rr); return true; } return false; } /** This catches version requests. Returns 1 if it was handled, 0 if it wasn't */ int PacketHandler::doVersionRequest(DNSPacket *p, DNSPacket *r, string &target) { DNSResourceRecord rr; if(p->qclass == QClass::CHAOS && p->qtype.getCode()==QType::TXT && target=="version.bind") {// TXT // modes: anonymous, powerdns only, full, spoofed const static string mode=::arg()["version-string"]; if(mode.empty() || mode=="full") rr.content=fullVersionString(); else if(mode=="anonymous") { r->setRcode(RCode::ServFail); return 1; } else if(mode=="powerdns") rr.content="Served by PowerDNS - http://www.powerdns.com"; else rr.content=mode; rr.ttl=5; rr.qname=target; rr.qtype=QType::TXT; rr.qclass=QClass::CHAOS; r->addRecord(rr); return 1; } return 0; } /** Determines if we are authoritative for a zone, and at what level */ bool PacketHandler::getAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId) { bool found=false; string subdomain(target); do { if( B.getSOA( subdomain, *sd, p ) ) { sd->qname = subdomain; if(zoneId) *zoneId = sd->domain_id; if(p->qtype.getCode() == QType::DS && pdns_iequals(subdomain, target)) { // Found authoritative zone but look for parent zone with 'DS' record. found=true; } else return true; } } while( chopOff( subdomain ) ); // 'www.powerdns.org' -> 'powerdns.org' -> 'org' -> '' return found; } vector PacketHandler::getBestReferralNS(DNSPacket *p, SOAData& sd, const string &target) { vector ret; DNSResourceRecord rr; string subdomain(target); do { if(subdomain == sd.qname) // stop at SOA break; B.lookup(QType(QType::NS), subdomain, p, sd.domain_id); while(B.get(rr)) { ret.push_back(rr); // this used to exclude auth NS records for some reason } if(!ret.empty()) return ret; } while( chopOff( subdomain ) ); // 'www.powerdns.org' -> 'powerdns.org' -> 'org' -> '' return ret; } // Return best matching wildcard or next closer name bool PacketHandler::getBestWildcard(DNSPacket *p, SOAData& sd, const string &target, string &wildcard, vector* ret) { ret->clear(); DNSResourceRecord rr; string subdomain(target); bool haveSomething=false; wildcard=subdomain; while( chopOff( subdomain ) && !haveSomething ) { if (subdomain.empty()) { B.lookup(QType(QType::ANY), "*", p, sd.domain_id); } else { B.lookup(QType(QType::ANY), "*."+subdomain, p, sd.domain_id); } while(B.get(rr)) { if(rr.qtype == p->qtype || rr.qtype.getCode() == QType::CNAME || (p->qtype.getCode() == QType::ANY && rr.qtype.getCode() != QType::RRSIG)) ret->push_back(rr); wildcard="*."+subdomain; haveSomething=true; } if ( subdomain == sd.qname || haveSomething ) // stop at SOA or result break; B.lookup(QType(QType::ANY), subdomain, p, sd.domain_id); if (B.get(rr)) { DLOG(L<<"No wildcard match, ancestor exists"<qtype.getCode()!=QType::AXFR) { // this packet needs additional processing vector arrs=r->getAPRecords(); if(arrs.empty()) return 1; DLOG(L< crrs; for(vector::const_iterator i=arrs.begin(); i!=arrs.end(); ++i) crrs.push_back(**i); // we now have a copy, push_back on packet might reallocate! for(vector::const_iterator i=crrs.begin(); i!=crrs.end(); ++i) { if(r->d.aa && !i->qname.empty() && i->qtype.getCode()==QType::NS && !B.getSOA(i->qname,sd,p)) { // drop AA in case of non-SOA-level NS answer, except for root referral r->setA(false); // i->d_place=DNSResourceRecord::AUTHORITY; // XXX FIXME } string content = stripDot(i->content); QType qtypes[2]; qtypes[0]="A"; qtypes[1]="AAAA"; for(int n=0 ; n < d_doIPv6AdditionalProcessing + 1; ++n) { if (i->qtype.getCode()==QType::SRV) { vectorparts; stringtok(parts, content); if (parts.size() >= 3) { B.lookup(qtypes[n],parts[2],p); } else continue; } else { B.lookup(qtypes[n], content, p); } while(B.get(rr)) { if(rr.domain_id!=i->domain_id && ::arg()["out-of-zone-additional-processing"]=="no") { DLOG(L<qname<<" ("<addRecord(rr); } } } } return 1; } void PacketHandler::emitNSEC(const std::string& begin, const std::string& end, const std::string& toNSEC, const SOAData& sd, DNSPacket *r, int mode) { // <<"We should emit '"<addRecord(rr); } void emitNSEC3(DNSBackend& B, const NSEC3PARAMRecordContent& ns3prc, const SOAData& sd, const std::string& unhashed, const std::string& begin, const std::string& end, const std::string& toNSEC3, DNSPacket *r, int mode) { // cerr<<"We should emit NSEC3 '"<addRecord(rr); } void PacketHandler::emitNSEC3(const NSEC3PARAMRecordContent& ns3prc, const SOAData& sd, const std::string& unhashed, const std::string& begin, const std::string& end, const std::string& toNSEC3, DNSPacket *r, int mode) { ::emitNSEC3(B, ns3prc, sd, unhashed, begin, end, toNSEC3, r, mode); } /* mode 0 = No Data Responses, QTYPE is not DS mode 1 = No Data Responses, QTYPE is DS mode 2 = Wildcard No Data Responses mode 3 = Wildcard Answer Responses mode 4 = Name Error Responses mode 5 = Direct NSEC request */ void PacketHandler::addNSECX(DNSPacket *p, DNSPacket *r, const string& target, const string& wildcard, const string& auth, int mode) { NSEC3PARAMRecordContent ns3rc; // cerr<<"Doing NSEC3PARAM lookup for '"<qdomain<<"|"<qtype.getName()<<": "; bool narrow; if(d_dk.getNSEC3PARAM(auth, &ns3rc, &narrow)) { // cerr<<"Present, narrow="<getBeforeAndAfterNamesAbsolute(id, toLower(toBase32Hex(hashed)), unhashed, before, after); before=fromBase32Hex(before); after=fromBase32Hex(after); } // cerr<<"rgetNSEC3Hashes: "<d_dnssecOk) return; DLOG(L<<"Should add NSEC covering '"<getBeforeAndAfterNames(sd.domain_id, auth, target, before, after); emitNSEC(before, after, target, sd, r, mode); if (mode == 2) { // wildcard NO-DATA before='.'; sd.db->getBeforeAndAfterNames(sd.domain_id, auth, wildcard, before, after); emitNSEC(before, after, target, sd, r, mode); } if (mode == 4) { // this one does wildcard denial, if applicable before='.'; sd.db->getBeforeAndAfterNames(sd.domain_id, auth, auth, before, after); emitNSEC(auth, after, auth, sd, r, mode); } return; } /* Semantics: - only one backend owns the SOA of a zone - only one AXFR per zone at a time - double startTransaction should fail - backends need to implement transaction semantics How BindBackend would implement this: startTransaction makes a file feedRecord sends everything to that file commitTransaction moves that file atomically over the regular file, and triggers a reload rollbackTransaction removes the file How PostgreSQLBackend would implement this: startTransaction starts a sql transaction, which also deletes all records feedRecord is an insert statement commitTransaction commits the transaction rollbackTransaction aborts it How MySQLBackend would implement this: (good question!) */ int PacketHandler::trySuperMaster(DNSPacket *p) { if(p->d_tcp) { // do it right now if the client is TCP // rarely happens return trySuperMasterSynchronous(p); } else { // queue it if the client is on UDP Communicator.addTrySuperMasterRequest(p); return 0; } } int PacketHandler::trySuperMasterSynchronous(DNSPacket *p) { Resolver::res_t nsset; try { Resolver resolver; uint32_t theirserial; resolver.getSoaSerial(p->getRemote(),p->qdomain, &theirserial); resolver.resolve(p->getRemote(), p->qdomain.c_str(), QType::NS, &nsset); } catch(ResolverException &re) { L<qdomain<<" at: "<< p->getRemote() <<": "<getRemote(), p->qdomain, nsset, &account, &db)) { L<qdomain<<" for potential supermaster "<getRemote()<<". "<createSlaveDomain(p->getRemote(),p->qdomain,account); } catch(AhuException& ae) { L<qdomain<<" for potential supermaster "<getRemote()<<": "<qdomain, p->getRemote()); L<qdomain<<"' from supermaster "<getRemote()<<", queued axfr"< do stuff */ if(!::arg().mustDo("slave")) { L<qdomain<<" from "<getRemote()<<" but slave support is disabled in the configuration"<qdomain, di) || !(db=di.backend)) { L<qdomain<<" from "<getRemote()<<" for which we are not authoritative"<getRemote())) { L<qdomain<<" from trusted-notification-proxy "<< p->getRemote()<qdomain<<" does not have any masters defined"<isMaster(p->qdomain, p->getRemote())) { L<qdomain<<" from "<getRemote()<<" which is not a master"<d_remote); return 0; } bool validDNSName(const string &name) { string::size_type pos, length=name.length(); char c; for(pos=0; pos < length; ++pos) { c=name[pos]; if(!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c =='-' || c == '_' || c=='*' || c=='.' || c=='/' || c=='@' || c==' ' || c=='\\' || c==':')) return false; } return true; } DNSPacket *PacketHandler::question(DNSPacket *p) { DNSPacket *ret; if(d_pdl) { ret=d_pdl->prequery(p); if(ret) return ret; } bool shouldRecurse=false; ret=questionOrRecurse(p, &shouldRecurse); if(shouldRecurse) { DP->sendPacket(p); } return ret; } void PacketHandler::synthesiseRRSIGs(DNSPacket* p, DNSPacket* r) { DLOG(L<<"Need to synthesise the RRSIGs if someone asked for them explicitly"< > > records_t; typedef map ttls_t; records_t records; ttls_t ttls; NSECRecordContent nrc; NSEC3RecordContent n3rc; nrc.d_set.insert(QType::RRSIG); DNSResourceRecord rr; SOAData sd; sd.db=(DNSBackend *)-1; // force uncached answer getAuth(p, &sd, p->qdomain, 0); bool narrow; NSEC3PARAMRecordContent ns3pr; bool doNSEC3= d_dk.getNSEC3PARAM(sd.qname, &ns3pr, &narrow); B.lookup(QType(QType::ANY), p->qdomain, p); bool haveone=false; while(B.get(rr)) { haveone=true; if(!((rr.auth && rr.qtype.getCode()) || (!(doNSEC3 && ns3pr.d_flags) && rr.qtype.getCode() == QType::NS))) continue; // make sure all fields are present in the SOA content if(rr.qtype.getCode() == QType::SOA) { rr.content = serializeSOAData(sd); } // this deals with the 'prio' mismatch! if(rr.qtype.getCode()==QType::MX || rr.qtype.getCode() == QType::SRV) { rr.content = lexical_cast(rr.priority) + " " + rr.content; } // fix direct DNSKEY ttl if(::arg().mustDo("experimental-direct-dnskey") && rr.qtype.getCode() == QType::DNSKEY) { rr.ttl = sd.default_ttl; } if(!rr.content.empty() && rr.qtype.getCode()==QType::TXT && rr.content[0]!='"') { rr.content="\""+rr.content+"\""; } if(rr.content.empty()) // empty contents confuse the MOADNS setup rr.content="."; shared_ptr drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); records[rr.qtype.getCode()].push_back(drc); ttls[rr.qtype.getCode()]=rr.ttl; nrc.d_set.insert(rr.qtype.getCode()); } if(records.empty()) { if (haveone) makeNOError(p, r, p->qdomain, "", sd, 0); return; } if(pdns_iequals(p->qdomain, sd.qname)) { // Add DNSKEYs at apex DNSSECPrivateKey dpk; DNSSECKeeper::keyset_t keyset = d_dk.getKeys(p->qdomain); BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type value, keyset) { records[QType::DNSKEY].push_back(shared_ptr(DNSRecordContent::mastermake(QType::DNSKEY, 1, value.first.getDNSKEY().getZoneRepresentation()))); ttls[QType::DNSKEY]=sd.default_ttl; nrc.d_set.insert(QType::DNSKEY); } } string before,after; string unhashed(p->qdomain); if(doNSEC3) { // now get the NSEC3 and NSEC3PARAM string hashed=hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, unhashed); getNSEC3Hashes(narrow, sd.db, sd.domain_id, hashed, false, unhashed, before, after); unhashed=dotConcat(toLower(toBase32Hex(before)), sd.qname); n3rc.d_set=nrc.d_set; // Copy d_set from NSEC n3rc.d_algorithm=ns3pr.d_algorithm; n3rc.d_flags=ns3pr.d_flags; n3rc.d_iterations=ns3pr.d_iterations; n3rc.d_salt=ns3pr.d_salt; n3rc.d_nexthash=after; if(pdns_iequals(p->qdomain, sd.qname)) { ns3pr.d_flags = 0; // the NSEC3PARAM 'flag' is defined to always be zero in RFC5155. records[QType::NSEC3PARAM].push_back(shared_ptr(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, ns3pr.getZoneRepresentation()))); ttls[QType::NSEC3PARAM]=sd.default_ttl; n3rc.d_set.insert(QType::NSEC3PARAM); } // ok, the NSEC3PARAM is in.. } else { // now get the NSEC too (since we must sign it!) sd.db->getBeforeAndAfterNames(sd.domain_id, sd.qname, p->qdomain, before, after); nrc.d_set.insert(QType::NSEC); nrc.d_next=after; records[QType::NSEC].push_back(shared_ptr(DNSRecordContent::mastermake(QType::NSEC, 1, nrc.getZoneRepresentation()))); ttls[QType::NSEC]=sd.default_ttl; // ok, the NSEC is in.. } DLOG(L<<"Have "< rrsigs; BOOST_FOREACH(records_t::value_type& iter, records) { rr.qname=(doNSEC3 && iter.first == QType::NSEC3) ? unhashed : p->qdomain; rr.ttl=ttls[iter.first]; addSignature(d_dk, B, sd.qname, rr.qname, rr.qname, iter.first, rr.ttl, DNSPacketWriter::ANSWER, iter.second, rrsigs, rr.ttl); } BOOST_FOREACH(DNSResourceRecord& rr, rrsigs) r->addRecord(rr); } void PacketHandler::makeNXDomain(DNSPacket* p, DNSPacket* r, const std::string& target, const std::string& wildcard, SOAData& sd) { DNSResourceRecord rr; rr.qname=sd.qname; rr.qtype=QType::SOA; rr.content=serializeSOAData(sd); rr.ttl=min(sd.ttl, sd.default_ttl); rr.signttl=sd.ttl; rr.domain_id=sd.domain_id; rr.d_place=DNSResourceRecord::AUTHORITY; rr.auth = 1; rr.scopeMask = sd.scopeMask; r->addRecord(rr); if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname)) addNSECX(p, r, target, wildcard, sd.qname, 4); r->setRcode(RCode::NXDomain); S.ringAccount("nxdomain-queries",p->qdomain+"/"+p->qtype.getName()); } void PacketHandler::makeNOError(DNSPacket* p, DNSPacket* r, const std::string& target, const std::string& wildcard, SOAData& sd, int mode) { DNSResourceRecord rr; rr.qname=sd.qname; rr.qtype=QType::SOA; rr.content=serializeSOAData(sd); rr.ttl=sd.ttl; rr.ttl=min(sd.ttl, sd.default_ttl); rr.signttl=sd.ttl; rr.domain_id=sd.domain_id; rr.d_place=DNSResourceRecord::AUTHORITY; rr.auth = 1; r->addRecord(rr); if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname)) addNSECX(p, r, target, wildcard, sd.qname, mode); S.ringAccount("noerror-queries",p->qdomain+"/"+p->qtype.getName()); } bool PacketHandler::addDSforNS(DNSPacket* p, DNSPacket* r, SOAData& sd, const string& dsname) { //cerr<<"Trying to find a DS for '"<qname<addRecord(rr); } r->setA(false); if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname) && !addDSforNS(p, r, sd, rrset.begin()->qname)) addNSECX(p, r, rrset.begin()->qname, "", sd.qname, 1); return true; } void PacketHandler::completeANYRecords(DNSPacket *p, DNSPacket*r, SOAData& sd, const string &target) { if(!p->d_dnssecOk) return; // Don't send dnssec info to non validating resolvers. if(!d_dk.isSecuredZone(sd.qname)) return; addNSECX(p, r, target, "", sd.qname, 5); if(pdns_iequals(sd.qname, p->qdomain)) { addDNSKEY(p, r, sd); addNSEC3PARAM(p, r, sd); } } bool PacketHandler::tryWildcard(DNSPacket *p, DNSPacket*r, SOAData& sd, string &target, string &wildcard, bool& retargeted, bool& nodata) { retargeted = nodata = false; string bestmatch; vector rrset; if(!getBestWildcard(p, sd, target, wildcard, &rrset)) return false; if(rrset.empty()) { DLOG(L<<"Wildcard matched something, but not of the correct type"<qname<addRecord(rr); } } if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname) && !nodata) { addNSECX(p, r, bestmatch, wildcard, sd.qname, 3); } return true; } //! Called by the Distributor to ask a question. Returns 0 in case of an error DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse) { *shouldRecurse=false; DNSResourceRecord rr; SOAData sd; sd.db=0; string subdomain=""; string soa; int retargetcount=0; set authSet; vector rrset; bool weDone=0, weRedirected=0, weHaveUnauth=0; DNSPacket *r=0; bool noCache=false; if(p->d.qr) { // QR bit from dns packet (thanks RA from N) L<getRemote()<<", dropping"<d_havetsig) { string keyname, secret; TSIGRecordContent trc; if(!checkForCorrectTSIG(p, &B, &keyname, &secret, &trc)) { r=p->replyPacket(); // generate an empty reply packet if(d_logDNSDetails) L<setRcode(RCode::NotAuth); return r; } p->setTSIGDetails(trc, keyname, secret, trc.d_mac); // this will get copied by replyPacket() noCache=true; } r=p->replyPacket(); // generate an empty reply packet, possibly with TSIG details inside try { // XXX FIXME do this in DNSPacket::parse ? if(!validDNSName(p->qdomain)) { if(d_logDNSDetails) L<getRemote()<<", '"<qdomain<<"': sending servfail"<setRcode(RCode::ServFail); return r; } if(p->d.opcode) { // non-zero opcode (again thanks RA!) if(p->d.opcode==Opcode::Update) { if(::arg().mustDo("log-failed-updates")) L<getRemote()<<" for "<qdomain<<", sending NOTIMP"<setRcode(RCode::NotImp); // notimp; return r; } else if(p->d.opcode==Opcode::Notify) { int res=processNotify(p); if(res>=0) { r->setRcode(res); r->setOpcode(Opcode::Notify); return r; } delete r; return 0; } L<d.opcode<<" from "<getRemote()<<" for "<qdomain<setRcode(RCode::NotImp); return r; } // L<qdomain<<"' "<qtype.getName()<<" from "<getRemote()<< " (tcp="<d_tcp<<")"<d.ra = (p->d.rd && d_doRecursion && DP->recurseFor(p)); // make sure we set ra if rd was set, and we'll do it if(p->qtype.getCode()==QType::IXFR) { r->setRcode(RCode::NotImp); return r; } // please don't query fancy records directly! if(d_doFancyRecords && (p->qtype.getCode()==QType::URL || p->qtype.getCode()==QType::CURL || p->qtype.getCode()==QType::MBOXFW)) { r->setRcode(RCode::ServFail); return r; } string target=p->qdomain; if(doVersionRequest(p,r,target)) // catch version.bind requests goto sendit; if((p->qtype.getCode() == QType::ANY || p->qtype.getCode() == QType::RRSIG) && !p->d_tcp && g_anyToTcp) { r->d.tc = 1; r->commitD(); return r; } if(p->qclass==255) // any class query r->setA(false); else if(p->qclass != QClass::IN) // we only know about IN, so we don't find anything goto sendit; retargeted:; if(retargetcount > 10) { // XXX FIXME, retargetcount++? r->setRcode(RCode::ServFail); return r; } if(!getAuth(p, &sd, target, 0)) { DLOG(L<d.ra) { DLOG(L<setA(false); // drop AA if we never had a SOA in the first place if(::arg().mustDo("send-root-referral")) { DLOG(L<qtype.getCode() == QType::RRSIG && d_dk.isSecuredZone(sd.qname)) { synthesiseRRSIGs(p, r); goto sendit; } DLOG(L<<"Checking for referrals first, unless this is a DS query"<qtype.getCode() != QType::DS && tryReferral(p, r, sd, target)) goto sendit; DLOG(L<<"Got no referrals, trying ANY"<qtype.getCode() == QType::ANY) { if (rr.qtype.getCode() == QType::RRSIG) // RRSIGS are added later any way. continue; // TODO: this actually means addRRSig should check if the RRSig is already there. if (!p->d_dnssecOk && (rr.qtype.getCode() == QType:: DNSKEY || rr.qtype.getCode() == QType::NSEC3PARAM)) continue; // Don't send dnssec info to non validating resolvers. } // cerr<<"Auth: "<qtype)<<", "<qtype.getCode() == QType::ANY || rr.qtype == p->qtype) && rr.auth) weDone=1; // the line below fakes 'unauth NS' for delegations for non-DNSSEC backends. if((rr.qtype == p->qtype && !rr.auth) || (rr.qtype.getCode() == QType::NS && (!rr.auth || !pdns_iequals(sd.qname, rr.qname)))) weHaveUnauth=1; if(rr.qtype.getCode() == QType::CNAME && p->qtype.getCode() != QType::CNAME) weRedirected=1; if(rr.qtype.getCode() == QType::SOA && pdns_iequals(rr.qname, sd.qname)) { // fix up possible SOA adjustments for this zone rr.content=serializeSOAData(sd); rr.ttl=sd.ttl; rr.domain_id=sd.domain_id; rr.auth = true; } rrset.push_back(rr); } DLOG(L<<"After first ANY query for '"<qtype.getCode())<<"] against QType::DS ["<<(QType::DS)<<"]"<qtype.getCode() == QType::DS) { DLOG(L<<"DS query found no direct result, trying referral now"<qtype.getCode() == QType::CNAME) || (p->qtype.getCode() == QType::ANY)) && retargetcount > 0)) makeNXDomain(p, r, target, wildcard, sd); } goto sendit; } if(weRedirected) { BOOST_FOREACH(rr, rrset) { if(rr.qtype.getCode() == QType::CNAME) { r->addRecord(rr); target = rr.content; retargetcount++; goto retargeted; } } } else if(weDone) { bool haveRecords = false; BOOST_FOREACH(rr, rrset) { if((p->qtype.getCode() == QType::ANY || rr.qtype == p->qtype) && rr.qtype.getCode() && rr.auth) { r->addRecord(rr); haveRecords = true; } } if (haveRecords) { if(p->qtype.getCode() == QType::ANY) completeANYRecords(p, r, sd, target); } else makeNOError(p, r, rr.qname, "", sd, 0); goto sendit; } else if(weHaveUnauth) { DLOG(L<<"Have unauth data, so need to hunt for best NS records"<qdomain<<"|"<qtype.getCode()<<"): you have a trailing dot, this could be the problem (or run pdnssec rectify-zone " <qdomain<<"|"<qtype.getCode()<<"): please run pdnssec rectify-zone "<getRRS()) { if(rr.scopeMask) { noCache=1; break; } } if(p->d_dnssecOk) addRRSigs(d_dk, B, authSet, r->getRRS()); r->wrapup(); // needed for inserting in cache if(!noCache) PC.insert(p, r, r->getMinTTL()); // in the packet cache } catch(DBException &e) { L<setRcode(RCode::ServFail); S.inc("servfail-packets"); S.ringAccount("servfail-queries",p->qdomain); } catch(AhuException &e) { L<replyPacket(); // generate an empty reply packet r->setRcode(RCode::ServFail); S.inc("servfail-packets"); S.ringAccount("servfail-queries",p->qdomain); } return r; } pdns-3.3/pdns/version.hh0000644000014601777760000000171012143161472016535 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002-2013 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VERSION_HH #define VERSION_HH #include "namespaces.hh" string compilerVersion(); void showProductVersion(); string fullVersionString(); void versionSetProduct(string product); #endif //!VERSION_HH pdns-3.3/pdns/zoneparser-tng.cc0000644000014601777760000002710112156130736020021 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "dnsparser.hh" #include "sstuff.hh" #include "misc.hh" #include "dnswriter.hh" #include "dnsrecords.hh" #include "misc.hh" #include #include "dns.hh" #include "zoneparser-tng.hh" #include #include #include ZoneParserTNG::ZoneParserTNG(const string& fname, const string& zname, const string& reldir) : d_reldir(reldir), d_zonename(zname), d_defaultttl(3600), d_havedollarttl(false) { d_zonename = toCanonic("", d_zonename); stackFile(fname); } void ZoneParserTNG::stackFile(const std::string& fname) { FILE *fp=fopen(fname.c_str(), "r"); if(!fp) throw runtime_error("Unable to open file '"+fname+"': "+stringerror()); filestate fs(fp, fname); d_filestates.push(fs); } ZoneParserTNG::~ZoneParserTNG() { while(!d_filestates.empty()) { fclose(d_filestates.top().d_fp); d_filestates.pop(); } } static string makeString(const string& line, const pair& range) { return string(line.c_str() + range.first, range.second - range.first); } static bool isTimeSpec(const string& nextpart) { if(nextpart.empty()) return false; for(string::const_iterator iter = nextpart.begin(); iter != nextpart.end(); ++iter) { if(isdigit(*iter)) continue; if(iter+1 != nextpart.end()) return false; char c=tolower(*iter); return (c=='s' || c=='m' || c=='h' || c=='d' || c=='w' || c=='y'); } return true; } unsigned int ZoneParserTNG::makeTTLFromZone(const string& str) { if(str.empty()) return 0; unsigned int val=atoi(str.c_str()); char lc=toupper(str[str.length()-1]); if(!isdigit(lc)) switch(lc) { case 'S': break; case 'M': val*=60; // minutes, not months! break; case 'H': val*=3600; break; case 'D': val*=3600*24; break; case 'W': val*=3600*24*7; break; case 'Y': // ? :-) val*=3600*24*365; break; default: throw ZoneParserTNG::exception("Unable to parse time specification '"+str+"' "+getLineOfFile()); } return val; } bool ZoneParserTNG::getTemplateLine() { if(d_templateparts.empty() || d_templatecounter > d_templatestop) // no template, or done with return false; string retline; for(parts_t::const_iterator iter = d_templateparts.begin() ; iter != d_templateparts.end(); ++iter) { if(iter != d_templateparts.begin()) retline+=" "; string part=makeString(d_templateline, *iter); /* a part can contain a 'naked' $, an escaped $ (\$), or ${offset,width,radix}, with width defaulting to 0, and radix beging 'd', 'o', 'x' or 'X', defaulting to 'd'. The width is zero-padded, so if the counter is at 1, the offset is 15, with is 3, and the radix is 'x', output will be '010', from the input of ${15,3,x} */ string outpart; outpart.reserve(part.size()+5); bool inescape=false; for(string::size_type pos = 0; pos < part.size() ; ++pos) { char c=part[pos]; if(inescape) { outpart.append(1, c); inescape=false; continue; } if(part[pos]=='\\') { inescape=true; continue; } if(c=='$') { if(pos + 1 == part.size() || part[pos+1]!='{') { // a trailing $, or not followed by { outpart.append(lexical_cast(d_templatecounter)); continue; } // need to deal with { case pos+=2; string::size_type startPos=pos; for(; pos < part.size() && part[pos]!='}' ; ++pos) ; if(pos == part.size()) // partial spec break; // we are on the '}' string spec(part.c_str() + startPos, part.c_str() + pos); int offset=0, width=0; char radix='d'; sscanf(spec.c_str(), "%d,%d,%c", &offset, &width, &radix); // parse format specifier char format[12]; snprintf(format, sizeof(format) - 1, "%%0%d%c", width, radix); // make into printf-style format char tmp[80]; snprintf(tmp, sizeof(tmp)-1, format, d_templatecounter + offset); // and do the actual printing outpart+=tmp; } else outpart.append(1, c); } retline+=outpart; } d_templatecounter+=d_templatestep; d_line = retline; return true; } void chopComment(string& line) { string::size_type pos, len = line.length(); bool inQuote=false; for(pos = 0 ; pos < len; ++pos) { if(line[pos]=='\\') pos++; else if(line[pos]=='"') inQuote=!inQuote; else if(line[pos]==';' && !inQuote) break; } if(pos != len) line.resize(pos); } bool findAndElide(string& line, char c) { string::size_type pos, len = line.length(); bool inQuote=false; for(pos = 0 ; pos < len; ++pos) { if(line[pos]=='\\') pos++; else if(line[pos]=='"') inQuote=!inQuote; else if(line[pos]==c && !inQuote) break; } if(pos != len) { line.erase(pos, 1); return true; } return false; } string ZoneParserTNG::getLineOfFile() { return "on line "+lexical_cast(d_filestates.top().d_lineno)+" of file '"+d_filestates.top().d_filename+"'"; } // ODD: this function never fills out the prio field! rest of pdns compensates though bool ZoneParserTNG::get(DNSResourceRecord& rr) { retry:; if(!getTemplateLine() && !getLine()) return false; boost::trim_right_if(d_line, is_any_of(" \r\n\x1a")); parts_t parts; vstringtok(parts, d_line); if(parts.empty()) goto retry; if(parts[0].first != parts[0].second && makeString(d_line, parts[0])[0]==';') // line consisting of nothing but comments goto retry; if(d_line[0]=='$') { string command=makeString(d_line, parts[0]); if(pdns_iequals(command,"$TTL") && parts.size() > 1) { d_defaultttl=makeTTLFromZone(trim_right_copy_if(makeString(d_line, parts[1]), is_any_of(";"))); d_havedollarttl=true; } else if(pdns_iequals(command,"$INCLUDE") && parts.size() > 1) { string fname=unquotify(makeString(d_line, parts[1])); if(!fname.empty() && fname[0]!='/' && !d_reldir.empty()) fname=d_reldir+"/"+fname; stackFile(fname); } else if(pdns_iequals(command, "$ORIGIN") && parts.size() > 1) { d_zonename = toCanonic("", makeString(d_line, parts[1])); } else if(pdns_iequals(command, "$GENERATE") && parts.size() > 2) { // $GENERATE 1-127 $ CNAME $.0 string range=makeString(d_line, parts[1]); d_templatestep=1; d_templatestop=0; sscanf(range.c_str(),"%d-%d/%d", &d_templatecounter, &d_templatestop, &d_templatestep); d_templateline=d_line; parts.pop_front(); parts.pop_front(); d_templateparts=parts; goto retry; } else throw exception("Can't parse zone line '"+d_line+"' "+getLineOfFile()); goto retry; } if(isspace(d_line[0])) rr.qname=d_prevqname; else { rr.qname=makeString(d_line, parts[0]); parts.pop_front(); if(rr.qname.empty() || rr.qname[0]==';') goto retry; } if(rr.qname=="@") rr.qname=d_zonename; else if(!isCanonical(rr.qname)) { if(d_zonename.empty() || d_zonename[0]!='.') // prevent us from adding a double dot rr.qname.append(1,'.'); rr.qname.append(d_zonename); } d_prevqname=rr.qname; if(parts.empty()) throw exception("Line with too little parts "+getLineOfFile()); string nextpart; rr.ttl=d_defaultttl; bool haveTTL=0, haveQTYPE=0; pair range; while(!parts.empty()) { range=parts.front(); parts.pop_front(); nextpart=makeString(d_line, range); if(nextpart.empty()) break; if(nextpart.find(';')!=string::npos) break; // cout<<"Next part: '"< recparts; switch(rr.qtype.getCode()) { case QType::MX: stringtok(recparts, rr.content); if(recparts.size()==2) { recparts[1] = stripDot(toCanonic(d_zonename, recparts[1])); rr.content=recparts[0]+" "+recparts[1]; } break; case QType::RP: stringtok(recparts, rr.content); if(recparts.size()==2) { recparts[0] = stripDot(toCanonic(d_zonename, recparts[0])); recparts[1] = stripDot(toCanonic(d_zonename, recparts[1])); rr.content=recparts[0]+" "+recparts[1]; } break; case QType::SRV: stringtok(recparts, rr.content); if(recparts.size()==4) { if(recparts[3]!=".") recparts[3] = stripDot(toCanonic(d_zonename, recparts[3])); rr.content=recparts[0]+" "+recparts[1]+" "+recparts[2]+" "+recparts[3]; } break; case QType::NS: case QType::CNAME: case QType::PTR: case QType::AFSDB: rr.content=stripDot(toCanonic(d_zonename, rr.content)); break; case QType::SOA: stringtok(recparts, rr.content); if(recparts.size() > 1) { recparts[0]=toCanonic(d_zonename, recparts[0]); recparts[1]=toCanonic(d_zonename, recparts[1]); } rr.content.clear(); for(string::size_type n = 0; n < recparts.size(); ++n) { if(n) rr.content.append(1,' '); if(n > 1) rr.content+=lexical_cast(makeTTLFromZone(recparts[n])); else rr.content+=recparts[n]; if(n==6 && !d_havedollarttl) d_defaultttl=makeTTLFromZone(recparts[n]); } break; default:; } rr.d_place=DNSResourceRecord::ANSWER; return true; } bool ZoneParserTNG::getLine() { while(!d_filestates.empty()) { if(stringfgets(d_filestates.top().d_fp, d_line)) { d_filestates.top().d_lineno++; return true; } fclose(d_filestates.top().d_fp); d_filestates.pop(); } return false; } pdns-3.3/pdns/tcpreceiver.hh0000644000014601777760000000401612136555572017377 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_TCPRECEIVER_HH #define PDNS_TCPRECEIVER_HH #include "dns.hh" #include "iputils.hh" #include "dnsbackend.hh" #include "packethandler.hh" #include #include #include #ifndef WIN32 # include # include # include # include # include # include # include # include # include #endif // WIN32 #include "namespaces.hh" class TCPNameserver { public: TCPNameserver(); ~TCPNameserver(); void go(); private: static void sendPacket(boost::shared_ptr p, int outsock); static int readLength(int fd, ComboAddress *remote); static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote); static int doAXFR(const string &target, boost::shared_ptr q, int outsock); static bool canDoAXFR(boost::shared_ptr q); static void *doConnection(void *data); static void *launcher(void *data); void thread(void); static pthread_mutex_t s_plock; static PacketHandler *s_P; pthread_t d_tid; static Semaphore *d_connectionroom_sem; static NetmaskGroup d_ng; vectord_sockets; vector d_prfds; static int s_timeout; }; #endif /* PDNS_TCPRECEIVER_HH */ pdns-3.3/pdns/lua-auth.cc0000644000014601777760000001370512147631274016573 0ustar00jenkinsnogroup00000000000000#include "lua-auth.hh" #if !defined(HAVE_LUA) AuthLua::AuthLua(const std::string &fname) : PowerDNSLua(fname) { // empty } DNSPacket* AuthLua::prequery(DNSPacket *p) { return false; } bool AuthLua::axfrfilter(const ComboAddress& remote, const string& zone, const DNSResourceRecord& in, vector& out) { return false; } #else extern "C" { #undef L /* Include the Lua API header files. */ #include #include #include } #include #include #include #include #include #include #include "logger.hh" #include "namespaces.hh" AuthLua::AuthLua(const std::string &fname) : PowerDNSLua(fname) { registerLuaDNSPacket(); } bool AuthLua::axfrfilter(const ComboAddress& remote, const string& zone, const DNSResourceRecord& in, vector& out) { lua_getglobal(d_lua, "axfrfilter"); if(!lua_isfunction(d_lua, -1)) { // cerr<<"No such function 'axfrfilter'\n"; lua_pop(d_lua, 1); return false; } lua_pushstring(d_lua, remote.toString().c_str() ); lua_pushstring(d_lua, zone.c_str() ); lua_pushstring(d_lua, in.qname.c_str() ); lua_pushnumber(d_lua, in.qtype.getCode() ); lua_pushnumber(d_lua, in.ttl ); lua_pushnumber(d_lua, in.priority ); lua_pushstring(d_lua, in.content.c_str() ); if(lua_pcall(d_lua, 7, 2, 0)) { // error string error=string("lua error in axfrfilter: ")+lua_tostring(d_lua, -1); lua_pop(d_lua, 1); throw runtime_error(error); return false; } int newres = (int)lua_tonumber(d_lua, 1); // did we handle it? if(newres < 0) { //cerr << "handler did not handle"<d_p; } static int ldp_setRcode(lua_State *L) { DNSPacket *p=ldp_checkDNSPacket(L); int rcode = luaL_checkint(L, 2); p->setRcode(rcode); return 0; } static int ldp_getQuestion(lua_State *L) { DNSPacket *p=ldp_checkDNSPacket(L); lua_pushstring(L, p->qdomain.c_str()); lua_pushnumber(L, p->qtype.getCode()); return 2; } static int ldp_addRecords(lua_State *L) { DNSPacket *p=ldp_checkDNSPacket(L); vector rrs; popResourceRecordsTable(L, "BOGUS", rrs); BOOST_FOREACH(DNSResourceRecord rr, rrs) { p->addRecord(rr); } return 0; } static int ldp_getRemote(lua_State *L) { DNSPacket *p=ldp_checkDNSPacket(L); lua_pushstring(L, p->getRemote().c_str()); return 1; } // these functions are used for PowerDNS recursor regresseion testing against auth. The Lua 5.2 implementation is most likely broken. #if LUA_VERSION_NUM < 502 static const struct luaL_reg ldp_methods [] = { {"setRcode", ldp_setRcode}, {"getQuestion", ldp_getQuestion}, {"addRecords", ldp_addRecords}, {"getRemote", ldp_getRemote}, {NULL, NULL} }; void AuthLua::registerLuaDNSPacket(void) { luaL_newmetatable(d_lua, "LuaDNSPacket"); lua_pushstring(d_lua, "__index"); lua_pushvalue(d_lua, -2); /* pushes the metatable */ lua_settable(d_lua, -3); /* metatable.__index = metatable */ luaL_openlib(d_lua, NULL, ldp_methods, 0); lua_pop(d_lua, 1); } #else static const struct luaL_Reg ldp_methods [] = { {"setRcode", ldp_setRcode}, {"getQuestion", ldp_getQuestion}, {"addRecords", ldp_addRecords}, {"getRemote", ldp_getRemote}, {NULL, NULL} }; void AuthLua::registerLuaDNSPacket(void) { luaL_newmetatable(d_lua, "LuaDNSPacket"); lua_pushstring(d_lua, "__index"); lua_pushvalue(d_lua, -2); /* pushes the metatable */ lua_settable(d_lua, -3); /* metatable.__index = metatable */ luaL_newlib(d_lua, ldp_methods); lua_pop(d_lua, 1); } #endif DNSPacket* AuthLua::prequery(DNSPacket *p) { lua_getglobal(d_lua,"prequery"); if(!lua_isfunction(d_lua, -1)) { // cerr<<"No such function 'prequery'\n"; lua_pop(d_lua, 1); return 0; } DNSPacket *r=0; // allocate a fresh packet and prefill the question r=p->replyPacket(); // wrap it LuaDNSPacket* lua_dp = (LuaDNSPacket *)lua_newuserdata(d_lua, sizeof(LuaDNSPacket)); lua_dp->d_p=r; // make it of the right type luaL_getmetatable(d_lua, "LuaDNSPacket"); lua_setmetatable(d_lua, -2); if(lua_pcall(d_lua, 1, 1, 0)) { // error string error=string("lua error in prequery: ")+lua_tostring(d_lua, -1); theL()< #include "communicator.hh" #include #include #include "dnsbackend.hh" #include "ueberbackend.hh" #include "packethandler.hh" #include "resolver.hh" #include "logger.hh" #include "dns.hh" #include "arguments.hh" #include "session.hh" #include "packetcache.hh" #include #include #include "base64.hh" #include "inflighter.cc" #include "lua-auth.hh" #include "namespaces.hh" #include "common_startup.hh" #include using boost::scoped_ptr; template bool rfc1982LessThan(T a, T b) { return ((signed)(a - b)) < 0; } void CommunicatorClass::addSuckRequest(const string &domain, const string &master) { Lock l(&d_lock); SuckRequest sr; sr.domain = domain; sr.master = master; pair res; res=d_suckdomains.push_back(sr); if(res.second) { d_suck_sem.post(); } } void CommunicatorClass::suck(const string &domain,const string &remote) { L<(P.getBackend()); // copy of the same UeberBackend NSEC3PARAMRecordContent ns3pr, hadNs3pr; bool narrow, hadNarrow=false; DNSSECKeeper dk (B); // reuse our backend for DNSSECKeeper bool dnssecZone = false; bool haveNSEC3=false; if(dk.isSecuredZone(domain)) { dnssecZone=true; haveNSEC3=dk.getNSEC3PARAM(domain, &ns3pr, &narrow); if (haveNSEC3) { hadNs3pr = ns3pr; hadNarrow = narrow; } } const bool hadNSEC3 = haveNSEC3; const bool hadPresigned = dk.isPresigned(domain); const bool hadDnssecZone = dnssecZone; if(!B->getDomainInfo(domain, di) || !di.backend) { // di.backend and B are mostly identical L< nsset, qnames; ComboAddress raddr(remote, 53); string tsigkeyname, tsigalgorithm, tsigsecret; if(dk.getTSIGForAccess(domain, remote, &tsigkeyname)) { string tsigsecret64; if(B->getTSIGKey(tsigkeyname, &tsigalgorithm, &tsigsecret64)) { B64Decode(tsigsecret64, tsigsecret); } else { L< pdl; vector scripts; if(B->getDomainMetadata(domain, "LUA-AXFR-SCRIPT", scripts) && !scripts.empty()) { try { pdl.reset(new AuthLua(scripts[0])); L< localaddr; ComboAddress laddr; if(B->getDomainMetadata(domain, "AXFR-SOURCE", localaddr) && !localaddr.empty()) { try { laddr = ComboAddress(localaddr[0]); L< rrs; set secured; while(retriever.getChunk(recs)) { if(first) { L<qtype.getCode() == QType::OPT || i->qtype.getCode() == QType::TSIG) // ignore EDNS0 & TSIG continue; if(!endsOn(i->qname, domain)) { L<qname<<"'|"<qtype.getName()<<" during AXFR of zone '"<qtype.getCode() == QType::NSEC3PARAM) { ns3pr = NSEC3PARAMRecordContent(i->content); narrow = false; dnssecZone = haveNSEC3 = gotPresigned = gotNSEC3 = true; continue; } else if (i->qtype.getCode() == QType::NSEC3) { dnssecZone = gotPresigned = true; NSEC3RecordContent ns3rc(i->content); gotOptOutFlag = ns3rc.d_flags & 1; if (ns3rc.d_set.count(QType::NS) && !pdns_iequals(i->qname, domain)) secured.insert(toLower(makeRelative(i->qname, domain))); continue; } else if (i->qtype.getCode() == QType::NSEC) { dnssecZone = gotPresigned = true; continue; } if(i->qtype.getCode() == QType::SOA) { if(soa_serial != 0) continue; //skip the last SOA SOAData sd; fillSOAData(i->content,sd); soa_serial = sd.serial; } i->domain_id=domain_id; #if 0 if(i->qtype.getCode()>=60000) throw DBException("Database can't store unknown record type "+lexical_cast(i->qtype.getCode()-1024)); #endif vector out; if(pdl && pdl->axfrfilter(raddr, domain, *i, out)) { BOOST_FOREACH(const DNSResourceRecord& rr, out) { rrs.push_back(rr); } } else { rrs.push_back(*i); } } } BOOST_FOREACH(const DNSResourceRecord& rr, rrs) { if(rr.qtype.getCode() == QType::NS && !pdns_iequals(rr.qname, domain)) nsset.insert(rr.qname); qnames.insert(rr.qname); } if(dnssecZone) { if(!haveNSEC3) L<startTransaction(domain, domain_id); bool doent=true; uint32_t maxent = ::arg().asNum("max-ent-entries"); string ordername, shorter; set nonterm, rrterm; BOOST_FOREACH(DNSResourceRecord& rr, rrs) { // Figure out auth and ents rr.auth=true; shorter=rr.qname; rrterm.clear(); do { if(doent) { if (!qnames.count(shorter) && !nonterm.count(shorter) && !rrterm.count(shorter)) rrterm.insert(shorter); } if(nsset.count(shorter) && rr.qtype.getCode() != QType::DS) { rr.auth=false; break; } if (pdns_iequals(shorter, domain)) // stop at apex break; }while(chopOff(shorter)); // Insert ents for auth rrs if(doent && rr.auth) { nonterm.insert(rrterm.begin(), rrterm.end()); if(nonterm.size() > maxent) { L<feedRecord(rr, &ordername); } else di.backend->feedRecord(rr); } else { // NSEC if (rr.auth || rr.qtype.getCode() == QType::NS) { ordername=toLower(labelReverse(makeRelative(rr.qname, domain))); di.backend->feedRecord(rr, &ordername); } else di.backend->feedRecord(rr); } } else di.backend->feedRecord(rr); } // Insert empty non-terminals if(doent && !nonterm.empty()) { if (haveNSEC3) { di.backend->feedEnts3(domain_id, domain, nonterm, ns3pr.d_iterations, ns3pr.d_salt, narrow); } else di.backend->feedEnts(domain_id, nonterm); } // now we also need to update the presigned flag and NSEC3PARAM // for the zone if (gotPresigned) { if (!hadDnssecZone && !hadPresigned) { // zone is now presigned dk.setPresigned(domain); } if (hadPresigned || !hadDnssecZone) { // this is a presigned zone, update NSEC3PARAM if (gotNSEC3) { ns3pr.d_flags = gotOptOutFlag ? 1 : 0; // only update if there was a change if (!hadNSEC3 || (narrow != hadNarrow) || (ns3pr.d_algorithm != hadNs3pr.d_algorithm) || (ns3pr.d_flags != hadNs3pr.d_flags) || (ns3pr.d_iterations != hadNs3pr.d_iterations) || (ns3pr.d_salt != hadNs3pr.d_salt)) { dk.setNSEC3PARAM(domain, ns3pr, narrow); } } else if (hadNSEC3) { dk.unsetNSEC3PARAM(domain); } } } else if (hadPresigned) { // zone is no longer presigned dk.unsetPresigned(domain); dk.unsetNSEC3PARAM(domain); } di.backend->commitTransaction(); di.backend->setFresh(domain_id); PC.purge(domain+"$"); L<abortTransaction(); } } catch(MOADNSException &re) { L<abortTransaction(); } } catch(std::exception &re) { L<abortTransaction(); } } catch(ResolverException &re) { L<abortTransaction(); } } catch(AhuException &ae) { L<abortTransaction(); } } } namespace { struct QueryInfo { struct timeval query_ttd; uint16_t id; }; struct DomainNotificationInfo { DomainInfo di; bool dnssecOk; string tsigkeyname, tsigalgname, tsigsecret; }; } struct SlaveSenderReceiver { typedef pair Identifier; struct Answer { uint32_t theirSerial; uint32_t theirInception; uint32_t theirExpire; }; map d_freshness; SlaveSenderReceiver() { } void deliverTimeout(const Identifier& i) { } Identifier send(DomainNotificationInfo& dni) { random_shuffle(dni.di.masters.begin(), dni.di.masters.end()); try { ComboAddress remote(*dni.di.masters.begin()); return make_pair(dni.di.zone, d_resolver.sendResolve(ComboAddress(*dni.di.masters.begin(), 53), dni.di.zone.c_str(), QType::SOA, dni.dnssecOk, dni.tsigkeyname, dni.tsigalgname, dni.tsigsecret) ); } catch(AhuException& e) { throw runtime_error("While attempting to query freshness of '"+dni.di.zone+"': "+e.reason); } } bool receive(Identifier& id, Answer& a) { if(d_resolver.tryGetSOASerial(&id.first, &a.theirSerial, &a.theirInception, &a.theirExpire, &id.second)) { return 1; } return 0; } void deliverAnswer(DomainNotificationInfo& dni, const Answer& a, unsigned int usec) { d_freshness[dni.di.id]=a; } Resolver d_resolver; }; void CommunicatorClass::addSlaveCheckRequest(const DomainInfo& di, const ComboAddress& remote) { Lock l(&d_lock); DomainInfo ours = di; ours.backend = 0; d_tocheck.insert(ours); d_any_sem.post(); // kick the loop! } void CommunicatorClass::addTrySuperMasterRequest(DNSPacket *p) { Lock l(&d_lock); DNSPacket ours = *p; d_potentialsupermasters.push_back(ours); d_any_sem.post(); // kick the loop! } void CommunicatorClass::slaveRefresh(PacketHandler *P) { UeberBackend *B=dynamic_cast(P->getBackend()); vector rdomains; vector sdomains; // the bool is for 'presigned' vector trysuperdomains; { Lock l(&d_lock); rdomains.insert(rdomains.end(), d_tocheck.begin(), d_tocheck.end()); d_tocheck.clear(); trysuperdomains.insert(trysuperdomains.end(), d_potentialsupermasters.begin(), d_potentialsupermasters.end()); d_potentialsupermasters.clear(); } BOOST_FOREACH(DNSPacket& dp, trysuperdomains) { int res; res=P->trySuperMasterSynchronous(&dp); if(res>=0) { DNSPacket *r=dp.replyPacket(); r->setRcode(res); r->setOpcode(Opcode::Notify); N->send(r); delete r; } } if(rdomains.empty()) // if we have priority domains, check them first B->getUnfreshSlaveInfos(&rdomains); DNSSECKeeper dk(B); // NOW HEAR THIS! This DK uses our B backend, so no interleaved access! { Lock l(&d_lock); domains_by_name_t& nameindex=boost::multi_index::get(d_suckdomains); BOOST_FOREACH(DomainInfo& di, rdomains) { SuckRequest sr; sr.domain=di.zone; if(di.masters.empty()) // slave domains w/o masters are ignored continue; // remove unfresh domains already queued for AXFR, no sense polling them again sr.master=*di.masters.begin(); if(nameindex.count(sr)) { continue; } DomainNotificationInfo dni; dni.di=di; dni.dnssecOk = dk.isPresigned(di.zone); if(dk.getTSIGForAccess(di.zone, sr.master, &dni.tsigkeyname)) { string secret64; B->getTSIGKey(dni.tsigkeyname, &dni.tsigalgname, &secret64); B64Decode(secret64, dni.tsigsecret); } sdomains.push_back(dni); } } if(sdomains.empty()) { if(d_slaveschanged) { Lock l(&d_lock); L<1 ? "s" : "")<<" need"<< (sdomains.size()>1 ? "" : "s")<< " checking, "<, SlaveSenderReceiver> ifl(sdomains, ssr); ifl.d_maxInFlight = 200; for(;;) { try { ifl.run(); break; } catch(std::exception& e) { L<getDomainInfo(di.zone, di)) { L< their serial "<< theirserial << endl; di.backend->setFresh(di.id); } else if(theirserial == ourserial) { if(!dk.isPresigned(di.zone)) { L<setFresh(di.id); } else { B->lookup(QType(QType::RRSIG), di.zone); // can't use DK before we are done with this lookup! DNSResourceRecord rr; uint32_t maxExpire=0, maxInception=0; while(B->get(rr)) { RRSIGRecordContent rrc(rr.content); if(rrc.d_type == QType::SOA) { maxInception = std::max(maxInception, rrc.d_siginception); maxExpire = std::max(maxExpire, rrc.d_sigexpire); } } if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) { L<setFresh(di.id); } else { L<& ret) { return -1; } pdns-3.3/pdns/packetcache.cc0000644000014601777760000002437412136555572017316 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 - 2011 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "utility.hh" #include "packetcache.hh" #include "logger.hh" #include "arguments.hh" #include "statbag.hh" #include #include extern StatBag S; PacketCache::PacketCache() { pthread_rwlock_init(&d_mut, 0); // d_ops = 0; d_ttl=-1; d_recursivettl=-1; S.declare("packetcache-hit"); S.declare("packetcache-miss"); S.declare("packetcache-size"); d_statnumhit=S.getPointer("packetcache-hit"); d_statnummiss=S.getPointer("packetcache-miss"); d_statnumentries=S.getPointer("packetcache-size"); } PacketCache::~PacketCache() { WriteLock l(&d_mut); } int PacketCache::get(DNSPacket *p, DNSPacket *cached) { extern StatBag S; if(d_ttl<0) getTTLS(); if(!((++d_ops) % 300000)) { cleanup(); } if(d_doRecursion && p->d.rd) { // wants recursion if(!d_recursivettl) { (*d_statnummiss)++; return 0; } } else { // does not if(!d_ttl) { (*d_statnummiss)++; return 0; } } bool packetMeritsRecursion=d_doRecursion && p->d.rd; if(ntohs(p->d.qdcount)!=1) // we get confused by packets with more than one question return 0; string value; bool haveSomething; { TryReadLock l(&d_mut); // take a readlock here if(!l.gotIt()) { S.inc("deferred-cache-lookup"); return 0; } uint16_t maxReplyLen = p->d_tcp ? 0xffff : p->getMaxReplyLen(); haveSomething=getEntryLocked(p->qdomain, p->qtype, PacketCache::PACKETCACHE, value, -1, packetMeritsRecursion, maxReplyLen, p->d_dnssecOk, p->hasEDNS()); } if(haveSomething) { (*d_statnumhit)++; if(cached->noparse(value.c_str(), value.size()) < 0) { return 0; } cached->spoofQuestion(p); // for correct case return 1; } // cerr<<"Packet cache miss for '"<qdomain<<"', merits: "<d.qdcount)!=1) { return; // do not try to cache packets with multiple questions } if(q->qclass != QClass::IN) // we only cache the INternet return; bool packetMeritsRecursion=d_doRecursion && q->d.rd; uint16_t maxReplyLen = q->d_tcp ? 0xffff : q->getMaxReplyLen(); unsigned int ourttl = packetMeritsRecursion ? d_recursivettl : d_ttl; if(maxttlqdomain, q->qtype, PacketCache::PACKETCACHE, r->getString(), ourttl, -1, packetMeritsRecursion, maxReplyLen, q->d_dnssecOk, q->hasEDNS()); } // universal key appears to be: qname, qtype, kind (packet, query cache), optionally zoneid, meritsRecursion void PacketCache::insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID, bool meritsRecursion, unsigned int maxReplyLen, bool dnssecOk, bool EDNS) { if(!((++d_ops) % 300000)) { cleanup(); } if(!ttl) return; //cerr<<"Inserting qname '"<qname, suffix) && !iends_with(iter->qname, dotsuffix)) { // cerr<<"Stopping!"< range = d_map.equal_range(tie(match)); d_map.erase(range.first, range.second); } *d_statnumentries=d_map.size(); return delcount; } // called from ueberbackend bool PacketCache::getEntry(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion, unsigned int maxReplyLen, bool dnssecOk, bool hasEDNS) { if(d_ttl<0) getTTLS(); if(!((++d_ops) % 300000)) { cleanup(); } TryReadLock l(&d_mut); // take a readlock here if(!l.gotIt()) { S.inc( "deferred-cache-lookup"); return false; } return getEntryLocked(qname, qtype, cet, value, zoneID, meritsRecursion, maxReplyLen, dnssecOk, hasEDNS); } bool PacketCache::getEntryLocked(const string &qname, const QType& qtype, CacheEntryType cet, string& value, int zoneID, bool meritsRecursion, unsigned int maxReplyLen, bool dnssecOK, bool hasEDNS) { uint16_t qt = qtype.getCode(); //cerr<<"Lookup for maxReplyLen: "<ttd > now); if(ret) value = i->value; return ret; } map PacketCache::getCounts() { ReadLock l(&d_mut); mapret; int recursivePackets=0, nonRecursivePackets=0, queryCacheEntries=0, negQueryCacheEntries=0; for(cmap_t::const_iterator iter = d_map.begin() ; iter != d_map.end(); ++iter) { if(iter->ctype == PACKETCACHE) if(iter->meritsRecursion) recursivePackets++; else nonRecursivePackets++; else if(iter->ctype == QUERYCACHE) { if(iter->value.empty()) negQueryCacheEntries++; else queryCacheEntries++; } } ret['!']=negQueryCacheEntries; ret['Q']=queryCacheEntries; ret['n']=nonRecursivePackets; ret['r']=recursivePackets; return ret; } int PacketCache::size() { ReadLock l(&d_mut); return d_map.size(); } /** readlock for figuring out which iterators to delete, upgrade to writelock when actually cleaning */ void PacketCache::cleanup() { WriteLock l(&d_mut); *d_statnumentries=d_map.size(); unsigned int maxCached=::arg().asNum("max-cache-entries"); unsigned int toTrim=0; unsigned int cacheSize=*d_statnumentries; if(maxCached && cacheSize > maxCached) { toTrim = cacheSize - maxCached; } unsigned int lookAt=0; // two modes - if toTrim is 0, just look through 10% of the cache and nuke everything that is expired // otherwise, scan first 5*toTrim records, and stop once we've nuked enough if(toTrim) lookAt=5*toTrim; else lookAt=cacheSize/10; // cerr<<"cacheSize: "<::type sequence_t; sequence_t& sidx=d_map.get<1>(); unsigned int erased=0, lookedAt=0; for(sequence_t::iterator i=sidx.begin(); i != sidx.end(); lookedAt++) { if(i->ttd < now) { sidx.erase(i++); erased++; } else ++i; if(toTrim && erased > toTrim) break; if(lookedAt > lookAt) break; } // cerr<<"erased: "< #include #include #include #include #include "dnsparser.hh" #include "namespaces.hh" #include "namespaces.hh" struct QuestionIdentifier { QuestionIdentifier() {} bool operator<(const QuestionIdentifier& rhs) const { return tie(d_sourceip, d_destip, d_sourceport, d_destport, d_qname, d_qtype, d_id) < tie(rhs.d_sourceip, rhs.d_destip, rhs.d_sourceport, rhs.d_destport, rhs.d_qname, rhs.d_qtype, rhs.d_id); } // the canonical direction is that of the question static QuestionIdentifier create(const struct ip* ip, const struct udphdr* udp, const MOADNSParser& mdp) { QuestionIdentifier ret; if(mdp.d_header.qr) { memcpy(&ret.d_sourceip, &ip->ip_dst, sizeof(ret.d_sourceip)); ret.d_sourceip=htonl(ret.d_sourceip); memcpy(&ret.d_destip, &ip->ip_src, sizeof(ret.d_destip)); ret.d_destip=htonl(ret.d_destip); ret.d_sourceport=htons(udp->uh_dport); ret.d_destport=htons(udp->uh_sport); } else { memcpy(&ret.d_sourceip, &ip->ip_src, sizeof(ret.d_sourceip)); ret.d_sourceip=htonl(ret.d_sourceip); memcpy(&ret.d_destip, &ip->ip_dst, sizeof(ret.d_destip)); ret.d_destip=htonl(ret.d_destip); ret.d_sourceport=htons(udp->uh_sport); ret.d_destport=htons(udp->uh_dport); } ret.d_qname=mdp.d_qname; ret.d_qtype=mdp.d_qtype; ret.d_id=mdp.d_header.id; return ret; } uint32_t d_sourceip; uint32_t d_destip; uint16_t d_sourceport; uint16_t d_destport; string d_qname; uint16_t d_qtype; uint16_t d_id; }; inline ostream& operator<<(ostream &s, const QuestionIdentifier& qi) { s<< "'"<>24 & 0xff)<<"."; s<< (rint>>16 & 0xff)<<"."; s<< (rint>>8 & 0xff)<<"."; s<< (rint & 0xff); s<<":"<>24 & 0xff)<<"."; s<< (rint>>16 & 0xff)<<"."; s<< (rint>>8 & 0xff)<<"."; s<< (rint & 0xff); return s<<":"< #include #include #include "namespaces.hh" #include "misc.hh" #include #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "config.h" #include #include #include #ifndef HAVE_STRCASESTR /* * strcasestr() locates the first occurrence in the string s1 of the * sequence of characters (excluding the terminating null character) * in the string s2, ignoring case. strcasestr() returns a pointer * to the located string, or a null pointer if the string is not found. * If s2 is empty, the function returns s1. */ static char * strcasestr(const char *s1, const char *s2) { int *cm = __trans_lower; const uchar_t *us1 = (const uchar_t *)s1; const uchar_t *us2 = (const uchar_t *)s2; const uchar_t *tptr; int c; if (us2 == NULL || *us2 == '\0') return ((char *)us1); c = cm[*us2]; while (*us1 != '\0') { if (c == cm[*us1++]) { tptr = us1; while (cm[c = *++us2] == cm[*us1++] && c != '\0') continue; if (c == '\0') return ((char *)tptr - 1); us1 = tptr; us2 = (const uchar_t *)s2; c = cm[*us2]; } } return (NULL); } #endif // HAVE_STRCASESTR using namespace rapidjson; string makeStringFromDocument(const Document& doc) { StringBuffer output; Writer w(output); doc.Accept(w); return string(output.GetString(), output.Size()); } string returnJSONObject(const map& items) { Document doc; doc.SetObject(); typedef map items_t; BOOST_FOREACH(const items_t::value_type& val, items) { doc.AddMember(val.first.c_str(), val.second.c_str(), doc.GetAllocator()); } return makeStringFromDocument(doc); } string makeLogGrepJSON(map& varmap, const string& fname, const string& prefix) { FILE* ptr = fopen(fname.c_str(), "r"); if(!ptr) { return "[]"; } boost::shared_ptr fp(ptr, fclose); string line; string needle=varmap["needle"]; trim_right(needle); boost::replace_all(needle, "%20", " "); boost::replace_all(needle, "%22", "\""); boost::tokenizer > t(needle, boost::escaped_list_separator("\\", " ", "\"")); vector matches(t.begin(), t.end()); matches.push_back(prefix); boost::circular_buffer lines(200); while(stringfgets(fp.get(), line)) { vector::const_iterator iter; for(iter = matches.begin(); iter != matches.end(); ++iter) { if(!strcasestr(line.c_str(), iter->c_str())) break; } if(iter == matches.end()) { trim_right(line); lines.push_front(line); } } Document doc; doc.SetArray(); if(!lines.empty()) { BOOST_FOREACH(const string& line, lines) { doc.PushBack(line.c_str(), doc.GetAllocator()); } } return makeStringFromDocument(doc); } pdns-3.3/pdns/dnspcap.hh0000644000014601777760000000471512164306474016516 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_DNSPCAP_HH #define PDNS_DNSPCAP_HH #include #include #include #include "misc.hh" #include #define __FAVOR_BSD #include #include #include #if defined(__NetBSD__) #include #include #elif defined (__OpenBSD__) #include #include #elif defined (__SVR4) && defined (__sun) #include #else #include #endif #include #include #include "namespaces.hh" struct pdns_pcap_file_header { uint32_t magic; uint16_t version_major; uint16_t version_minor; uint32_t thiszone; /* gmt to local correction */ uint32_t sigfigs; /* accuracy of timestamps */ uint32_t snaplen; /* max length saved portion of each pkt */ uint32_t linktype; /* data link type (LINKTYPE_*) */ }; struct pdns_timeval { uint32_t tv_sec; uint32_t tv_usec; }; struct pdns_pcap_pkthdr { struct pdns_timeval ts; /* time stamp */ uint32_t caplen; /* length of portion present */ uint32_t len; /* length this packet (off wire) */ }; struct pdns_lcc_header { uint16_t lcc_pkttype;/* packet type */ uint16_t lcc_hatype;/* link-layer address type */ uint16_t lcc_halen;/* link-layer address length */ uint8_t lcc_addr[8];/* link-layer address */ uint16_t lcc_protocol;/* protocol */ }; class PcapPacketReader { public: class EofException : public runtime_error { public: EofException(const string& str="") : runtime_error(str) { } }; PcapPacketReader(const string& fname); ~PcapPacketReader(); template void checkedFread(T* ptr) { checkedFreadSize(ptr, sizeof(*ptr)); } void checkedFreadSize(void* ptr, size_t size) ; bool getUDPPacket(); struct pdns_lcc_header* d_lcc; struct ether_header* d_ether; struct ip *d_ip; const struct tcphdr *d_tcp; const struct udphdr *d_udp; const uint8_t* d_payload; unsigned int d_len; struct pdns_pcap_pkthdr d_pheader; pdns_pcap_file_header d_pfh; unsigned int d_runts, d_oversized, d_correctpackets, d_nonetheripudp; char d_buffer[32768]; private: FILE* d_fp; string d_fname; int d_skipMediaHeader; }; class PcapPacketWriter { public: PcapPacketWriter(const string& fname, PcapPacketReader& ppr); void write(); ~PcapPacketWriter(); private: string d_fname; const PcapPacketReader& d_ppr; FILE *d_fp; }; #endif // DNSPCAP_HH pdns-3.3/pdns/dnsreplay.cc0000644000014601777760000004300212136555572017051 0ustar00jenkinsnogroup00000000000000/** Replay all recursion-desired DNS questions to a specified IP address. Track all outgoing questions, remap id to one of ours. Also track all recorded answers, and map them to that same id, the 'expectation'. When we see a question, parse it, give it a QuestionIdentifyer, and and an id from the free-id list. When we see an answer in the tcpdump, parse it, make QI, and add it to the original QI and check When we see an answer from the socket, use the id to match it up to the original QI and check There is one central object, which has (when complete) our assigned id QI Original answer Socket answer What to do with timeouts. We keep around at most 65536 outstanding answers. */ /* mental_clock=0; for(;;) { do { read a packet send a packet } while(time_of_last_packet_sent < mental_clock) mental_clock=time_of_last_packet_sent; wait for a response packet for 0.1 seconds note how much time has passed mental_clock+=time_passed; } */ #include #include "statbag.hh" #include "dnspcap.hh" #include "sstuff.hh" #include "anadns.hh" #include #include "dnsrecords.hh" // this is needed because boost multi_index also uses 'L', as do we (which is sad enough) #undef L #include #include #include #include #include #include #include #include "namespaces.hh" using namespace ::boost::multi_index; #include "namespaces.hh" StatBag S; bool g_quiet=true; int g_timeoutMsec=0; namespace po = boost::program_options; po::variables_map g_vm; const struct timeval operator*(float fact, const struct timeval& rhs) { // cout<<"In: "< d_available; } s_idmanager; struct AssignedIDTag{}; struct QuestionTag{}; struct QuestionData { QuestionData() : d_assignedID(-1), d_origRcode(-1), d_newRcode(-1), d_norecursionavailable(false), d_origlate(false), d_newlate(false) { } QuestionIdentifier d_qi; int d_assignedID; MOADNSParser::answers_t d_origAnswers, d_newAnswers; int d_origRcode, d_newRcode; struct timeval d_resentTime; bool d_norecursionavailable; bool d_origlate, d_newlate; }; typedef multi_index_container< QuestionData, indexed_by< ordered_unique, BOOST_MULTI_INDEX_MEMBER(QuestionData, QuestionIdentifier, d_qi) > , ordered_unique, BOOST_MULTI_INDEX_MEMBER(QuestionData, int, d_assignedID) > > > qids_t; qids_t qids; bool g_throttled; unsigned int s_questions, s_origanswers, s_weanswers, s_wetimedout, s_perfect, s_mostly, s_origtimedout; unsigned int s_wenever, s_orignever; unsigned int s_webetter, s_origbetter, s_norecursionavailable; unsigned int s_weunmatched, s_origunmatched; unsigned int s_wednserrors, s_origdnserrors, s_duplicates; double DiffTime(const struct timeval& first, const struct timeval& second) { int seconds=second.tv_sec - first.tv_sec; int useconds=second.tv_usec - first.tv_usec; if(useconds < 0) { seconds-=1; useconds+=1000000; } return seconds + useconds/1000000.0; } void WeOrigSlowQueriesDelta(int& weOutstanding, int& origOutstanding, int& weSlow, int& origSlow) { struct timeval now; gettimeofday(&now, 0); weOutstanding=origOutstanding=weSlow=origSlow=0; for(qids_t::iterator i=qids.begin(); i!=qids.end(); ++i) { double dt=DiffTime(i->d_resentTime, now); if(dt < 2.0) { if(i->d_newRcode == -1) weOutstanding++; if(i->d_origRcode == -1) origOutstanding++; } else { if(i->d_newRcode == -1) { weSlow++; if(!i->d_newlate) { QuestionData qd=*i; qd.d_newlate=true; qids.replace(i, qd); s_wetimedout++; } } if(i->d_origRcode == -1) { origSlow++; if(!i->d_origlate) { QuestionData qd=*i; qd.d_origlate=true; qids.replace(i, qd); s_origtimedout++; } } } } } void compactAnswerSet(MOADNSParser::answers_t orig, set& compacted) { for(MOADNSParser::answers_t::const_iterator i=orig.begin(); i != orig.end(); ++i) if(i->first.d_place==DNSRecord::Answer) compacted.insert(i->first); } bool isRcodeOk(int rcode) { return rcode==0 || rcode==3; } set > s_origbetterset; bool isRootReferral(const MOADNSParser::answers_t& answers) { if(answers.empty()) return false; bool ok=true; for(MOADNSParser::answers_t::const_iterator iter = answers.begin(); iter != answers.end(); ++iter) { // cerr<<(int)iter->first.d_place<<", "<first.d_label<<" "<first.d_type<<", # "<first.d_place!=2) ok=false; if(iter->first.d_label!="." || iter->first.d_type!=QType::NS) ok=false; } return ok; } void measureResultAndClean(const QuestionIdentifier& qi) { QuestionData qd=*qids.find(qi); set canonicOrig, canonicNew; compactAnswerSet(qd.d_origAnswers, canonicOrig); compactAnswerSet(qd.d_newAnswers, canonicNew); if(!g_quiet) { cout<::const_iterator i=canonicOrig.begin(); i!=canonicOrig.end(); ++i) cout<<"\t"<d_label<<"\t"<d_type)<<"\t'" << (i->d_content ? i->d_content->getZoneRepresentation() : "") <<"'\n"; cout<<"new: rcode="<::const_iterator i=canonicNew.begin(); i!=canonicNew.end(); ++i) cout<<"\t"<d_label<<"\t"<d_type)<<"\t'" << (i->d_content ? i->d_content->getZoneRepresentation() : "") <<"'\n"; cout<<"\n"; cout<<"-\n"; } } qids.erase(qi); s_idmanager.releaseID(qd.d_assignedID); } Socket *s_socket; void receiveFromReference() try { string packet; ComboAddress remote; int res=waitForData(s_socket->getHandle(), g_timeoutMsec/1000, 1000*(g_timeoutMsec%1000)); if(res < 0 || res==0) return; while(s_socket->recvFromAsync(packet, remote)) { try { s_weanswers++; MOADNSParser mdp(packet.c_str(), packet.length()); if(!mdp.d_header.qr) { cout<<"Received a question from our reference nameserver!"<::type qids_by_id_index_t; qids_by_id_index_t& idindex=qids.get(); qids_by_id_index_t::const_iterator found=idindex.find(ntohs(mdp.d_header.id)); if(found == idindex.end()) { // cout<<"Received an answer ("<d_qi; QuestionData qd=*found; qd.d_newAnswers=mdp.d_answers; qd.d_newRcode=mdp.d_header.rcode; idindex.replace(found, qd); if(qd.d_origRcode!=-1) { // cout<<"Removing entry "<first<<", is done [in socket]"<d_resentTime, now) < 10) ++i; else { s_idmanager.releaseID(i->d_assignedID); if(i->d_newRcode==-1) { s_wenever++; } if(i->d_origRcode==-1) { s_orignever++; } qids.erase(i++); } } } void printStats(uint64_t origWaitingFor=0, uint64_t weWaitingFor=0) { format headerfmt ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n"); format datafmt("%s%|9t|%d %|21t|%d %|29t|%d %|36t|%d %|47t|%d %|57t|%d %|66t|%d %|72t|%d\n"); cerr< 1000) { cerr<<"Too many questions ("<uh_dport)!=53 && ntohs(pr.d_udp->uh_sport)!=53) || dh->rd != g_rdSelector || (unsigned int)pr.d_len <= sizeof(dnsheader)) return sent; QuestionData qd; try { if(!dh->qr) { qd.d_assignedID = s_idmanager.peakID(); uint16_t tmp=dh->id; dh->id=htons(qd.d_assignedID); s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote); sent=true; dh->id=tmp; } MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp); if(!mdp.d_header.qr) { s_questions++; if(qids.count(qi)) { if(!g_quiet) cout<<"Saw an exact duplicate question, "<ra) { s_norecursionavailable++; qd.d_norecursionavailable=true; } qids.replace(i, qd); if(qd.d_newRcode!=-1) { // cout<<"Removing entry "<()->default_value(0), "stop after this many packets") ("quiet", po::value()->default_value(true), "don't be too noisy") ("recursive", po::value()->default_value(true), "look at recursion desired packets, or not (defaults true)") ("speedup", po::value()->default_value(1), "replay at this speedup") ("timeout-msec", po::value()->default_value(500), "wait at least this many milliseconds for a reply"); po::options_description alloptions; po::options_description hidden("hidden options"); hidden.add_options() ("pcap-source", po::value(), "PCAP source file") ("target-ip", po::value()->default_value("127.0.0.1"), "target-ip") ("target-port", po::value()->default_value(5300), "target port"); alloptions.add(desc).add(hidden); po::positional_options_description p; p.add("pcap-source", 1); p.add("target-ip", 1); p.add("target-port", 1); po::store(po::command_line_parser(argc, argv).options(alloptions).positional(p).run(), g_vm); po::notify(g_vm); reportAllTypes(); if (g_vm.count("help")) { cerr << "Usage: dnsreplay [--options] filename [ip-address] [port]"<(); g_rdSelector = g_vm["recursive"].as(); g_quiet = g_vm["quiet"].as(); float speedup=g_vm["speedup"].as(); g_timeoutMsec=g_vm["timeout-msec"].as(); PcapPacketReader pr(g_vm["pcap-source"].as()); s_socket= new Socket(InterNetwork, Datagram); s_socket->setNonBlocking(); ComboAddress remote(g_vm["target-ip"].as(), g_vm["target-port"].as()); cerr<<"Replaying packets to: '"<()<<"', port "<()< packetLimit) break; mental_time=packet_ts; struct timeval then, now; gettimeofday(&then,0); receiveFromReference(); gettimeofday(&now, 0); mental_time= mental_time + speedup * (now-then); } out:; sleep(1); receiveFromReference(); printStats(); } catch(std::exception& e) { cerr<<"Fatal: "< uint32_t localtime_format_YYYYMMDDSS(time_t t, uint32_t seq) { struct tm tm; localtime_r(&t, &tm); return (uint32_t)(tm.tm_year+1900) * 1000000u + (uint32_t)(tm.tm_mon + 1) * 10000u + (uint32_t)tm.tm_mday * 100u + seq; } bool editSOA(DNSSECKeeper& dk, const string& qname, DNSPacket* dp) { vector& rrs = dp->getRRS(); BOOST_FOREACH(DNSResourceRecord& rr, rrs) { if(rr.qtype.getCode() == QType::SOA && pdns_iequals(rr.qname,qname)) { string kind; dk.getFromMeta(qname, "SOA-EDIT", kind); if(kind.empty()) return false; SOAData sd; fillSOAData(rr.content, sd); sd.serial = calculateEditSoa(sd, kind); rr.content = serializeSOAData(sd); return true; } } return false; } uint32_t calculateEditSoa(SOAData sd, const string& kind) { if(pdns_iequals(kind,"INCEPTION")) { time_t inception = getStartOfWeek(); return localtime_format_YYYYMMDDSS(inception, 1); } else if(pdns_iequals(kind,"INCEPTION-INCREMENT")) { time_t inception = getStartOfWeek(); uint32_t inception_serial = localtime_format_YYYYMMDDSS(inception, 1); uint32_t dont_increment_after = localtime_format_YYYYMMDDSS(inception + 2*86400, 99); if(sd.serial <= dont_increment_after) return (sd.serial + 2); /* "day00" and "day01" are reserved for inception increasing, so increment sd.serial by two */ else if(sd.serial < inception_serial) return inception_serial; } else if(pdns_iequals(kind,"INCEPTION-WEEK")) { time_t inception = getStartOfWeek(); return ( inception / (7*86400) ); } else if(pdns_iequals(kind,"INCREMENT-WEEKS")) { time_t inception = getStartOfWeek(); return (sd.serial + (inception / (7*86400))); } else if(pdns_iequals(kind,"EPOCH")) { return time(0); } else if(pdns_iequals(kind,"INCEPTION-EPOCH")) { time_t inception = getStartOfWeek(); if (sd.serial < inception) return inception; } return sd.serial; } pdns-3.3/pdns/nsecrecords.cc0000644000014601777760000001627212136555572017373 0ustar00jenkinsnogroup00000000000000#include "dnsrecords.hh" void NSECRecordContent::report(void) { regist(1, 47, &make, &make, "NSEC"); } DNSRecordContent* NSECRecordContent::make(const string& content) { return new NSECRecordContent(content); } NSECRecordContent::NSECRecordContent(const string& content, const string& zone) : DNSRecordContent(47) { RecordTextReader rtr(content, zone); rtr.xfrLabel(d_next); while(!rtr.eof()) { uint16_t type; rtr.xfrType(type); d_set.insert(type); } } void NSECRecordContent::toPacket(DNSPacketWriter& pw) { pw.xfrLabel(d_next); uint8_t res[34]; set::const_iterator i; int oldWindow = -1; int window = 0; int len = 0; string tmp; for(i=d_set.begin(); i != d_set.end(); ++i){ uint16_t bit = (*i)%256; window = static_cast((*i) / 256); if (window != oldWindow) { if (oldWindow > -1) { res[0] = static_cast(oldWindow); res[1] = static_cast(len); tmp.assign(res, res+len+2); pw.xfrBlob(tmp); } memset(res, 0, 34); oldWindow = window; } res[2+bit/8] |= 1 << (7-(bit%8)); len=1+bit/8; } res[0] = static_cast(window); res[1] = static_cast(len); tmp.assign(res, res+len+2); pw.xfrBlob(tmp); } NSECRecordContent::DNSRecordContent* NSECRecordContent::make(const DNSRecord &dr, PacketReader& pr) { NSECRecordContent* ret=new NSECRecordContent(); pr.xfrLabel(ret->d_next); string bitmap; pr.xfrBlob(bitmap); // 00 06 20 00 00 00 00 03 -> NS RRSIG NSEC ( 2, 46, 47 ) counts from left if(bitmap.empty()) return ret; if(bitmap.size() < 2) throw MOADNSException("NSEC record with impossibly small bitmap"); for(unsigned int n = 0; n+1 < bitmap.size();) { unsigned int window=static_cast(bitmap[n++]); unsigned int len=static_cast(bitmap[n++]); // end if zero padding and ensure packet length if(window == 0&&len == 0) break; if(n+len>bitmap.size()) throw MOADNSException("NSEC record with bitmap length > packet length"); for(unsigned int k=0; k < len; k++) { uint8_t val=bitmap[n++]; for(int bit = 0; bit < 8 ; ++bit , val>>=1) if(val & 1) { ret->d_set.insert((7-bit) + 8*(k) + 256*window); } } } return ret; } string NSECRecordContent::getZoneRepresentation() const { string ret; RecordTextWriter rtw(ret); rtw.xfrLabel(d_next); for(set::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) { ret+=" "; ret+=NumberToType(*i); } return ret; } ////// begin of NSEC3 void NSEC3RecordContent::report(void) { regist(1, 50, &make, &make, "NSEC3"); } DNSRecordContent* NSEC3RecordContent::make(const string& content) { return new NSEC3RecordContent(content); } NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone) : DNSRecordContent(50) { RecordTextReader rtr(content, zone); rtr.xfr8BitInt(d_algorithm); rtr.xfr8BitInt(d_flags); rtr.xfr16BitInt(d_iterations); rtr.xfrHexBlob(d_salt); rtr.xfrBase32HexBlob(d_nexthash); while(!rtr.eof()) { uint16_t type; rtr.xfrType(type); d_set.insert(type); } } void NSEC3RecordContent::toPacket(DNSPacketWriter& pw) { pw.xfr8BitInt(d_algorithm); pw.xfr8BitInt(d_flags); pw.xfr16BitInt(d_iterations); pw.xfr8BitInt(d_salt.length()); pw.xfrBlob(d_salt); pw.xfr8BitInt(d_nexthash.length()); pw.xfrBlob(d_nexthash); uint8_t res[34]; set::const_iterator i; int oldWindow = -1; int window = 0; int len = 0; string tmp; for(i=d_set.begin(); i != d_set.end(); ++i){ uint16_t bit = (*i)%256; window = static_cast((*i) / 256); if (window != oldWindow) { if (oldWindow > -1) { res[0] = static_cast(oldWindow); res[1] = static_cast(len); tmp.assign(res, res+len+2); pw.xfrBlob(tmp); } memset(res, 0, 34); oldWindow = window; } res[2+bit/8] |= 1 << (7-(bit%8)); len=1+bit/8; } res[0] = static_cast(window); res[1] = static_cast(len); if (len) { tmp.assign(res, res+len+2); pw.xfrBlob(tmp); } } NSEC3RecordContent::DNSRecordContent* NSEC3RecordContent::make(const DNSRecord &dr, PacketReader& pr) { NSEC3RecordContent* ret=new NSEC3RecordContent(); pr.xfr8BitInt(ret->d_algorithm); pr.xfr8BitInt(ret->d_flags); pr.xfr16BitInt(ret->d_iterations); uint8_t len; pr.xfr8BitInt(len); pr.xfrBlob(ret->d_salt, len); pr.xfr8BitInt(len); pr.xfrBlob(ret->d_nexthash, len); string bitmap; pr.xfrBlob(bitmap); // 00 06 20 00 00 00 00 03 -> NS RRSIG NSEC ( 2, 46, 47 ) counts from left if(bitmap.empty()) return ret; if(bitmap.size() < 2) throw MOADNSException("NSEC3 record with impossibly small bitmap"); for(unsigned int n = 0; n+1 < bitmap.size();) { unsigned int window=static_cast(bitmap[n++]); unsigned int len=static_cast(bitmap[n++]); // end if zero padding and ensure packet length if(window == 0&&len == 0) break; if(n+len>bitmap.size()) throw MOADNSException("NSEC record with bitmap length > packet length"); for(unsigned int k=0; k < len; k++) { uint8_t val=bitmap[n++]; for(int bit = 0; bit < 8 ; ++bit , val>>=1) if(val & 1) { ret->d_set.insert((7-bit) + 8*(k) + 256*window); } } } return ret; } string NSEC3RecordContent::getZoneRepresentation() const { string ret; RecordTextWriter rtw(ret); rtw.xfr8BitInt(d_algorithm); rtw.xfr8BitInt(d_flags); rtw.xfr16BitInt(d_iterations); rtw.xfrHexBlob(d_salt); rtw.xfrBase32HexBlob(d_nexthash); for(set::const_iterator i=d_set.begin(); i!=d_set.end(); ++i) { ret+=" "; ret+=NumberToType(*i); } return ret; } void NSEC3PARAMRecordContent::report(void) { regist(1, 51, &make, &make, "NSEC3PARAM"); } DNSRecordContent* NSEC3PARAMRecordContent::make(const string& content) { return new NSEC3PARAMRecordContent(content); } NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) : DNSRecordContent(51) { RecordTextReader rtr(content, zone); rtr.xfr8BitInt(d_algorithm); rtr.xfr8BitInt(d_flags); rtr.xfr16BitInt(d_iterations); rtr.xfrHexBlob(d_salt); } void NSEC3PARAMRecordContent::toPacket(DNSPacketWriter& pw) { pw.xfr8BitInt(d_algorithm); pw.xfr8BitInt(d_flags); pw.xfr16BitInt(d_iterations); pw.xfr8BitInt(d_salt.length()); // cerr<<"salt: '"<d_algorithm); pr.xfr8BitInt(ret->d_flags); pr.xfr16BitInt(ret->d_iterations); pr.xfr8BitInt(ret->d_saltlength); pr.xfrHexBlob(ret->d_salt); return ret; } string NSEC3PARAMRecordContent::getZoneRepresentation() const { string ret; RecordTextWriter rtw(ret); rtw.xfr8BitInt(d_algorithm); rtw.xfr8BitInt(d_flags); rtw.xfr16BitInt(d_iterations); rtw.xfrHexBlob(d_salt); return ret; } pdns-3.3/pdns/missing0000755000014601777760000002123112136555572016140 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, 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. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.3 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar ${1+"$@"} && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar ${1+"$@"} && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" ${1+"$@"} && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" ${1+"$@"} && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 pdns-3.3/pdns/md5.hh0000644000014601777760000000200012150646616015534 0ustar00jenkinsnogroup00000000000000#ifndef _MD5_H #define _MD5_H #include #include #ifdef HAVE_LIBPOLARSSLSSL #include #else #include "ext/polarssl-1.1.2/include/polarssl/md5.h" #endif class MD5Summer { public: MD5Summer() { md5_starts(&d_context); }; void feed(const std::string &str) { feed(str.c_str(), str.length()); } void feed(const char* ptr, size_t len) { md5_update(&d_context, reinterpret_cast(ptr), len); }; const std::string get() const { md5_context ctx2; unsigned char result[16] = {0}; ctx2=d_context; md5_finish(&ctx2, result); return std::string(result, result + sizeof result); }; private: MD5Summer(const MD5Summer&); MD5Summer& operator=(const MD5Summer&); md5_context d_context; }; inline std::string pdns_md5sum(const std::string& input) { unsigned char result[16] = {0}; md5(reinterpret_cast(input.c_str()), input.length(), result); return std::string(result, result + sizeof result); } #endif /* md5.h */ pdns-3.3/pdns/test-rcpgenerator_cc.cc0000644000014601777760000000131112144677100021151 0ustar00jenkinsnogroup00000000000000#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include #include "rcpgenerator.hh" #include "misc.hh" #include using std::string; BOOST_AUTO_TEST_SUITE(rcp_generator_cc) BOOST_AUTO_TEST_CASE(test_xfrIP6) { RecordTextReader rtr("::1"); string rawIPv6; rtr.xfrIP6(rawIPv6); string loopback6; loopback6.append(15, 0); loopback6.append(1,1); BOOST_CHECK_EQUAL(makeHexDump(rawIPv6), makeHexDump(loopback6)); RecordTextReader rtr2("2a01:4f8:d12:1880::5"); rtr2.xfrIP6(rawIPv6); string ip6("\x2a\x01\x04\xf8\x0d\x12\x18\x80\x00\x00\x00\x00\x00\x00\x00\x05", 16); BOOST_CHECK_EQUAL(makeHexDump(rawIPv6), makeHexDump(ip6)); } BOOST_AUTO_TEST_SUITE_END() pdns-3.3/pdns/zoneparser-tng.hh0000644000014601777760000000344512136555572020047 0ustar00jenkinsnogroup00000000000000/* PowerDNS Versatile Database Driven Nameserver Copyright (C) 2005 - 2007 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PDNS_ZONEPARSER_TNG #define PDNS_ZONEPARSER_TNG #include #include #include #include #include "namespaces.hh" class ZoneParserTNG { public: ZoneParserTNG(const string& fname, const string& zname="", const string& reldir=""); ~ZoneParserTNG(); bool get(DNSResourceRecord& rr); typedef runtime_error exception; typedef deque > parts_t; private: bool getLine(); bool getTemplateLine(); void stackFile(const std::string& fname); unsigned makeTTLFromZone(const std::string& str); string getLineOfFile(); string d_reldir; string d_line; string d_prevqname; string d_zonename; int d_defaultttl; bool d_havedollarttl; uint32_t d_templatecounter, d_templatestop, d_templatestep; string d_templateline; parts_t d_templateparts; struct filestate { filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){} FILE *d_fp; string d_filename; int d_lineno; }; std::stack d_filestates; }; #endif pdns-3.3/pdns/dnswriter.hh0000644000014601777760000001100612144356144017073 0ustar00jenkinsnogroup00000000000000#ifndef PDNS_DNSWRITER_HH #define PDNS_DNSWRITER_HH #include #include #include #if !defined SOLARIS8 && !defined WIN32 #elif defined WIN32 #include "utility.hh" #endif #include "dns.hh" #include "namespaces.hh" /** this class can be used to write DNS packets. It knows about DNS in the sense that it makes the packet header and record headers. The model is: packetheader (recordheader recordcontent)* The packetheader needs to be updated with the amount of packets of each kind (answer, auth, additional) Each recordheader contains the length of a dns record. Calling convention: vector content; DNSPacketWriter dpw(content, const string& qname, uint16_t qtype, uint16_t qclass=1); // sets the question dpw.startrecord("this.is.an.ip.address.", ns_t_a); // does nothing, except store qname and qtype dpw.xfr32BitInt(0x01020304); // adds 4 bytes (0x01020304) to the record buffer dpw.startrecord("this.is.an.ip.address.", ns_t_a); // aha! writes out dnsrecord header containing qname and qtype and length 4, plus the recordbuffer, which gets emptied // new qname and qtype are stored dpw.xfr32BitInt(0x04030201); // adds 4 bytes (0x04030201) to the record buffer dpw.commit(); // writes out dnsrecord header containing qname and qtype and length 4, plus the recordbuffer // content now contains the ready packet, with 1 question and 2 answers */ class DNSPacketWriter : public boost::noncopyable { public: typedef vector > lmap_t; enum Place {ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //! Start a DNS Packet in the vector passed, with question qname, qtype and qclass DNSPacketWriter(vector& content, const string& qname, uint16_t qtype, uint16_t qclass=1, uint8_t opcode=0); /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - ANSWER, AUTHORITY, ADDITIONAL */ void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER); /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */ typedef vector > optvect_t; void addOpt(int udpsize, int extRCode, int Z, const optvect_t& options=optvect_t()); /** needs to be called after the last record is added, but can be called again and again later on. Is called internally by startRecord too. The content of the vector<> passed to the constructor is inconsistent until commit is called. */ void commit(); uint32_t size(); // needs to be 32 bit because otherwise we don't see the wrap coming when it happened! /** Should the packet have grown too big for the writer's liking, rollback removes the record currently being written */ void rollback(); void xfr48BitInt(uint64_t val); void xfr32BitInt(uint32_t val); void xfr16BitInt(uint16_t val); void xfrType(uint16_t val) { xfr16BitInt(val); } void xfrIP(const uint32_t& val) { xfr32BitInt(htonl(val)); } void xfrIP6(const std::string& val) { xfrBlob(val,16); } void xfrTime(const uint32_t& val) { xfr32BitInt(val); } void xfr8BitInt(uint8_t val); void xfrLabel(const string& label, bool compress=false); void xfrText(const string& text, bool multi=false); void xfrBlob(const string& blob, int len=-1); void xfrHexBlob(const string& blob, bool keepReading=false); uint16_t d_pos; dnsheader* getHeader(); void getRecords(string& records); const vector& getRecordBeingWritten() { return d_record; } void setCanonic(bool val) { d_canonic=val; } void setLowercase(bool val) { d_lowerCase=val; } vector & getContent() { return d_content; } private: vector & d_content; vector d_record; string d_qname; uint16_t d_qtype, d_qclass; string d_recordqname; uint16_t d_recordqtype, d_recordqclass; uint32_t d_recordttl; lmap_t d_labelmap; uint16_t d_stuff; uint16_t d_sor; uint16_t d_rollbackmarker; // start of last complete packet, for rollback Place d_recordplace; bool d_canonic, d_lowerCase; }; typedef vector > labelparts_t; bool labeltokUnescape(labelparts_t& parts, const string& label); std::vector segmentDNSText(const string& text); // from dnslabeltext.rl #endif pdns-3.3/contrib/0000755000014601777760000000000012165464053015231 5ustar00jenkinsnogroup00000000000000pdns-3.3/contrib/powerdns.solaris.init.d0000644000014601777760000000560412136555572021666 0ustar00jenkinsnogroup00000000000000#!/bin/sh ################################################################################ # rc script for PowerDNS, Solaris-style | fernando@secret.org # ################################################################################ prefix=/usr/local exec_prefix=${prefix} BINARYPATH=${exec_prefix}/bin SBINARYPATH=${exec_prefix}/sbin SOCKETPATH=/var/run cd $SOCKETPATH suffix=`/bin/basename $0 | /bin/awk -F- '{print $2}'` if [ $suffix ] then EXTRAOPTS=--config-name=$suffix PROGNAME=pdns-$suffix else PROGNAME=$0 fi pdns_server="$SBINARYPATH/pdns_server $EXTRAOPTS" doPC() { ret=`$BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null` } doPC ping NOTRUNNING=$? case "$1" in status) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then doPC status /bin/echo $ret else /bin/echo "not running" fi ;; stop) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then doPC quit /bin/echo $ret else /bin/echo "not running" fi ;; force-stop) /bin/echo "$PROGNAME: \c" /bin/pkill -v -9 pdns_server /bin/echo "force-stopped" ;; start) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then /bin/echo "already running" else $pdns_server --daemon --guardian=yes if test "$?" = "0" then /bin/echo "started" fi fi ;; force-reload | restart) /bin/echo "$PROGNAME: \c" /bin/echo "stopping and waiting\c" doPC quit sleep 3 /bin/echo $0 start ;; reload) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then doPC cycle /bin/echo requested reload else /bin/echo not running yet $0 start fi ;; monitor) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then /bin/echo "already running" else $pdns_server --daemon=no --guardian=no --control-console --loglevel=9 fi ;; dump) /bin/echo "$PROGNAME: \c" if test "$NOTRUNNING" = "0" then doPC list /bin/echo $ret else /bin/echo "not running" fi ;; show) /bin/echo "$PROGNAME: \c" if [ $# -lt 2 ] then /bin/echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then /bin/echo -n "$2=" doPC show $2 ; /bin/echo $ret else /bin/echo "not running" fi ;; mrtg) if [ $# -lt 2 ] then /bin/echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then doPC show $2 ; /bin/echo $ret if [ "$3x" != "x" ] then doPC show $3 ; /bin/echo $ret else /bin/echo 0 fi doPC uptime ; /bin/echo $ret /bin/echo PowerDNS daemon else /bin/echo "not running" fi ;; cricket) if [ $# -lt 2 ] then /bin/echo Insufficient parameters exit fi if test "$NOTRUNNING" = "0" then doPC show $2 ; /bin/echo $ret else /bin/echo "not running" fi ;; *) /bin/echo "Usage: $0 { start | stop | force-reload | restart | status | dump | show | mrtg | cricket | monitor }" exit 1 ;; esac exit 0 pdns-3.3/contrib/systemd-pdns-recursor.service0000644000014601777760000000027712136555572023122 0ustar00jenkinsnogroup00000000000000[Unit] Description=PowerDNS recursing nameserver After=network.target [Service] Type=forking ExecStart=/usr/sbin/pdns_recursor --daemon PrivateTmp=true [Install] WantedBy=multi-user.target pdns-3.3/contrib/systemd-pdns.service0000644000014601777760000000046112155275020021237 0ustar00jenkinsnogroup00000000000000[Unit] Description=PowerDNS Authoritative Server After=network.target mysqld.service postgresql.service slapd.service [Service] Type=forking ExecStart=/usr/sbin/pdns_server --daemon ExecStop=/usr/bin/pdns_control quit Restart=on-failure RestartSec=2 PrivateTmp=true [Install] WantedBy=multi-user.target pdns-3.3/build-scripts/0000755000014601777760000000000012165464053016355 5ustar00jenkinsnogroup00000000000000pdns-3.3/build-scripts/semistaticg++0000755000014601777760000000072712136555572020760 0ustar00jenkinsnogroup00000000000000#!/usr/bin/env python import sys,os args = sys.argv[1:] if '-static' not in args: os.execvp('g++', ['g++']+args) libs = [] otherargs = [] for arg in args: if arg == '-static': continue if arg.startswith('/usr/lib') or (arg.startswith('-l') and arg not in ('-lm','-ldl','-lpthread')): libs.append(arg) else: otherargs.append(arg) gargv=['gcc']+otherargs+['-Wl,-Bstatic']+libs+['-lstdc++','-Wl,-Bdynamic','-static-libgcc','-lm','-ldl'] os.execvp('gcc', gargv) pdns-3.3/ltmain.sh0000755000014601777760000073337712165464021015433 0ustar00jenkinsnogroup00000000000000# Generated from ltmain.m4sh. # ltmain.sh (GNU libtool) 2.2.6b # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print informational messages (default) # --version print version information # -h, --help print short or long help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.2.6b Debian-2.2.6b-2 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . PROGRAM=ltmain.sh PACKAGE=libtool VERSION="2.2.6b Debian-2.2.6b-2" TIMESTAMP="" package_revision=1.3017 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # NLS nuisances: We save the old values to restore during execute mode. # Only set LANG and LC_ALL to C if already set. # These must not be set unconditionally because not all systems understand # e.g. LANG=C (notably SCO). lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done $lt_unset CDPATH : ${CP="cp -f"} : ${ECHO="echo"} : ${EGREP="/bin/grep -E"} : ${FGREP="/bin/grep -F"} : ${GREP="/bin/grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } # Generated shell functions inserted here. # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" # The name of this program: # In the unlikely event $progname began with a '-', it would play havoc with # func_echo (imagine progname=-n), so we prepend ./ in that case: func_dirname_and_basename "$progpath" progname=$func_basename_result case $progname in -*) progname=./$progname ;; esac # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname${mode+: }$mode: $*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` done my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "X$my_tmpdir" | $Xsed } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "X$1" | $Xsed \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_version # Echo version message to standard output and exit. func_version () { $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $SED -n '/^# Usage:/,/# -h/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" $ECHO $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help # Echo long help message to standard output and exit. func_help () { $SED -n '/^# Usage:/,/# Report bugs to/ { s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p }' < "$progpath" exit $? } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { func_error "missing argument for $1" exit_cmd=exit } exit_cmd=: # Check that we have a working $ECHO. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then # Yippee, $ECHO works! : else # Restart under the correct shell, and then maybe $ECHO will work. exec $SHELL "$progpath" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat </dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # Parse options once, thoroughly. This comes as soon as possible in # the script to make things like `libtool --version' happen quickly. { # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Parse non-mode specific arguments: while test "$#" -gt 0; do opt="$1" shift case $opt in --config) func_config ;; --debug) preserve_args="$preserve_args $opt" func_echo "enabling shell trace mode" opt_debug='set -x' $opt_debug ;; -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break execute_dlfiles="$execute_dlfiles $1" shift ;; --dry-run | -n) opt_dry_run=: ;; --features) func_features ;; --finish) mode="finish" ;; --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break case $1 in # Valid mode arguments: clean) ;; compile) ;; execute) ;; finish) ;; install) ;; link) ;; relink) ;; uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac mode="$1" shift ;; --preserve-dup-deps) opt_duplicate_deps=: ;; --quiet|--silent) preserve_args="$preserve_args $opt" opt_silent=: ;; --verbose| -v) preserve_args="$preserve_args $opt" opt_silent=false ;; --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break preserve_args="$preserve_args $opt $1" func_enable_tag "$1" # tagname is set here shift ;; # Separate optargs to long options: -dlopen=*|--mode=*|--tag=*) func_opt_split "$opt" set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} shift ;; -\?|-h) func_usage ;; --help) opt_help=: ;; --version) func_version ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) nonopt="$opt" break ;; esac done case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_duplicate_deps ;; esac # Having warned about all mis-specified options, bail out if # anything was wrong. $exit_cmd $EXIT_FAILURE } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } ## ----------- ## ## Main. ## ## ----------- ## $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi test -z "$mode" && func_fatal_error "error: you must specify a MODE." # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$mode' for more information." } # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_ltwrapper_scriptname_result="" if func_ltwrapper_executable_p "$1"; then func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" fi } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_quote_for_eval "$arg" CC_quoted="$CC_quoted $func_quote_for_eval_result" done case "$@ " in " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T <?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi removelist="$removelist $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist removelist="$removelist $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir command="$command -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$mode'" ;; esac $ECHO $ECHO "Try \`$progname --help' for more information about other modes." exit $? } # Now that we've collected a possible --mode arg, show help if necessary $opt_help && func_mode_help # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $execute_dlfiles; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_quote_for_eval "$file" args="$args $func_quote_for_eval_result" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" $ECHO "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS $ECHO "X----------------------------------------------------------------------" | $Xsed $ECHO "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done $ECHO $ECHO "If you ever happen to want to link against installed libraries" $ECHO "in a given directory, LIBDIR, you must either use libtool, and" $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" $ECHO "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" $ECHO " during execution" fi if test -n "$runpath_var"; then $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" $ECHO " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi $ECHO $ECHO "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" $ECHO "pages." ;; *) $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac $ECHO "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS } test "$mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $ECHO "X$nonopt" | $GREP shtool >/dev/null; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" install_prog="$install_prog$func_quote_for_eval_result" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) case " $install_prog " in *[\\\ /]cp\ *) ;; *) prev=$arg ;; esac ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" install_prog="$install_prog $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for progfile in $progfiles; do func_verbose "extracting global C symbols from \`$progfile'" $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" } done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" fi $ECHO >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; " case $host in *cygwin* | *mingw* | *cegcc* ) $ECHO >> "$output_objdir/$my_dlsyms" "\ /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */" lt_dlsym_const= ;; *osf5*) echo >> "$output_objdir/$my_dlsyms" "\ /* This system does not cope well with relocations in const data */" lt_dlsym_const= ;; *) lt_dlsym_const=const ;; esac $ECHO >> "$output_objdir/$my_dlsyms" "\ extern $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac $ECHO >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) symtab_cflags="$symtab_cflags $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper_part1 [arg=no] # # Emit the first part of a libtool wrapper script on stdout. # For more information, see the description associated with # func_emit_wrapper(), below. func_emit_wrapper_part1 () { func_emit_wrapper_part1_arg1=no if test -n "$1" ; then func_emit_wrapper_part1_arg1=$1 fi $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='${SED} -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then ECHO=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then # Yippee, \$ECHO works! : else # Restart under the correct shell, and then maybe \$ECHO will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $ECHO "\ # Find the directory that this script lives in. thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done " } # end: func_emit_wrapper_part1 # func_emit_wrapper_part2 [arg=no] # # Emit the second part of a libtool wrapper script on stdout. # For more information, see the description associated with # func_emit_wrapper(), below. func_emit_wrapper_part2 () { func_emit_wrapper_part2_arg1=no if test -n "$1" ; then func_emit_wrapper_part2_arg1=$1 fi $ECHO "\ # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # end: func_emit_wrapper_part2 # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=no if test -n "$1" ; then func_emit_wrapper_arg1=$1 fi # split this up so that func_emit_cwrapperexe_src # can call each part independently. func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" } # func_to_host_path arg # # Convert paths to host format when used with build tools. # Intended for use with "native" mingw (where libtool itself # is running under the msys shell), or in the following cross- # build environments: # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # where wine is equipped with the `winepath' executable. # In the native mingw case, the (msys) shell automatically # converts paths for any non-msys applications it launches, # but that facility isn't available from inside the cwrapper. # Similar accommodations are necessary for $host mingw and # $build cygwin. Calling this function does no harm for other # $host/$build combinations not listed above. # # ARG is the path (on $build) that should be converted to # the proper representation for $host. The result is stored # in $func_to_host_path_result. func_to_host_path () { func_to_host_path_result="$1" if test -n "$1" ; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' case $build in *mingw* ) # actually, msys # awkward: cmd appends spaces to result lt_sed_strip_trailing_spaces="s/[ ]*\$//" func_to_host_path_tmp1=`( cmd //c echo "$1" |\ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_path_tmp1=`cygpath -w "$1"` func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` ;; * ) # Unfortunately, winepath does not exit with a non-zero # error code, so we are forced to check the contents of # stdout. On the other hand, if the command is not # found, the shell will set an exit code of 127 and print # *an error message* to stdout. So we must check for both # error code of zero AND non-empty stdout, which explains # the odd construction: func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ $SED -e "$lt_sed_naive_backslashify"` else # Allow warning below. func_to_host_path_result="" fi ;; esac if test -z "$func_to_host_path_result" ; then func_error "Could not determine host path corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_path_result="$1" fi ;; esac fi } # end: func_to_host_path # func_to_host_pathlist arg # # Convert pathlists to host format when used with build tools. # See func_to_host_path(), above. This function supports the # following $build/$host combinations (but does no harm for # combinations not listed here): # $build $host # mingw (msys) mingw [e.g. native] # cygwin mingw # *nix + wine mingw # # Path separators are also converted from $build format to # $host format. If ARG begins or ends with a path separator # character, it is preserved (but converted to $host format) # on output. # # ARG is a pathlist (on $build) that should be converted to # the proper representation on $host. The result is stored # in $func_to_host_pathlist_result. func_to_host_pathlist () { func_to_host_pathlist_result="$1" if test -n "$1" ; then case $host in *mingw* ) lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_to_host_pathlist_tmp2="$1" # Once set for this call, this variable should not be # reassigned. It is used in tha fallback case. func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e 's|^:*||' -e 's|:*$||'` case $build in *mingw* ) # Actually, msys. # Awkward: cmd appends spaces to result. lt_sed_strip_trailing_spaces="s/[ ]*\$//" func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e "$lt_sed_naive_backslashify"` ;; *cygwin* ) func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ $SED -e "$lt_sed_naive_backslashify"` ;; * ) # unfortunately, winepath doesn't convert pathlists func_to_host_pathlist_result="" func_to_host_pathlist_oldIFS=$IFS IFS=: for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do IFS=$func_to_host_pathlist_oldIFS if test -n "$func_to_host_pathlist_f" ; then func_to_host_path "$func_to_host_pathlist_f" if test -n "$func_to_host_path_result" ; then if test -z "$func_to_host_pathlist_result" ; then func_to_host_pathlist_result="$func_to_host_path_result" else func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" fi fi fi IFS=: done IFS=$func_to_host_pathlist_oldIFS ;; esac if test -z "$func_to_host_pathlist_result" ; then func_error "Could not determine the host path(s) corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This may break if $1 contains DOS-style drive # specifications. The fix is not to complicate the expression # below, but for the user to provide a working wine installation # with winepath so that path translation in the cross-to-mingw # case works properly. lt_replace_pathsep_nix_to_dos="s|:|;|g" func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ $SED -e "$lt_replace_pathsep_nix_to_dos"` fi # Now, add the leading and trailing path separators back case "$1" in :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" ;; esac case "$1" in *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" ;; esac ;; esac fi } # end: func_to_host_pathlist # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include # define setmode _setmode #else # include # include # ifdef __CYGWIN__ # include # define HAVE_SETENV # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif # endif #endif #include #include #include #include #include #include #include #include #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif #ifdef _MSC_VER # define S_IXUSR _S_IEXEC # define stat _stat # ifndef _INTPTR_T_DEFINED # define intptr_t int # endif #endif #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifdef __CYGWIN__ # define FOPEN_WB "wb" #endif #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #undef LTWRAPPER_DEBUGPRINTF #if defined DEBUGWRAPPER # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args static void ltwrapper_debugprintf (const char *fmt, ...) { va_list args; va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } #else # define LTWRAPPER_DEBUGPRINTF(args) #endif const char *program_name = NULL; void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_fatal (const char *message, ...); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_opt_process_env_set (const char *arg); void lt_opt_process_env_prepend (const char *arg); void lt_opt_process_env_append (const char *arg); int lt_split_name_value (const char *arg, char** name, char** value); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); static const char *script_text_part1 = EOF func_emit_wrapper_part1 yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ "/' -e 's/$/\\n"/' echo ";" cat <"))); for (i = 0; i < newargc; i++) { LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); } EOF case $host_os in mingw*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); if (rval == -1) { /* failed to start process */ LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); return 127; } return rval; EOF ;; *) cat <<"EOF" execv (lt_argv_zero, newargz); return rval; /* =127, but avoids unused variable warning */ EOF ;; esac cat <<"EOF" } void * xmalloc (size_t num) { void *p = (void *) malloc (num); if (!p) lt_fatal ("Memory exhausted"); return p; } char * xstrdup (const char *string) { return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL; } const char * base_name (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ if (isalpha ((unsigned char) name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) if (IS_DIR_SEPARATOR (*name)) base = name + 1; return base; } int check_executable (const char *path) { struct stat st; LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!")); if ((!path) || (!*path)) return 0; if ((stat (path, &st) >= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!")); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", tmp_pathspec)); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { char *errstr = strerror (errno); lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal ("Could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } static void lt_error_core (int exit_status, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } void lt_setenv (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", (name ? name : ""), (value ? value : ""))); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } int lt_split_name_value (const char *arg, char** name, char** value) { const char *p; int len; if (!arg || !*arg) return 1; p = strchr (arg, (int)'='); if (!p) return 1; *value = xstrdup (++p); len = strlen (arg) - strlen (*value); *name = XMALLOC (char, len); strncpy (*name, arg, len-1); (*name)[len - 1] = '\0'; return 0; } void lt_opt_process_env_set (const char *arg) { char *name = NULL; char *value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); } lt_setenv (name, value); XFREE (name); XFREE (value); } void lt_opt_process_env_prepend (const char *arg) { char *name = NULL; char *value = NULL; char *new_value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); } new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); XFREE (name); XFREE (value); } void lt_opt_process_env_append (const char *arg) { char *name = NULL; char *value = NULL; char *new_value = NULL; if (lt_split_name_value (arg, &name, &value) != 0) { XFREE (name); XFREE (value); lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); } new_value = lt_extend_str (getenv (name), value, 1); lt_setenv (name, new_value); XFREE (new_value); XFREE (name); XFREE (value); } void lt_update_exe_path (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", (name ? name : ""), (value ? value : ""))); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", (name ? name : ""), (value ? value : ""))); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF } # end: func_emit_cwrapperexe_src # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) deplibs="$deplibs $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) weak_libs="$weak_libs $arg" prev= continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname '-L' '' "$arg" dir=$func_stripname_result if test -z "$dir"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework deplibs="$deplibs System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot) compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" arg="$arg $wl$func_quote_for_eval_result" compiler_flags="$compiler_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" arg="$arg $wl$func_quote_for_eval_result" compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" linker_flags="$linker_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # -64, -mips[0-9] enable 64-bit mode on the SGI compiler # -r[0-9][0-9]* specifies the processor on the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler # +DA*, +DD* enable 64-bit mode on the HP compiler # -q* pass through compiler args for the IBM compiler # -m*, -t[45]*, -txscale* pass through architecture-specific # compiler args for GCC # -F/path gives path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" compiler_flags="$compiler_flags $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. objs="$objs $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_duplicate_deps ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$pre_post_deps $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= case $lib in *.la) func_source "$lib" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` case " $weak_libs " in *" $deplib_base "*) ;; *) deplibs="$deplibs $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" dir=$func_stripname_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then $ECHO $ECHO "*** Warning: Trying to link with static lib archive $deplib." $ECHO "*** I have the capability to make that library automatically link in when" $ECHO "*** you link to this library. But I can only do this if you have a" $ECHO "*** shared version of the library, which you do not appear to have" $ECHO "*** because the file extensions .$libext of this argument makes me believe" $ECHO "*** that it is just a static archive that I should not use here." else $ECHO $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" newlib_search_path="$newlib_search_path $func_stripname_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) temp_rpath="$temp_rpath$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded notinst_deplibs="$notinst_deplibs $lib" need_relink=no ;; *) if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then $ECHO if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then $ECHO $ECHO "*** And there doesn't seem to be a static archive available" $ECHO "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. $ECHO $ECHO "*** Warning: This system can not link to static lib archive $lib." $ECHO "*** I have the capability to make that library automatically link in when" $ECHO "*** you link to this library. But I can only do this if you have a" $ECHO "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then $ECHO "*** But as you try to build a module library, libtool will still create " $ECHO "*** a static module, that should work as long as the dlopening application" $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then $ECHO $ECHO "*** However, this would only work if libtool was able to extract symbol" $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" $ECHO "*** not find such a program. So, this module is probably useless." $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if $opt_duplicate_deps ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_dirname "$deplib" "" "." dir="$func_dirname_result" # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else $ECHO $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" libobjs="$libobjs $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi removelist="$removelist $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $ECHO $ECHO "*** Warning: linker path does not have real file for library $a_deplib." $ECHO "*** I have the capability to make that library automatically link in when" $ECHO "*** you link to this library. But I can only do this if you have a" $ECHO "*** shared version of the library, which you do not appear to have" $ECHO "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $ECHO $ECHO "*** Warning: linker path does not have real file for library $a_deplib." $ECHO "*** I have the capability to make that library automatically link in when" $ECHO "*** you link to this library. But I can only do this if you have a" $ECHO "*** shared version of the library, which you do not appear to have" $ECHO "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` done fi if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | $GREP . >/dev/null; then $ECHO if test "X$deplibs_check_method" = "Xnone"; then $ECHO "*** Warning: inter-library dependencies are not supported in this platform." else $ECHO "*** Warning: inter-library dependencies are not known to be supported." fi $ECHO "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then $ECHO $ECHO "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" $ECHO "*** a static module, that should work as long as the dlopening" $ECHO "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then $ECHO $ECHO "*** However, this would only work if libtool was able to extract symbol" $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" $ECHO "*** not find such a program. So, this module is probably useless." $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else $ECHO "*** The inter-library dependencies that have been dropped here will be" $ECHO "*** automatically added whenever a program is linked with this library" $ECHO "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then $ECHO $ECHO "*** Since this library must not contain undefined symbols," $ECHO "*** because either the platform does not support them or" $ECHO "*** it was explicitly requested with -no-undefined," $ECHO "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" delfiles="$delfiles $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" func_len " $cmd" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then func_show_eval "$cmd" 'exit $?' skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output output_la=`$ECHO "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" $ECHO 'INPUT (' > $output for obj in $save_libobjs do $ECHO "$obj" >> $output done $ECHO ')' >> $output delfiles="$delfiles $output" elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do $ECHO "$obj" >> $output done delfiles="$delfiles $output" output=$firstobj\"$file_list_spec$output\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=$obj func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi delfiles="$delfiles $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *cegcc) # Disable wrappers for cegcc, we are cross compiling anyway. wrappers_required=no ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi # Quote $ECHO for shipping. if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then case $progpath in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; esac qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then oldobjs="$oldobjs $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $dlprefiles oldobjs="$oldobjs $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else $ECHO "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" newdlfiles="$newdlfiles $libdir/$name" ;; *) newdlfiles="$newdlfiles $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" newdlprefiles="$newdlprefiles $libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$mode" = link || test "$mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) RM="$RM $arg"; rmforce=yes ;; -*) RM="$RM $arg" ;; *) files="$files $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= origobjdir="$objdir" for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then objdir="$origobjdir" else objdir="$dir/$origobjdir" fi func_basename "$file" name="$func_basename_result" test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result rmfiles="$rmfiles $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$mode" = uninstall || test "$mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 pdns-3.3/ylwrap0000755000014601777760000001404312165464026015037 0ustar00jenkinsnogroup00000000000000#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, # 2007, 2009 Free Software Foundation, Inc. # # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case "$1" in '') echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # We do not want to overwrite a header file if it hasn't # changed. This avoid useless recompilations. However the # parser itself (the first file) should always be updated, # because it is the destination of the .y.c rule in the # Makefile. Divert the output of all other files to a temporary # file so we can compare them to existing versions. if test $first = no; then realtarget="$target" target="tmp-`echo $target | sed s/.*[\\/]//g`" fi # Edit out `#line' or `#' directives. # # We don't want the resulting debug information to point at # an absolute srcdir; it is better for it to just mention the # .y file with no path. # # We want to use the real output file name, not yy.lex.c for # instance. # # We want the include guards to be adjusted too. FROM=`echo "$from" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` TARGET=`echo "$2" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? # Check whether header files must be updated. if test $first = no; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$2" is unchanged rm -f "$target" else echo updating "$2" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then ret=1 fi fi shift shift first=no done else ret=$? fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pdns-3.3/Makefile.am0000644000014601777760000000211512162630475015624 0ustar00jenkinsnogroup00000000000000SUBDIRS=modules codedocs @programdescend@ DIST_SUBDIRS=modules codedocs pdns pdns/ext/rapidjson EXTRA_DIST=TODO README HACKING INSTALL debian-pdns/* pdns.spec \ codedocs/Makefile codedocs/doxygen.conf contrib/powerdns.solaris.init.d \ contrib/systemd-pdns.service contrib/systemd-pdns-recursor.service \ bootstrap build-scripts/semistaticg++ pdns/docs/dnstcpbench.1 ACLOCAL_AMFLAGS = -I m4 man8_MANS=pdns/docs/pdns_control.8 pdns/docs/pdnssec.8 pdns/docs/pdns_server.8 \ pdns/docs/zone2ldap.8 pdns/docs/zone2sql.8 if TOOLS man8_MANS += pdns/docs/dnsreplay.8 pdns/docs/dnsscope.8 pdns/docs/dnswasher.8 man1_MANS = pdns/docs/dnstcpbench.1 endif pdns/docs/dnstcpbench.1: cd pdns/docs && $(MAKE) dnstcpbench.1 install-exec-local: -@chmod +x pdns/pdns -@chmod +x pdns/precursor @echo "***********************************************************" @echo @echo init.d startup scripts have been made for you in pdns/pdns @echo and in pdns/precursor @echo You may want to copy these to /etc/init.d or equivalent @echo @echo "***********************************************************" pdns-3.3/configure.ac0000644000014601777760000005722212165464014016064 0ustar00jenkinsnogroup00000000000000dnl intro dnl The following lines may be patched by set-version-auth. AC_INIT([pdns], [3.3]) AC_SUBST([DIST_HOST], [jenkins@autotest.powerdns.com]) dnl End patch area. AC_CONFIG_SRCDIR([pdns/receiver.cc]) AM_INIT_AUTOMAKE([foreign tar-ustar -Wno-portability]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CANONICAL_HOST LT_INIT AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AC_C_BIGENDIAN AC_PREREQ(2.52) : ${CXXFLAGS="-Wall -O2"} AC_PREFIX_DEFAULT(/usr/local) AC_PROG_CC AC_PROG_CXX AM_PROG_CC_C_O AC_PROG_YACC AM_PROG_LEX AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LIBTOOL AC_LANG_CPLUSPLUS dnl Check for lua AC_MSG_CHECKING(if with lua) AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[use Lua]), [WITH_LUA=$withval],[WITH_LUA=yes]) AC_MSG_RESULT($WITH_LUA) if test "$WITH_LUA" != "no"; then # try pkgconfig if test "$WITH_LUA" = "yes"; then LUAPC=lua else LUAPC=$WITH_LUA fi PKG_CHECK_MODULES(LUA, $LUAPC >= 5.1, [ AC_DEFINE([HAVE_LUA], [1], [liblua]) AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) ],[ PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [ AC_DEFINE([HAVE_LUA], [1], [liblua]) AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) ],[ PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [ AC_DEFINE([HAVE_LUA], [1], [liblua]) AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) ]) ]) ]) AC_SUBST(LUA_CFLAGS) AC_SUBST(LUA_LIBS) fi AM_CONDITIONAL([RELEASE_BUILD], [test "$PACKAGE_VERSION" != "git"]) BOOST_REQUIRE([1.35]) BOOST_FOREACH BOOST_PROGRAM_OPTIONS([mt]) BOOST_SERIALIZATION([mt]) AC_ARG_ENABLE(unit-tests, AC_HELP_STRING([--enable-unit-tests],[enable unit test building]), [enable_unit_tests=yes],[enable_unit_tests=no]) if test x"$enable_unit_tests" = "xyes"; then BOOST_TEST([mt]) fi #BOOST_SYSTEM([mt]) # detect pkg-config explicitly PKG_PROG_PKG_CONFIG dnl Allow user to require SQLite3 AC_MSG_CHECKING(whether user requires sqlite3) AC_ARG_WITH(sqlite3, AC_HELP_STRING([--with-sqlite3],[include sqlite3 driver]), [WITH_SQLITE3=$withval],[WITH_SQLITE3=no]) AC_MSG_RESULT($WITH_SQLITE3) SQLITE3PC=sqlite3 if test "$WITH_SQLITE3" != "no"; then needsqlite3=yes if test "$WITH_SQLITE3" != "yes"; then SQLITE3PC=$WITH_SQLITE3 fi fi dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h getopt.h limits.h strings.h sys/time.h syslog.h unistd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM dnl Checks for library functions. AC_TYPE_SIGNAL AC_CHECK_FUNCS(gethostname gettimeofday mkdir mktime select socket strerror strcasestr) # Check for libdl LIBS="$LIBS -lz" my_save_LIBS="$LIBS" LIBS="" AC_CHECK_LIB(dl,dlopen) LIBDL=$LIBS LIBS="$my_save_LIBS" AC_SUBST(LIBDL) AC_MSG_CHECKING([for RTLD_NOW]); ac_save_LIBS="$LIBS" LIBS="$LIBS $LIBDL" AC_TRY_LINK( [#include ], [ (void) dlopen("",RTLD_NOW); ], has_RTLD_NOW=yes, has_RTLD_NOW=no) AC_MSG_RESULT([$has_RTLD_NOW]) if test "$has_RTLD_NOW" = "no" then AC_DEFINE(NEED_RTLD_NOW,,[If host OS misses RTLD_NOW]) fi LIBS=$ac_save_LIBS # Check for libcrypt my_save_LIBS="$LIBS" LIBS="" AC_CHECK_LIB(crypt, crypt) LIBCRYPT=$LIBS LIBS="$my_save_LIBS" AC_SUBST(LIBCRYPT) DYNLINKFLAGS="" THREADFLAGS="" AM_CONDITIONAL([OS_MACOSX], false) case "$host_os" in solaris2.10) AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread -lrt $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; solaris2.8 | solaris2.9 ) AC_DEFINE(NEED_POSIX_TYPEDEF,,[If POSIX typedefs need to be defined]) AC_DEFINE(NEED_INET_NTOP_PROTO,,[If your OS is so broken that it needs an additional prototype]) AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; solaris2.6 | solaris2.7) AC_DEFINE(NEED_POSIX_TYPEDEF,,[If POSIX typedefs need to be defined]) AC_DEFINE(NEED_INET_NTOP_PROTO,,[If your OS is so broken that it needs an additional prototype]) LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; linux*) AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) DYNLINKFLAGS="-rdynamic" LDFLAGS="$LDFLAGS -lrt" THREADFLAGS="-pthread" CXXFLAGS="-D_GNU_SOURCE $CXXFLAGS" ;; darwin11* | darwin12*) AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) DYNLINKFLAGS="-rdynamic" LDFLAGS="-pthread $LDFLAGS" CXXFLAGS="-pthread $CXXFLAGS -D__APPLE_USE_RFC_3542" AM_CONDITIONAL([OS_MACOSX], true) ;; *) AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) DYNLINKFLAGS="-rdynamic" LDFLAGS="-pthread $LDFLAGS" CXXFLAGS="-pthread $CXXFLAGS" ;; esac AC_SUBST(THREADFLAGS) AC_SUBST(DYNLINKFLAGS) AC_MSG_CHECKING(whether we will be doing verbose logging) AC_ARG_ENABLE(verbose-logging, AC_HELP_STRING([--enable-verbose-logging],[do verbose logging]), [enable_verbose_logging=yes], [enable_verbose_logging=no]) if test $enable_verbose_logging = yes; then AC_DEFINE(VERBOSELOG, 1, [If verbose logging should be enabled]) fi AC_MSG_RESULT($enable_verbose_logging) AC_MSG_CHECKING(whether we will try to link in system PolarSSL) AC_ARG_WITH([system-polarssl], [AC_HELP_STRING([--without-system-polarssl], [do not use system PolarSSL])], [system_polarssl=$withval], [system_polarssl=yes]) AC_MSG_RESULT($system_polarssl) AM_CONDITIONAL(HAVE_LIBPOLARSSL, false) if test x$system_polarssl = xyes; then AC_MSG_CHECKING([PolarSSL version >= 1.1]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #include ]], [[ #if POLARSSL_VERSION_NUMBER < 0x01010000 #error invalid version #endif ]] )], [use_system_polarssl=yes], [use_system_polarssl=no]) AC_MSG_RESULT($use_system_polarssl) fi if test x$use_system_polarssl = xyes; then AC_CHECK_LIB([polarssl], [sha1_hmac]) fi AC_MSG_CHECKING(whether we will be linking in Botan 1.10) AC_ARG_ENABLE(botan1.10, AC_HELP_STRING([--enable-botan1.10],[use Botan 1.10]), [enable_botan110=yes], [enable_botan110=no]) AC_MSG_RESULT($enable_botan110) AM_CONDITIONAL(BOTAN110,test x"$enable_botan110" = "xyes") AC_MSG_CHECKING(whether we will be linking in Botan 1.8) AC_ARG_ENABLE(botan1.8, AC_HELP_STRING([--enable-botan1.8],[use Botan 1.8]), [enable_botan18=yes], [enable_botan18=no]) AC_MSG_RESULT($enable_botan18) AM_CONDITIONAL(BOTAN18,test x"$enable_botan18" = "xyes") AC_MSG_CHECKING(whether we will be linking in Crypto++) AC_ARG_ENABLE(cryptopp, AC_HELP_STRING([--enable-cryptopp],[use Crypto++]), [enable_cryptopp=yes], [enable_cryptopp=no]) AC_MSG_RESULT($enable_cryptopp) AM_CONDITIONAL(CRYPTOPP,test x"$enable_cryptopp" = "xyes") if test "x$enable_botan110" = "xyes" then PKG_CHECK_MODULES(BOTAN110, botan-1.10, HAVE_BOTAN110=yes, AC_MSG_ERROR([Could not find botan 1.10])) AC_SUBST(BOTAN110_LIBS) AC_SUBST(BOTAN110_CFLAGS) AC_DEFINE(HAVE_BOTAN110,1,[If we have botan 1.10]) fi if test "x$enable_botan18" = "xyes" then PKG_CHECK_MODULES(BOTAN18, botan-1.8, HAVE_BOTAN18=yes, AC_MSG_ERROR([Could not find botan 1.8])) AC_SUBST(BOTAN18_LIBS) AC_SUBST(BOTAN18_CFLAGS) AC_DEFINE(HAVE_BOTAN18,1,[If we have botan 1.8]) fi AC_ARG_ENABLE(remotebackend_http, AC_HELP_STRING([--enable-remotebackend-http],[enable HTTP connector for remotebackend]),[enable_remotebackend_http=yes], [enable_remotebackend_http=no]) AC_MSG_CHECKING(whether to enable http connector in remotebackend) AC_MSG_RESULT($enable_remotebackend_http) AM_CONDITIONAL(REMOTEBACKEND_HTTP,test x"$enable_remotebackend_http" = "xyes") if test "x$enable_remotebackend_http" = "xyes" then PKG_CHECK_MODULES(LIBCURL, libcurl, HAVE_LIBCURL=yes, AC_MSG_ERROR([Could not find libcurl])) REMOTEBACKEND_HTTP=yes AC_SUBST(LIBCURL_LIBS) AC_SUBST(LIBCURL_CFLAGS) AC_DEFINE(HAVE_LIBCURL,1,[If we have libcurl]) AC_DEFINE(REMOTEBACKEND_HTTP,1,[If we want HTTP connector]) AC_SUBST(REMOTEBACKEND_HTTP) fi AC_MSG_CHECKING(whether we should build static binaries) AC_ARG_ENABLE(static-binaries, AC_HELP_STRING([--enable-static-binaries],[Build static binaries]), [case "${enableval}" in yes) static=true ;; no) static=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-static-binaries) ;; esac],[debug=false]) AC_MSG_RESULT($static) AM_CONDITIONAL(ALLSTATIC, test x$static = xtrue) if test x$static = xtrue; then LDFLAGS="-all-static $LDFLAGS" fi modules="gmysql geo random" AC_ARG_WITH(modules, AC_HELP_STRING([--with-modules],[which backends to compile with]), [ modules="$withval" ]) dynmodules="pipe" AC_ARG_WITH(dynmodules, AC_HELP_STRING([--with-dynmodules],[which backends to build for dynamic loading]), [ dynmodules="$withval" ]) AC_SUBST(socketdir) socketdir="/var/run" AC_ARG_WITH(socketdir, AC_HELP_STRING([--with-socketdir],[where the controlsocket lives]), [ socketdir="$withval" ]) AC_SUBST(moduledirs) AC_SUBST(moduleobjects) AC_SUBST(modulelibs) AC_MSG_CHECKING(whether we will be building the server) AC_ARG_ENABLE(pdns-server, AC_HELP_STRING([--enable-pdns_server],[if we should build the server]), [enable_pdns_server=$enableval], [enable_pdns_server=yes]) AC_MSG_RESULT($enable_pdns_server) if test x"$enable_pdns_server" = "xyes" then programdescend=pdns fi AC_SUBST(programdescend) AC_ARG_ENABLE(gcc-skip-locking, AC_HELP_STRING([--enable-gcc-skip-locking],[if we should forcefully skip gcc locking]), AC_DEFINE(GCC_SKIP_LOCKING,,[Skip gcc locking]), ) AC_MSG_CHECKING(whether we will be building and installing the extra tools) AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools],[if we should build+install the tools]), enable_tools=$enableval, enable_tools=no ) AC_MSG_RESULT($enable_tools) AM_CONDITIONAL(TOOLS,test x"$enable_tools" = "xyes") for a in $modules $dynmodules do case "$a" in oracle|goracle) needoracle=yes ;; gmysql ) needmysql=yes ;; mydns ) needmysql=yes ;; gpgsql ) needpgsql=yes ;; gsqlite3 ) needsqlite3=yes ;; pdns ) needmysql=yes ;; ldap) AC_CHECK_HEADERS([ldap.h], , [AC_MSG_ERROR([ldap header (ldap.h) not found])]) AC_CHECK_HEADERS([lber.h], , [AC_MSG_ERROR([ldap header (lber.h) not found])]) AC_SUBST([LIBLDAP]) AC_CHECK_LIB( [ldap_r], [ldap_set_option], [AC_DEFINE([HAVE_LIBLDAP_R], 1, [Have -lldap_r]) LIBLDAP="ldap_r"], [AC_CHECK_LIB( [ldap], [ldap_set_option], [AC_DEFINE([HAVE_LIBLDAP], 1, [Have -lldap]) LIBLDAP="ldap"], [AC_MSG_ERROR([ldap library (libldap) not found])] )] ) AC_CHECK_LIB( [$LIBLDAP], [ldap_initialize], [AC_DEFINE([HAVE_LDAP_INITIALIZE], 1, [Define to 1 if you have ldap_initialize])] ) AC_CHECK_LIB( [$LIBLDAP], [ldap_sasl_bind], [AC_DEFINE([HAVE_LDAP_SASL_BIND], 1, [Define to 1 if you have ldap_sasl_bind])] ) ;; godbc ) needunixodbc=yes ;; opendbx) AC_CHECK_HEADERS([odbx.h], , [AC_MSG_ERROR([opendbx header (odbx.h) not found])]) AC_SUBST([LIBOPENDBX]) AC_CHECK_LIB( [opendbx], [odbx_init], [AC_DEFINE([HAVE_LIBOPENDBX], 1, [Have -lopendbx]) LIBOPENDBX="opendbx"] ) ;; tinydns) needcdb=yes ;; esac done AM_CONDITIONAL(ORACLE,test x"$needoracle" = "xyes") if test "$needoracle" then AC_ARG_WITH(oracle_includes, AC_HELP_STRING([--with-oracle-includes=],[instantclient sdk include dir])) AC_ARG_WITH(oracle_libs, AC_HELP_STRING([--with-oracle-libs=],[instantclient oracle library dir])) if test x"$with_oracle_includes" = "x" then # check possible locations for p1 in /usr/include/oracle /usr/local/include/oracle do for p2 in $p1/*/client* do if test -d "$p2" then with_oracle_includes=$p2 fi done done fi if test x"$with_oracle_includes" = x && test "$ORACLE_HOME/rdbms/public" != "/rdbms/public"; then if test -d $ORACLE_HOME/rdbms/public; then with_oracle_includes=$ORACLE_HOME/rdbms/public fi fi # test header old_CXXFLAGS="$CXXFLAGS" old_CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS -I$with_oracle_includes" CPPFLAGS="$CPPFLAGS -I$with_oracle_includes" AC_CHECK_HEADER([oci.h], ORACLE_CFLAGS="-I$with_oracle_includes", AC_MSG_ERROR([Could not find oci.h])) CXXFLAGS="$old_CXXFLAGS" CPPFLAGS="$old_CPPFLAGS" AC_SUBST([ORACLE_CFLAGS]) AC_SUBST([ORACLE_LIBS]) if test x"$with_oracle_libs" = "x" then # check possible locationse for p1 in /usr/lib/oracle /usr/local/lib/oracle do for p2 in $p1/*/client*/lib do if test -d "$p2" then with_oracle_libs=$p2 fi done done fi if test x"$with_oracle_libs" = x && test "$ORACLE_HOME/lib" != "/lib"; then if test -d $ORACLE_HOME/lib; then with_oracle_libs=$ORACLE_HOME/lib fi fi # we have to check for client9 as well... # test -lclntsh old_LDFLAGS="$LDFLAGS" LDFLAGS="-L$with_oracle_libs -lnnz11 -locci" AC_CHECK_LIB([clntsh],[OCIEnvInit],ORACLE_LIBS="-L$with_oracle_libs -lnnz11 -lclntsh -locci", AC_CHECK_LIB([client9], [OCIEnvInit],ORACLE_LIBS="-L$with_oracle_libs -lclient9 -lclntsh9",AC_MSG_ERROR([Could not find client libraries]))) LDFLAGS="$old_LDFLAGS" fi if test "$needmysql" then AC_ARG_WITH(mysql, AC_HELP_STRING([--with-mysql=],[root directory path of MySQL installation]), [MYSQL_lib_check="$withval/lib/mysql $with_mysql/lib" MYSQL_inc_check="$withval/include/mysql" MYSQL_config_check="$withval/bin/mysql_config"], [MYSQL_lib_check="/usr/local/mysql/lib/mysql /usr/local/lib/mysql /opt/mysql/lib/mysql \ /usr/lib/mysql /usr/lib64/mysql /usr/local/mysql/lib /usr/local/lib /opt/mysql/lib /usr/lib \ /usr/sfw/lib/ /usr/lib/x86_64-linux-gnu/" MYSQL_inc_check="/usr/local/mysql/include/mysql /usr/local/include/mysql \ /opt/mysql/include/mysql /opt/mysql/include /usr/include/mysql /usr/sfw/include/mysql"]) AC_ARG_WITH(mysql-config, AC_HELP_STRING([--with-mysql-config=],[file path to mysql_config]), [MYSQL_config_check=$withval]) AC_ARG_WITH(mysql-lib, AC_HELP_STRING([--with-mysql-lib=],[directory path of MySQL library installation]), [MYSQL_lib_check="$withval/lib/mysql $withval/mysql $withval" MYSQL_config_check="skip"]) AC_ARG_WITH(mysql-includes, AC_HELP_STRING([--with-mysql-includes=],[directory path of MySQL header installation]), [MYSQL_inc_check="$withval/include/mysql $withval/mysql $withval" MYSQL_config_check="skip"]) MYSQL_config="" if test "x$MYSQL_config_check" != "xskip"; then AC_MSG_CHECKING([for mysql_config]) if test "x$MYSQL_config_check" == "x"; then # check if it's in path for m in /bin /usr/bin /usr/local/bin /opt/csw/bin; do if test -x $m/mysql_config; then MYSQL_config=$m/mysql_config break fi done if test "x$MYSQL_config" == "x"; then AC_MSG_RESULT([not found]) else AC_MSG_RESULT([$MYSQL_config]) fi else if test -x $MYSQL_config_check; then MYSQL_config="$MYSQL_config_check" AC_MSG_RESULT([$MYSQL_config]) else MYSQL_config="" AC_MSG_ERROR([not found]) fi fi fi if test "x$MYSQL_config" != "x"; then # use this to configure everything MYSQL_lib=`$MYSQL_config --libs` MYSQL_inc=`$MYSQL_config --include` else AC_MSG_CHECKING([for MySQL library directory]) MYSQL_libdir= for m in $MYSQL_lib_check; do if test -d "$m" && \ (test -f "$m/libmysqlclient.so" || test -f "$m/libmysqlclient.a") then MYSQL_libdir=$m break fi done if test -z "$MYSQL_libdir"; then AC_MSG_ERROR([Did not find the mysql library dir in '$MYSQL_lib_check']) fi case "$MYSQL_libdir" in /*) MYSQL_lib="-L$MYSQL_libdir -lmysqlclient" ;; *) AC_MSG_ERROR([The MySQL library directory ($MYSQL_libdir) must be an absolute path.]) ;; esac AC_MSG_RESULT([$MYSQL_libdir]) AC_SUBST(MYSQL_lib) AC_MSG_CHECKING([for MySQL include directory]) MYSQL_inc= for m in $MYSQL_inc_check; do if test -d "$m" && test -f "$m/mysql.h" then MYSQL_inc="$m" break fi done if test -z "$MYSQL_inc"; then AC_MSG_ERROR([Did not find the mysql include dir in '$MYSQL_inc_check']) fi case "$MYSQL_inc" in /*) AC_MSG_RESULT($MYSQL_inc) ;; *) AC_MSG_ERROR([The MySQL include directory ($MYSQL_inc) must be an absolute path.]) ;; esac MYSQL_inc="-I$MYSQL_inc" fi AC_SUBST(MYSQL_lib) AC_SUBST(MYSQL_inc) fi if test "$needpgsql" then AC_ARG_WITH(pgsql, AC_HELP_STRING([--with-pgsql=],[root directory path of PgSQL installation]), [PGSQL_lib_check="$withval/lib/pgsql $with_pgsql/lib" PGSQL_inc_check="$withval/include/pgsql"], [PGSQL_lib_check="/usr/local/pgsql/lib/pgsql /usr/local/lib/pgsql /opt/pgsql/lib/pgsql /usr/lib/pgsql /usr/local/pgsql/lib /usr/local/lib /opt/pgsql/lib /usr/lib /usr/lib64" PGSQL_inc_check="/usr/local/pgsql/include/pgsql /usr/include /usr/local/include/postgresql/ /usr/local/include /opt/pgsql/include/pgsql /opt/pgsql/include /usr/include/pgsql/ /usr/include/postgresql"]) AC_ARG_WITH(pgsql-lib, AC_HELP_STRING([--with-pgsql-lib=],[directory path of PgSQL library installation]), [PGSQL_lib_check="$withval/lib/pgsql $withval/pgsql $withval"]) AC_ARG_WITH(pgsql-includes, AC_HELP_STRING([--with-pgsql-includes=],[directory path of PgSQL header installation]), [PGSQL_inc_check="$withval/include/pgsql $withval/pgsql $withval"]) AC_MSG_CHECKING([for PgSQL library directory]) PGSQL_libdir= for m in $PGSQL_lib_check; do if test -d "$m" && \ (test -f "$m/libpq.a" || test -f "$m/libpq.so") then PGSQL_libdir=$m break fi done if test -z "$PGSQL_libdir"; then AC_MSG_ERROR([Didn't find the pgsql library dir in '$PGSQL_lib_check']) fi case "$PGSQL_libdir" in /usr/lib ) PGSQL_lib="" ;; /usr/lib64 ) PGSQL_lib="" ;; /* ) PGSQL_lib="-L$PGSQL_libdir -Wl,-rpath,$PGSQL_libdir" LDFLAGS="$PGSQL_lib $LDFLAGS" ;; * ) AC_MSG_ERROR([The PgSQL library directory ($PGSQL_libdir) must be an absolute path.]) ;; esac AC_SUBST(PGSQL_lib) AC_MSG_RESULT([$PGSQL_libdir]) AC_MSG_CHECKING([for PgSQL include directory]) PGSQL_incdir= for m in $PGSQL_inc_check; do if test -d "$m" && test -f "$m/libpq-fe.h" then PGSQL_incdir=$m break fi done if test -z "$PGSQL_incdir"; then AC_MSG_ERROR([Didn't find the PgSQL include dir in '$PGSQL_inc_check']) fi case "$PGSQL_incdir" in /* ) ;; * ) AC_MSG_ERROR([The PgSQL include directory ($PGSQL_incdir) must be an absolute path.]) ;; esac AC_SUBST(PGSQL_incdir) AC_MSG_RESULT([$PGSQL_incdir]) fi AM_CONDITIONAL(SQLITE3, test "$needsqlite3") if test "$needsqlite3" then PKG_CHECK_MODULES(SQLITE3, $SQLITE3PC, HAVE_SQLITE3=yes, AC_MSG_ERROR([+Could not find sqlite3])) AC_SUBST(SQLITE3_LIBS) AC_SUBST(SQLITE3_CFLAGS) AC_DEFINE(HAVE_SQLITE3,1,[If we have sqlite3]) fi if test "$needcdb" then PKG_CHECK_MODULES(CDB, libcdb, HAVE_CDB=yes, AC_MSG_ERROR([+Could not find libcdb/tinycdb])) AC_SUBST(CDB_LIBS) AC_SUBST(CDB_CFLAGS) fi if test "$needunixodbc" then AC_ARG_WITH(unixodbc, AC_HELP_STRING([--with-unixodbc=],[root directory path of unixodbc installation]), [UNIXODBC_lib_check="$withval/lib/unixodbc $with_unixodbc/lib $withval/lib" UNIXODBC_inc_check="$withval/include/unixodbc"], [UNIXODBC_lib_check="/usr/local/unixodbc/lib/unixodbc /usr/local/lib/unixodbc /usr/lib/unixodbc /usr/local/unixodbc/lib /usr/local/lib /opt/unixodbc/lib /usr/lib" UNIXODBC_inc_check="/usr/local/unixodbc/include/unixodbc /usr/local/include/unixodbc/ /usr/local/include /opt/unixodbc/include/unixodbc /opt/unixodbc/include /usr/include/ /usr/include/unixodbc"]) AC_ARG_WITH(unixodbc-lib, AC_HELP_STRING([--with-unixodbc-lib=],[directory path of unixodbc library installation]), [UNIXODBC_lib_check="$withval/lib/unixodbc $withval/unixodbc $withval"]) AC_ARG_WITH(unixodbc-includes, AC_HELP_STRING([--with-unixodbc-includes=],[directory path of unixodbc header installation]), [UNIXODBC_inc_check="$withval/include $withval/include/unixodbc $withval/unixodbc $withval"]) AC_MSG_CHECKING([for unixodbc library directory]) UNIXODBC_libdir= for m in $UNIXODBC_lib_check; do if test -d "$m" && \ (test -f "$m/libodbc.so" || test -f "$m/libodbc.a") then UNIXODBC_libdir=$m break fi done if test -z "$UNIXODBC_libdir"; then AC_MSG_ERROR([Didn't find the unixodbc library dir in '$UNIXODBC_lib_check']) fi case "$UNIXODBC_libdir" in /usr/lib ) UNIXODBC_lib="" ;; /* ) UNIXODBC_lib="-L$UNIXODBC_libdir -Wl,-rpath,$UNIXODBC_libdir" LDFLAGS="$UNIXODBC_lib $LDFLAGS" ;; * ) AC_MSG_ERROR([The unixodbc library directory ($UNIXODBC_libdir) must be an absolute path.]) ;; esac AC_SUBST(UNIXODBC_lib) AC_MSG_RESULT([$UNIXODBC_libdir]) AC_MSG_CHECKING([for unixodbc include directory]) UNIXODBC_incdir= for m in $UNIXODBC_inc_check; do if test -d "$m" && test -f "$m/sql.h" then UNIXODBC_incdir=$m break fi done if test -z "$UNIXODBC_incdir"; then AC_MSG_ERROR([Didn't find the unixodbc include dir in '$UNIXODBC_inc_check']) fi case "$UNIXODBC_incdir" in /* ) ;; * ) AC_MSG_ERROR([The unixodbc include directory ($UNIXODBC_incdir) must be an absolute path.]) ;; esac AC_SUBST(UNIXODBC_incdir) AC_MSG_RESULT([$UNIXODBC_incdir]) # LIBS="$LIBS -lunixodbc" fi for a in $modules do moduledirs="$moduledirs ${a}backend" for b in `cat $srcdir/modules/${a}backend/OBJECTFILES` do moduleobjects="$moduleobjects ../modules/${a}backend/$b" done modulelibs="$modulelibs `cat $srcdir/modules/${a}backend/OBJECTLIBS`" if test ${a} = "gpgsql"; then LIBS="$LIBS $LIBCRYPT" case "$host_os" in freebsd*) ;; darwin*) modulelibs="$modulelibs -lresolv" ;; *) modulelibs="$modulelibs -lresolv -lnsl" ;; esac fi done for a in $dynmodules do moduledirs="$moduledirs ${a}backend" done AC_SUBST(LIBS) export moduledirs moduleobjects modulelibs AC_OUTPUT(Makefile modules/Makefile pdns/Makefile codedocs/Makefile \ pdns/backends/Makefile pdns/backends/bind/Makefile pdns/pdns pdns/precursor \ modules/gmysqlbackend/Makefile modules/db2backend/Makefile \ modules/geobackend/Makefile modules/opendbxbackend/Makefile \ modules/pipebackend/Makefile modules/oraclebackend/Makefile \ modules/xdbbackend/Makefile modules/godbcbackend/Makefile \ modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile \ modules/gsqlite3backend/Makefile \ modules/goraclebackend/Makefile modules/mydnsbackend/Makefile \ modules/luabackend/Makefile modules/tinydnsbackend/Makefile \ modules/remotebackend/Makefile \ modules/randombackend/Makefile) pdns-3.3/configure0000755000014601777760000253361312165464024015513 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.67 for pdns 3.3. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` ;; esac ECHO=${lt_ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF $* _LT_EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL $0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL $0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "$0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" fi test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pdns' PACKAGE_TARNAME='pdns' PACKAGE_VERSION='3.3' PACKAGE_STRING='pdns 3.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="pdns/receiver.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_default_prefix=/usr/local ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS UNIXODBC_incdir UNIXODBC_lib CDB_LIBS CDB_CFLAGS SQLITE3_LIBS SQLITE3_CFLAGS SQLITE3_FALSE SQLITE3_TRUE PGSQL_incdir PGSQL_lib MYSQL_inc MYSQL_lib ORACLE_LIBS ORACLE_CFLAGS ORACLE_FALSE ORACLE_TRUE LIBOPENDBX LIBLDAP TOOLS_FALSE TOOLS_TRUE programdescend modulelibs moduleobjects moduledirs socketdir ALLSTATIC_FALSE ALLSTATIC_TRUE REMOTEBACKEND_HTTP LIBCURL_LIBS LIBCURL_CFLAGS REMOTEBACKEND_HTTP_FALSE REMOTEBACKEND_HTTP_TRUE BOTAN18_LIBS BOTAN18_CFLAGS BOTAN110_LIBS BOTAN110_CFLAGS CRYPTOPP_FALSE CRYPTOPP_TRUE BOTAN18_FALSE BOTAN18_TRUE BOTAN110_FALSE BOTAN110_TRUE HAVE_LIBPOLARSSL_FALSE HAVE_LIBPOLARSSL_TRUE DYNLINKFLAGS THREADFLAGS OS_MACOSX_FALSE OS_MACOSX_TRUE LIBCRYPT LIBDL BOOST_UNIT_TEST_FRAMEWORK_LIBS BOOST_UNIT_TEST_FRAMEWORK_LDPATH BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS BOOST_SERIALIZATION_LIBS BOOST_SERIALIZATION_LDPATH BOOST_SERIALIZATION_LDFLAGS BOOST_PROGRAM_OPTIONS_LIBS BOOST_LDPATH BOOST_PROGRAM_OPTIONS_LDPATH BOOST_PROGRAM_OPTIONS_LDFLAGS BOOST_CPPFLAGS DISTCHECK_CONFIGURE_FLAGS BOOST_ROOT RELEASE_BUILD_FALSE RELEASE_BUILD_TRUE LUA_LIBS LUA_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG LEXLIB LEX_OUTPUT_ROOT LEX YFLAGS YACC CXXCPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL lt_ECHO RANLIB AR OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC LIBTOOL host_os host_vendor host_cpu host build_os build_vendor build_cpu build AM_BACKSLASH AM_DEFAULT_VERBOSITY am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM DIST_HOST target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_shared enable_static with_pic enable_fast_install enable_dependency_tracking with_gnu_ld enable_libtool_lock with_lua with_boost enable_static_boost enable_unit_tests with_sqlite3 enable_verbose_logging with_system_polarssl enable_botan1_10 enable_botan1_8 enable_cryptopp enable_remotebackend_http enable_static_binaries with_modules with_dynmodules with_socketdir enable_pdns_server enable_gcc_skip_locking enable_tools with_oracle_includes with_oracle_libs with_mysql with_mysql_config with_mysql_lib with_mysql_includes with_pgsql with_pgsql_lib with_pgsql_includes with_unixodbc with_unixodbc_lib with_unixodbc_includes ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC CXXCPP YACC YFLAGS PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR LUA_CFLAGS LUA_LIBS BOOST_ROOT BOTAN110_CFLAGS BOTAN110_LIBS BOTAN18_CFLAGS BOTAN18_LIBS LIBCURL_CFLAGS LIBCURL_LIBS SQLITE3_CFLAGS SQLITE3_LIBS CDB_CFLAGS CDB_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures pdns 3.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/pdns] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of pdns 3.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-libtool-lock avoid locking (might break parallel builds) --enable-static-boost Prefer the static boost libraries over the shared ones [no] --enable-unit-tests enable unit test building --enable-verbose-logging do verbose logging --enable-botan1.10 use Botan 1.10 --enable-botan1.8 use Botan 1.8 --enable-cryptopp use Crypto++ --enable-remotebackend-http enable HTTP connector for remotebackend --enable-static-binaries Build static binaries --enable-pdns_server if we should build the server --enable-gcc-skip-locking if we should forcefully skip gcc locking --enable-tools if we should build+install the tools Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-lua use Lua --with-boost=DIR prefix of Boost 1.35 [guess] --with-sqlite3 include sqlite3 driver --without-system-polarssl do not use system PolarSSL --with-modules which backends to compile with --with-dynmodules which backends to build for dynamic loading --with-socketdir where the controlsocket lives --with-oracle-includes= instantclient sdk include dir --with-oracle-libs= instantclient oracle library dir --with-mysql= root directory path of MySQL installation --with-mysql-config= file path to mysql_config --with-mysql-lib= directory path of MySQL library installation --with-mysql-includes= directory path of MySQL header installation --with-pgsql= root directory path of PgSQL installation --with-pgsql-lib= directory path of PgSQL library installation --with-pgsql-includes= directory path of PgSQL header installation --with-unixodbc= root directory path of unixodbc installation --with-unixodbc-lib= directory path of unixodbc library installation --with-unixodbc-includes= directory path of unixodbc header installation Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor YACC The `Yet Another C Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path LUA_CFLAGS C compiler flags for LUA, overriding pkg-config LUA_LIBS linker flags for LUA, overriding pkg-config BOOST_ROOT Location of Boost installation BOTAN110_CFLAGS C compiler flags for BOTAN110, overriding pkg-config BOTAN110_LIBS linker flags for BOTAN110, overriding pkg-config BOTAN18_CFLAGS C compiler flags for BOTAN18, overriding pkg-config BOTAN18_LIBS linker flags for BOTAN18, overriding pkg-config LIBCURL_CFLAGS C compiler flags for LIBCURL, overriding pkg-config LIBCURL_LIBS linker flags for LIBCURL, overriding pkg-config SQLITE3_CFLAGS C compiler flags for SQLITE3, overriding pkg-config SQLITE3_LIBS linker flags for SQLITE3, overriding pkg-config CDB_CFLAGS C compiler flags for CDB, overriding pkg-config CDB_LIBS linker flags for CDB, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF pdns configure 3.3 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES # --------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_cxx_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_type # ac_fn_cxx_check_func LINENO FUNC VAR # ------------------------------------ # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_cxx_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by pdns $as_me 3.3, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DIST_HOST=jenkins@autotest.powerdns.com am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='pdns' VERSION='3.3' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_ustar}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if test "${am_cv_prog_tar_ustar+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac AM_BACKSLASH='\' # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.2.6b' macro_revision='1.3017' ltmain="$ac_aux_dir/ltmain.sh" DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if test "${lt_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if test "${lt_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$ac_tool_prefix"; then for ac_prog in "dumpbin -symbols" "link -dump -symbols" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in "dumpbin -symbols" "link -dump -symbols" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if test "${lt_cv_nm_interface+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:5060: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:5063: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:5066: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if test "${lt_cv_sys_max_cmd_len+set}" = set; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if test "${lt_cv_ld_reload_flag+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if test "${lt_cv_deplibs_check_method+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line 6272 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if test "${lt_cv_cc_needs_belf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if test "${lt_cv_apple_cc_single_mod+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if test "${lt_cv_objdir+set}" = set; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:7801: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:7805: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl*) # IBM XL C 8.0/Fortran 10.1 on PPC lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Sun\ F*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 $as_echo "$lt_prog_compiler_pic" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:8140: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:8144: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test "${lt_cv_prog_compiler_static_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:8245: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:8249: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:8300: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:8304: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu) link_all_deplibs=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported whole_archive_flag_spec='' link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo(void) {} _ACEOF if ac_fn_c_try_link "$LINENO"; then : archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then archive_cmds_need_lc=no else archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 $as_echo "$archive_cmds_need_lc" >&6; } ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if test "${ac_cv_lib_dld_shl_load+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if test "${ac_cv_lib_svld_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if test "${ac_cv_lib_dld_dld_link+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if test "${lt_cv_dlopen_self+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line 10684 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if test "${lt_cv_dlopen_self_static+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line 10780 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: ac_config_headers="$ac_config_headers config.h" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac : ${CXXFLAGS="-Wall -O2"} ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} _lt_caught_CXX_error=yes; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_flag_spec_ld_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if test "${lt_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if test "${lt_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec_CXX='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported whole_archive_flag_spec_CXX='' link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd[12]*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5]* | *pgcpp\ [1-5]*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=echo else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC*) # IBM XL 8.0 on PPC lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_CXX" >&5 $as_echo "$lt_prog_compiler_pic_CXX" >&6; } # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:14563: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:14567: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:14662: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:14666: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:14714: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:14718: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' ;; linux* | k*bsd*-gnu) link_all_deplibs_CXX=no ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then archive_cmds_need_lc_CXX=no else archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_CXX" >&5 $as_echo "$archive_cmds_need_lc_CXX" >&6; } ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval "test \"\${ac_cv_prog_cc_${ac_cc}_c_o+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_YACC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_LEX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 $as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LEX" && break done test -n "$LEX" || LEX=":" if test "x$LEX" != "x:"; then cat >conftest.l <<_ACEOF %% a { ECHO; } b { REJECT; } c { yymore (); } d { yyless (1); } e { yyless (input () != 0); } f { unput (yytext[0]); } . { BEGIN INITIAL; } %% #ifdef YYTEXT_POINTER extern char *yytext; #endif int main (void) { return ! yylex () + ! yywrap (); } _ACEOF { { ac_try="$LEX conftest.l" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$LEX conftest.l") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 $as_echo_n "checking lex output file root... " >&6; } if test "${ac_cv_prog_lex_root+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -f lex.yy.c; then ac_cv_prog_lex_root=lex.yy elif test -f lexyy.c; then ac_cv_prog_lex_root=lexyy else as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 $as_echo "$ac_cv_prog_lex_root" >&6; } LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root if test -z "${LEXLIB+set}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 $as_echo_n "checking lex library... " >&6; } if test "${ac_cv_lib_lex+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS=$LIBS ac_cv_lib_lex='none needed' for ac_lib in '' -lfl -ll; do LIBS="$ac_lib $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lex=$ac_lib fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext test "$ac_cv_lib_lex" != 'none needed' && break done LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 $as_echo "$ac_cv_lib_lex" >&6; } test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 $as_echo_n "checking whether yytext is a pointer... " >&6; } if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then : $as_echo_n "(cached) " >&6 else # POSIX says lex can declare yytext either as a pointer or an array; the # default is implementation-dependent. Figure out which it is, since # not all implementations provide the %pointer and %array declarations. ac_cv_prog_lex_yytext_pointer=no ac_save_LIBS=$LIBS LIBS="$LEXLIB $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define YYTEXT_POINTER 1 `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_prog_lex_yytext_pointer=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 $as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } if test $ac_cv_prog_lex_yytext_pointer = yes; then $as_echo "#define YYTEXT_POINTER 1" >>confdefs.h fi rm -f conftest.l $LEX_OUTPUT_ROOT.c fi if test "$LEX" = :; then LEX=${am_missing_run}flex fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking if with lua" >&5 $as_echo_n "checking if with lua... " >&6; } # Check whether --with-lua was given. if test "${with_lua+set}" = set; then : withval=$with_lua; WITH_LUA=$withval else WITH_LUA=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_LUA" >&5 $as_echo "$WITH_LUA" >&6; } if test "$WITH_LUA" != "no"; then # try pkgconfig if test "$WITH_LUA" = "yes"; then LUAPC=lua else LUAPC=$WITH_LUA fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$LUAPC >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "$LUAPC >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "$LUAPC >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$LUAPC >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "$LUAPC >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "$LUAPC >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$LUAPC >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "$LUAPC >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua-5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua-5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (lua-5.1 >= 5.1) were not met: $LUA_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5 ; } else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua-5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua-5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (lua-5.1 >= 5.1) were not met: $LUA_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5 ; } else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua-5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua-5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (lua-5.1 >= 5.1) were not met: $LUA_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5 ; } else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LUA" >&5 $as_echo_n "checking for LUA... " >&6; } if test -n "$LUA_CFLAGS"; then pkg_cv_LUA_CFLAGS="$LUA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_CFLAGS=`$PKG_CONFIG --cflags "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LUA_LIBS"; then pkg_cv_LUA_LIBS="$LUA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua-5.1 >= 5.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "lua-5.1 >= 5.1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LUA_LIBS=`$PKG_CONFIG --libs "lua-5.1 >= 5.1" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua-5.1 >= 5.1" 2>&1` else LUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua-5.1 >= 5.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LUA_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (lua-5.1 >= 5.1) were not met: $LUA_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables LUA_CFLAGS and LUA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5 ; } else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi else LUA_CFLAGS=$pkg_cv_LUA_CFLAGS LUA_LIBS=$pkg_cv_LUA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LUA 1" >>confdefs.h $as_echo "#define HAVE_LUA_H 1" >>confdefs.h fi fi if test "$PACKAGE_VERSION" != "git"; then RELEASE_BUILD_TRUE= RELEASE_BUILD_FALSE='#' else RELEASE_BUILD_TRUE='#' RELEASE_BUILD_FALSE= fi echo "$as_me: this is boost.m4 serial 18" >&5 boost_save_IFS=$IFS boost_version_req=1.35 IFS=. set x $boost_version_req 0 0 0 IFS=$boost_save_IFS shift boost_version_req=`expr "$1" '*' 100000 + "$2" '*' 100 + "$3"` boost_version_req_string=$1.$2.$3 # Check whether --with-boost was given. if test "${with_boost+set}" = set; then : withval=$with_boost; fi # If BOOST_ROOT is set and the user has not provided a value to # --with-boost, then treat BOOST_ROOT as if it the user supplied it. if test x"$BOOST_ROOT" != x; then if test x"$with_boost" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT" >&5 $as_echo "$as_me: Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT" >&6;} with_boost=$BOOST_ROOT else { $as_echo "$as_me:${as_lineno-$LINENO}: Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost" >&5 $as_echo "$as_me: Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost" >&6;} fi fi DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'" boost_save_CPPFLAGS=$CPPFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boost headers version >= $boost_version_req_string" >&5 $as_echo_n "checking for Boost headers version >= $boost_version_req_string... " >&6; } if test "${boost_cv_inc_path+set}" = set; then : $as_echo_n "(cached) " >&6 else boost_cv_inc_path=no ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !defined BOOST_VERSION # error BOOST_VERSION is not defined #elif BOOST_VERSION < $boost_version_req # error Boost headers version < $boost_version_req #endif int main () { ; return 0; } _ACEOF # If the user provided a value to --with-boost, use it and only it. case $with_boost in #( ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \ /usr/include C:/Boost/include;; #( *) set x "$with_boost/include" "$with_boost";; esac shift for boost_dir do # Without --layout=system, Boost (or at least some versions) installs # itself in /include/boost-. This inner loop helps to # find headers in such directories. # # Any ${boost_dir}/boost-x_xx directories are searched in reverse version # order followed by ${boost_dir}. The final '.' is a sentinel for # searching $boost_dir" itself. Entries are whitespace separated. # # I didn't indent this loop on purpose (to avoid over-indented code) boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \ && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \ && echo .` for boost_inc in $boost_layout_system_search_list do if test x"$boost_inc" != x.; then boost_inc="$boost_dir/$boost_inc" else boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list fi if test x"$boost_inc" != x; then # We are going to check whether the version of Boost installed # in $boost_inc is usable by running a compilation that # #includes it. But if we pass a -I/some/path in which Boost # is not installed, the compiler will just skip this -I and # use other locations (either from CPPFLAGS, or from its list # of system include directories). As a result we would use # header installed on the machine instead of the /some/path # specified by the user. So in that precise case (trying # $boost_inc), make sure the version.hpp exists. # # Use test -e as there can be symlinks. test -e "$boost_inc/boost/version.hpp" || continue CPPFLAGS="$CPPFLAGS -I$boost_inc" fi if ac_fn_cxx_try_compile "$LINENO"; then : boost_cv_inc_path=yes else boost_cv_version=no fi rm -f core conftest.err conftest.$ac_objext if test x"$boost_cv_inc_path" = xyes; then if test x"$boost_inc" != x; then boost_cv_inc_path=$boost_inc fi break 2 fi done done ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_inc_path" >&5 $as_echo "$boost_cv_inc_path" >&6; } case $boost_cv_inc_path in #( no) boost_errmsg="cannot find Boost headers version >= $boost_version_req_string" as_fn_error $? "$boost_errmsg" "$LINENO" 5 ;;#( yes) BOOST_CPPFLAGS= ;;#( *) BOOST_CPPFLAGS="-I$boost_cv_inc_path" ;; esac if test x"$boost_cv_inc_path" != xno; then $as_echo "#define HAVE_BOOST 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boost's header version" >&5 $as_echo_n "checking for Boost's header version... " >&6; } if test "${boost_cv_lib_version+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include boost-lib-version = BOOST_LIB_VERSION _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | tr -d '\r' | $SED -n -e "/^boost-lib-version = /{s///;s/\"//g;p;q;}" >conftest.i 2>&1; then : boost_cv_lib_version=`cat conftest.i` fi rm -rf conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_lib_version" >&5 $as_echo "$boost_cv_lib_version" >&6; } # e.g. "134" for 1_34_1 or "135" for 1_35 boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'` case $boost_major_version in #( '' | *[!0-9]*) as_fn_error $? "invalid value: boost_major_version=$boost_major_version" "$LINENO" 5 ;; esac fi CPPFLAGS=$boost_save_CPPFLAGS if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for boost/foreach.hpp" >&5 $as_echo "$as_me: Boost not available, not searching for boost/foreach.hpp" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" ac_fn_cxx_check_header_mongrel "$LINENO" "boost/foreach.hpp" "ac_cv_header_boost_foreach_hpp" "$ac_includes_default" if test "x$ac_cv_header_boost_foreach_hpp" = x""yes; then : $as_echo "#define HAVE_BOOST_FOREACH_HPP 1" >>confdefs.h else as_fn_error $? "cannot find boost/foreach.hpp" "$LINENO" 5 fi CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the toolset name used by Boost for $CXX" >&5 $as_echo_n "checking for the toolset name used by Boost for $CXX... " >&6; } if test "${boost_cv_lib_tag+set}" = set; then : $as_echo_n "(cached) " >&6 else boost_cv_lib_tag=unknown if test x$boost_cv_inc_path != xno; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # The following tests are mostly inspired by boost/config/auto_link.hpp # The list is sorted to most recent/common to oldest compiler (in order # to increase the likelihood of finding the right compiler with the # least number of compilation attempt). # Beware that some tests are sensible to the order (for instance, we must # look for MinGW before looking for GCC3). # I used one compilation test per compiler with a #error to recognize # each compiler so that it works even when cross-compiling (let me know # if you know a better approach). # Known missing tags (known from Boost's tools/build/v2/tools/common.jam): # como, edg, kcc, bck, mp, sw, tru, xlc # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines # the same defines as GCC's). for i in \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 8 && !defined __ICC @ gcc48" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 7 && !defined __ICC @ gcc47" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 6 && !defined __ICC @ gcc46" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 5 && !defined __ICC @ gcc45" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 4 && !defined __ICC @ gcc44" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 3 && !defined __ICC @ gcc43" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && !defined __ICC @ gcc42" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 1 && !defined __ICC @ gcc41" \ "defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && !defined __ICC @ gcc40" \ "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \ && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \ "defined __GNUC__ && __GNUC__ == 3 && __GNUC_MINOR__ == 4 && !defined __ICC @ gcc34" \ "defined __GNUC__ && __GNUC__ == 3 && __GNUC_MINOR__ == 3 && !defined __ICC @ gcc33" \ "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \ "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \ "defined __GNUC__ && __GNUC__ == 3 && __GNUC_MINOR__ == 2 && !defined __ICC @ gcc32" \ "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \ "defined __GNUC__ && __GNUC__ == 3 && __GNUC_MINOR__ == 1 && !defined __ICC @ gcc31" \ "defined __GNUC__ && __GNUC__ == 3 && __GNUC_MINOR__ == 0 && !defined __ICC @ gcc30" \ "defined __BORLANDC__ @ bcb" \ "defined __ICC && (defined __unix || defined ) @ il" \ "defined __ICL @ iw" \ "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \ "defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ == 95 && !defined __ICC @ gcc295" \ "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \ "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \ "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \ "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8" do boost_tag_test=`expr "X$i" : 'X\([^@]*\) @ '` boost_tag=`expr "X$i" : 'X[^@]* @ \(.*\)'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if $boost_tag_test /* OK */ #else # error $boost_tag_test #endif int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : boost_cv_lib_tag=$boost_tag; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu case $boost_cv_lib_tag in #( # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed # to "gcc41" for instance. *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there. gcc*) boost_tag_x= case $host_os in #( darwin*) if test $boost_major_version -ge 136; then # The `x' added in r46793 of Boost. boost_tag_x=x fi;; esac # We can specify multiple tags in this variable because it's used by # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ... boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc" ;; #( unknown) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not figure out which toolset name to use for $CXX" >&5 $as_echo "$as_me: WARNING: could not figure out which toolset name to use for $CXX" >&2;} boost_cv_lib_tag= ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_lib_tag" >&5 $as_echo "$boost_cv_lib_tag" >&6; } # Check whether --enable-static-boost was given. if test "${enable_static_boost+set}" = set; then : enableval=$enable_static_boost; enable_static_boost=yes else enable_static_boost=no fi # Check whether we do better use `mt' even though we weren't ask to. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined _REENTRANT || defined _MT || defined __MT__ /* use -mt */ #else # error MT not needed #endif int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : boost_guess_use_mt=: else boost_guess_use_mt=false fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for the Boost program_options library" >&5 $as_echo "$as_me: Boost not available, not searching for the Boost program_options library" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for boost/program_options.hpp" >&5 $as_echo "$as_me: Boost not available, not searching for boost/program_options.hpp" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" ac_fn_cxx_check_header_mongrel "$LINENO" "boost/program_options.hpp" "ac_cv_header_boost_program_options_hpp" "$ac_includes_default" if test "x$ac_cv_header_boost_program_options_hpp" = x""yes; then : $as_echo "#define HAVE_BOOST_PROGRAM_OPTIONS_HPP 1" >>confdefs.h else as_fn_error $? "cannot find boost/program_options.hpp" "$LINENO" 5 fi CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" # Now let's try to find the library. The algorithm is as follows: first look # for a given library name according to the user's PREFERRED-RT-OPT. For each # library name, we prefer to use the ones that carry the tag (toolset name). # Each library is searched through the various standard paths were Boost is # usually installed. If we can't find the standard variants, we try to # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist # but there's -obviously- libboost_threads-mt.dylib). { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Boost program_options library" >&5 $as_echo_n "checking for the Boost program_options library... " >&6; } if test "${boost_cv_lib_program_options+set}" = set; then : $as_echo_n "(cached) " >&6 else boost_cv_lib_program_options=no case "mt" in #( mt | mt-) boost_mt=-mt; boost_rtopt=;; #( mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "Xmt" : 'Xmt-*\(.*\)'`;; #( *) boost_mt=; boost_rtopt=mt;; esac if test $enable_static_boost = yes; then boost_rtopt="s$boost_rtopt" fi # Find the proper debug variant depending on what we've been asked to find. case $boost_rtopt in #( *d*) boost_rt_d=$boost_rtopt;; #( *[sgpn]*) # Insert the `d' at the right place (in between `sg' and `pn') boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( *) boost_rt_d='-d';; esac # If the PREFERRED-RT-OPT are not empty, prepend a `-'. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" $boost_guess_use_mt && boost_mt=-mt # Look for the abs path the static archive. # $libext is computed by Libtool but let's make sure it's non empty. test -z "$libext" && as_fn_error $? "the libext variable is empty, did you invoke Libtool?" "$LINENO" 5 boost_save_ac_objext=$ac_objext # Generate the test file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { boost::program_options::options_description d("test"); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_objext=do_not_rm_me_plz else as_fn_error $? "cannot compile a test that uses Boost program_options" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to ident the 6 nested for loops, only the 2 innermost ones # matter. for boost_tag_ in -$boost_cv_lib_tag ''; do for boost_ver_ in -$boost_cv_lib_version ''; do for boost_mt_ in $boost_mt -mt ''; do for boost_rtopt_ in $boost_rtopt '' -d; do for boost_lib in \ boost_program_options$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ boost_program_options$boost_tag_$boost_rtopt_$boost_ver_ \ boost_program_options$boost_tag_$boost_mt_$boost_ver_ \ boost_program_options$boost_tag_$boost_ver_ do # Avoid testing twice the same lib case $boost_failed_libs in #( *@$boost_lib@*) continue;; esac # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. boost_tmp_lib=$with_boost test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} for boost_ldpath in "$boost_tmp_lib/lib" '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ "$with_boost" C:/Boost/lib /lib* do test -n "$boost_ldpath" -a ! -e "$boost_ldpath" && continue boost_save_LDFLAGS=$LDFLAGS # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) boost_cv_lib_program_options_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$boost_cv_lib_program_options_LIBS" || continue;; #( *) # No: use -lboost_foo to find the shared library. boost_cv_lib_program_options_LIBS="-l$boost_lib";; esac boost_save_LIBS=$LIBS LIBS="$boost_cv_lib_program_options_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_cv_lib_program_options=yes else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_cv_lib_program_options=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext ac_objext=$boost_save_ac_objext LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$boost_cv_lib_program_options" = xyes; then # Check or used cached result of whether or not using -R or -rpath makes sense. # Some implementations of ld, such as for Mac OSX, require -rpath but # -R is the flag known to work on other systems. # https://github.com/tsuna/boost.m4/issues/19 if test "${boost_cv_rpath_link_ldflag+set}" = set; then : $as_echo_n "(cached) " >&6 else for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do test x"$boost_ldpath" != x && LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" LIBS="$boost_save_LIBS $boost_cv_lib_program_options_LIBS" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_rpath_link_ldflag_found=yes break else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_rpath_link_ldflag_found=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext done if test "x$boost_rpath_link_ldflag_found" != "xyes"; then : as_fn_error $? "Unable to determine whether to use -R or -rpath" "$LINENO" 5 fi LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS fi test x"$boost_ldpath" != x && boost_cv_lib_program_options_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" boost_cv_lib_program_options_LDPATH="$boost_ldpath" break 6 else boost_failed_libs="$boost_failed_libs@$boost_lib@" fi done done done done done done rm -f conftest.$ac_objext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_lib_program_options" >&5 $as_echo "$boost_cv_lib_program_options" >&6; } case $boost_cv_lib_program_options in #( no) $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 as_fn_error $? "cannot find the flags to link with Boost program_options" "$LINENO" 5 ;; esac BOOST_PROGRAM_OPTIONS_LDFLAGS=$boost_cv_lib_program_options_LDFLAGS BOOST_PROGRAM_OPTIONS_LDPATH=$boost_cv_lib_program_options_LDPATH BOOST_LDPATH=$boost_cv_lib_program_options_LDPATH BOOST_PROGRAM_OPTIONS_LIBS=$boost_cv_lib_program_options_LIBS CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for the Boost serialization library" >&5 $as_echo "$as_me: Boost not available, not searching for the Boost serialization library" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for boost/archive/text_oarchive.hpp" >&5 $as_echo "$as_me: Boost not available, not searching for boost/archive/text_oarchive.hpp" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" ac_fn_cxx_check_header_mongrel "$LINENO" "boost/archive/text_oarchive.hpp" "ac_cv_header_boost_archive_text_oarchive_hpp" "$ac_includes_default" if test "x$ac_cv_header_boost_archive_text_oarchive_hpp" = x""yes; then : $as_echo "#define HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP 1" >>confdefs.h else as_fn_error $? "cannot find boost/archive/text_oarchive.hpp" "$LINENO" 5 fi CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" # Now let's try to find the library. The algorithm is as follows: first look # for a given library name according to the user's PREFERRED-RT-OPT. For each # library name, we prefer to use the ones that carry the tag (toolset name). # Each library is searched through the various standard paths were Boost is # usually installed. If we can't find the standard variants, we try to # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist # but there's -obviously- libboost_threads-mt.dylib). { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Boost serialization library" >&5 $as_echo_n "checking for the Boost serialization library... " >&6; } if test "${boost_cv_lib_serialization+set}" = set; then : $as_echo_n "(cached) " >&6 else boost_cv_lib_serialization=no case "mt" in #( mt | mt-) boost_mt=-mt; boost_rtopt=;; #( mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "Xmt" : 'Xmt-*\(.*\)'`;; #( *) boost_mt=; boost_rtopt=mt;; esac if test $enable_static_boost = yes; then boost_rtopt="s$boost_rtopt" fi # Find the proper debug variant depending on what we've been asked to find. case $boost_rtopt in #( *d*) boost_rt_d=$boost_rtopt;; #( *[sgpn]*) # Insert the `d' at the right place (in between `sg' and `pn') boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( *) boost_rt_d='-d';; esac # If the PREFERRED-RT-OPT are not empty, prepend a `-'. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" $boost_guess_use_mt && boost_mt=-mt # Look for the abs path the static archive. # $libext is computed by Libtool but let's make sure it's non empty. test -z "$libext" && as_fn_error $? "the libext variable is empty, did you invoke Libtool?" "$LINENO" 5 boost_save_ac_objext=$ac_objext # Generate the test file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { std::ostream* o = 0; // Cheap way to get an ostream... boost::archive::text_oarchive t(*o); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_objext=do_not_rm_me_plz else as_fn_error $? "cannot compile a test that uses Boost serialization" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to ident the 6 nested for loops, only the 2 innermost ones # matter. for boost_tag_ in -$boost_cv_lib_tag ''; do for boost_ver_ in -$boost_cv_lib_version ''; do for boost_mt_ in $boost_mt -mt ''; do for boost_rtopt_ in $boost_rtopt '' -d; do for boost_lib in \ boost_serialization$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ boost_serialization$boost_tag_$boost_rtopt_$boost_ver_ \ boost_serialization$boost_tag_$boost_mt_$boost_ver_ \ boost_serialization$boost_tag_$boost_ver_ do # Avoid testing twice the same lib case $boost_failed_libs in #( *@$boost_lib@*) continue;; esac # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. boost_tmp_lib=$with_boost test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} for boost_ldpath in "$boost_tmp_lib/lib" '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ "$with_boost" C:/Boost/lib /lib* do test -n "$boost_ldpath" -a ! -e "$boost_ldpath" && continue boost_save_LDFLAGS=$LDFLAGS # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) boost_cv_lib_serialization_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$boost_cv_lib_serialization_LIBS" || continue;; #( *) # No: use -lboost_foo to find the shared library. boost_cv_lib_serialization_LIBS="-l$boost_lib";; esac boost_save_LIBS=$LIBS LIBS="$boost_cv_lib_serialization_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_cv_lib_serialization=yes else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_cv_lib_serialization=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext ac_objext=$boost_save_ac_objext LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$boost_cv_lib_serialization" = xyes; then # Check or used cached result of whether or not using -R or -rpath makes sense. # Some implementations of ld, such as for Mac OSX, require -rpath but # -R is the flag known to work on other systems. # https://github.com/tsuna/boost.m4/issues/19 if test "${boost_cv_rpath_link_ldflag+set}" = set; then : $as_echo_n "(cached) " >&6 else for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do test x"$boost_ldpath" != x && LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" LIBS="$boost_save_LIBS $boost_cv_lib_serialization_LIBS" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_rpath_link_ldflag_found=yes break else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_rpath_link_ldflag_found=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext done if test "x$boost_rpath_link_ldflag_found" != "xyes"; then : as_fn_error $? "Unable to determine whether to use -R or -rpath" "$LINENO" 5 fi LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS fi test x"$boost_ldpath" != x && boost_cv_lib_serialization_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" boost_cv_lib_serialization_LDPATH="$boost_ldpath" break 6 else boost_failed_libs="$boost_failed_libs@$boost_lib@" fi done done done done done done rm -f conftest.$ac_objext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_lib_serialization" >&5 $as_echo "$boost_cv_lib_serialization" >&6; } case $boost_cv_lib_serialization in #( no) $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 as_fn_error $? "cannot find the flags to link with Boost serialization" "$LINENO" 5 ;; esac BOOST_SERIALIZATION_LDFLAGS=$boost_cv_lib_serialization_LDFLAGS BOOST_SERIALIZATION_LDPATH=$boost_cv_lib_serialization_LDPATH BOOST_LDPATH=$boost_cv_lib_serialization_LDPATH BOOST_SERIALIZATION_LIBS=$boost_cv_lib_serialization_LIBS CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi # Check whether --enable-unit-tests was given. if test "${enable_unit_tests+set}" = set; then : enableval=$enable_unit_tests; enable_unit_tests=yes else enable_unit_tests=no fi if test x"$enable_unit_tests" = "xyes"; then if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for the Boost unit_test_framework library" >&5 $as_echo "$as_me: Boost not available, not searching for the Boost unit_test_framework library" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test x"$boost_cv_inc_path" = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: Boost not available, not searching for boost/test/unit_test.hpp" >&5 $as_echo "$as_me: Boost not available, not searching for boost/test/unit_test.hpp" >&6;} else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" ac_fn_cxx_check_header_mongrel "$LINENO" "boost/test/unit_test.hpp" "ac_cv_header_boost_test_unit_test_hpp" "$ac_includes_default" if test "x$ac_cv_header_boost_test_unit_test_hpp" = x""yes; then : $as_echo "#define HAVE_BOOST_TEST_UNIT_TEST_HPP 1" >>confdefs.h else as_fn_error $? "cannot find boost/test/unit_test.hpp" "$LINENO" 5 fi CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" # Now let's try to find the library. The algorithm is as follows: first look # for a given library name according to the user's PREFERRED-RT-OPT. For each # library name, we prefer to use the ones that carry the tag (toolset name). # Each library is searched through the various standard paths were Boost is # usually installed. If we can't find the standard variants, we try to # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist # but there's -obviously- libboost_threads-mt.dylib). { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Boost unit_test_framework library" >&5 $as_echo_n "checking for the Boost unit_test_framework library... " >&6; } if test "${boost_cv_lib_unit_test_framework+set}" = set; then : $as_echo_n "(cached) " >&6 else boost_cv_lib_unit_test_framework=no case "mt" in #( mt | mt-) boost_mt=-mt; boost_rtopt=;; #( mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "Xmt" : 'Xmt-*\(.*\)'`;; #( *) boost_mt=; boost_rtopt=mt;; esac if test $enable_static_boost = yes; then boost_rtopt="s$boost_rtopt" fi # Find the proper debug variant depending on what we've been asked to find. case $boost_rtopt in #( *d*) boost_rt_d=$boost_rtopt;; #( *[sgpn]*) # Insert the `d' at the right place (in between `sg' and `pn') boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( *) boost_rt_d='-d';; esac # If the PREFERRED-RT-OPT are not empty, prepend a `-'. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" $boost_guess_use_mt && boost_mt=-mt # Look for the abs path the static archive. # $libext is computed by Libtool but let's make sure it's non empty. test -z "$libext" && as_fn_error $? "the libext variable is empty, did you invoke Libtool?" "$LINENO" 5 boost_save_ac_objext=$ac_objext # Generate the test file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include using boost::unit_test::test_suite; test_suite* init_unit_test_suite(int argc, char ** argv) { return NULL; } int main () { BOOST_CHECK(2 == 2); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_objext=do_not_rm_me_plz else as_fn_error $? "cannot compile a test that uses Boost unit_test_framework" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to ident the 6 nested for loops, only the 2 innermost ones # matter. for boost_tag_ in -$boost_cv_lib_tag ''; do for boost_ver_ in -$boost_cv_lib_version ''; do for boost_mt_ in $boost_mt -mt ''; do for boost_rtopt_ in $boost_rtopt '' -d; do for boost_lib in \ boost_unit_test_framework$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ boost_unit_test_framework$boost_tag_$boost_rtopt_$boost_ver_ \ boost_unit_test_framework$boost_tag_$boost_mt_$boost_ver_ \ boost_unit_test_framework$boost_tag_$boost_ver_ do # Avoid testing twice the same lib case $boost_failed_libs in #( *@$boost_lib@*) continue;; esac # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. boost_tmp_lib=$with_boost test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} for boost_ldpath in "$boost_tmp_lib/lib" '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ "$with_boost" C:/Boost/lib /lib* do test -n "$boost_ldpath" -a ! -e "$boost_ldpath" && continue boost_save_LDFLAGS=$LDFLAGS # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) boost_cv_lib_unit_test_framework_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$boost_cv_lib_unit_test_framework_LIBS" || continue;; #( *) # No: use -lboost_foo to find the shared library. boost_cv_lib_unit_test_framework_LIBS="-l$boost_lib";; esac boost_save_LIBS=$LIBS LIBS="$boost_cv_lib_unit_test_framework_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_cv_lib_unit_test_framework=yes else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_cv_lib_unit_test_framework=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext ac_objext=$boost_save_ac_objext LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$boost_cv_lib_unit_test_framework" = xyes; then # Check or used cached result of whether or not using -R or -rpath makes sense. # Some implementations of ld, such as for Mac OSX, require -rpath but # -R is the flag known to work on other systems. # https://github.com/tsuna/boost.m4/issues/19 if test "${boost_cv_rpath_link_ldflag+set}" = set; then : $as_echo_n "(cached) " >&6 else for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do test x"$boost_ldpath" != x && LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" LIBS="$boost_save_LIBS $boost_cv_lib_unit_test_framework_LIBS" rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && $as_echo "$as_me:${as_lineno-$LINENO}: re-using the existing conftest.$ac_objext" >&5 if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext }; then : boost_rpath_link_ldflag_found=yes break else if $boost_use_source; then $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi boost_rpath_link_ldflag_found=no fi ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext done if test "x$boost_rpath_link_ldflag_found" != "xyes"; then : as_fn_error $? "Unable to determine whether to use -R or -rpath" "$LINENO" 5 fi LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS fi test x"$boost_ldpath" != x && boost_cv_lib_unit_test_framework_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" boost_cv_lib_unit_test_framework_LDPATH="$boost_ldpath" break 6 else boost_failed_libs="$boost_failed_libs@$boost_lib@" fi done done done done done done rm -f conftest.$ac_objext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boost_cv_lib_unit_test_framework" >&5 $as_echo "$boost_cv_lib_unit_test_framework" >&6; } case $boost_cv_lib_unit_test_framework in #( no) $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 as_fn_error $? "cannot find the flags to link with Boost unit_test_framework" "$LINENO" 5 ;; esac BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS=$boost_cv_lib_unit_test_framework_LDFLAGS BOOST_UNIT_TEST_FRAMEWORK_LDPATH=$boost_cv_lib_unit_test_framework_LDPATH BOOST_LDPATH=$boost_cv_lib_unit_test_framework_LDPATH BOOST_UNIT_TEST_FRAMEWORK_LIBS=$boost_cv_lib_unit_test_framework_LIBS CPPFLAGS=$boost_save_CPPFLAGS ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi fi #BOOST_SYSTEM([mt]) # detect pkg-config explicitly if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether user requires sqlite3" >&5 $as_echo_n "checking whether user requires sqlite3... " >&6; } # Check whether --with-sqlite3 was given. if test "${with_sqlite3+set}" = set; then : withval=$with_sqlite3; WITH_SQLITE3=$withval else WITH_SQLITE3=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_SQLITE3" >&5 $as_echo "$WITH_SQLITE3" >&6; } SQLITE3PC=sqlite3 if test "$WITH_SQLITE3" != "no"; then needsqlite3=yes if test "$WITH_SQLITE3" != "yes"; then SQLITE3PC=$WITH_SQLITE3 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in fcntl.h getopt.h limits.h strings.h sys/time.h syslog.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_cxx_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = x""yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if test "${ac_cv_struct_tm+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if test "${ac_cv_type_signal+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in gethostname gettimeofday mkdir mktime select socket strerror strcasestr do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Check for libdl LIBS="$LIBS -lz" my_save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF LIBS="-ldl $LIBS" fi LIBDL=$LIBS LIBS="$my_save_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for RTLD_NOW" >&5 $as_echo_n "checking for RTLD_NOW... " >&6; }; ac_save_LIBS="$LIBS" LIBS="$LIBS $LIBDL" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { (void) dlopen("",RTLD_NOW); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : has_RTLD_NOW=yes else has_RTLD_NOW=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_RTLD_NOW" >&5 $as_echo "$has_RTLD_NOW" >&6; } if test "$has_RTLD_NOW" = "no" then $as_echo "#define NEED_RTLD_NOW /**/" >>confdefs.h fi LIBS=$ac_save_LIBS # Check for libcrypt my_save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 $as_echo_n "checking for crypt in -lcrypt... " >&6; } if test "${ac_cv_lib_crypt_crypt+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char crypt (); int main () { return crypt (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_crypt_crypt=yes else ac_cv_lib_crypt_crypt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5 $as_echo "$ac_cv_lib_crypt_crypt" >&6; } if test "x$ac_cv_lib_crypt_crypt" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPT 1 _ACEOF LIBS="-lcrypt $LIBS" fi LIBCRYPT=$LIBS LIBS="$my_save_LIBS" DYNLINKFLAGS="" THREADFLAGS="" if false; then OS_MACOSX_TRUE= OS_MACOSX_FALSE='#' else OS_MACOSX_TRUE='#' OS_MACOSX_FALSE= fi case "$host_os" in solaris2.10) $as_echo "#define HAVE_IPV6 1" >>confdefs.h LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread -lrt $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; solaris2.8 | solaris2.9 ) $as_echo "#define NEED_POSIX_TYPEDEF /**/" >>confdefs.h $as_echo "#define NEED_INET_NTOP_PROTO /**/" >>confdefs.h $as_echo "#define HAVE_IPV6 1" >>confdefs.h LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; solaris2.6 | solaris2.7) $as_echo "#define NEED_POSIX_TYPEDEF /**/" >>confdefs.h $as_echo "#define NEED_INET_NTOP_PROTO /**/" >>confdefs.h LIBS="-lposix4 -lresolv -lnsl -lsocket -lpthread $LIBS" CXXFLAGS="-D_REENTRANT $CXXFLAGS" ;; linux*) $as_echo "#define HAVE_IPV6 1" >>confdefs.h DYNLINKFLAGS="-rdynamic" LDFLAGS="$LDFLAGS -lrt" THREADFLAGS="-pthread" CXXFLAGS="-D_GNU_SOURCE $CXXFLAGS" ;; darwin11* | darwin12*) $as_echo "#define HAVE_IPV6 1" >>confdefs.h DYNLINKFLAGS="-rdynamic" LDFLAGS="-pthread $LDFLAGS" CXXFLAGS="-pthread $CXXFLAGS -D__APPLE_USE_RFC_3542" if true; then OS_MACOSX_TRUE= OS_MACOSX_FALSE='#' else OS_MACOSX_TRUE='#' OS_MACOSX_FALSE= fi ;; *) $as_echo "#define HAVE_IPV6 1" >>confdefs.h DYNLINKFLAGS="-rdynamic" LDFLAGS="-pthread $LDFLAGS" CXXFLAGS="-pthread $CXXFLAGS" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be doing verbose logging" >&5 $as_echo_n "checking whether we will be doing verbose logging... " >&6; } # Check whether --enable-verbose-logging was given. if test "${enable_verbose_logging+set}" = set; then : enableval=$enable_verbose_logging; enable_verbose_logging=yes else enable_verbose_logging=no fi if test $enable_verbose_logging = yes; then $as_echo "#define VERBOSELOG 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_verbose_logging" >&5 $as_echo "$enable_verbose_logging" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will try to link in system PolarSSL" >&5 $as_echo_n "checking whether we will try to link in system PolarSSL... " >&6; } # Check whether --with-system-polarssl was given. if test "${with_system_polarssl+set}" = set; then : withval=$with_system_polarssl; system_polarssl=$withval else system_polarssl=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $system_polarssl" >&5 $as_echo "$system_polarssl" >&6; } if false; then HAVE_LIBPOLARSSL_TRUE= HAVE_LIBPOLARSSL_FALSE='#' else HAVE_LIBPOLARSSL_TRUE='#' HAVE_LIBPOLARSSL_FALSE= fi if test x$system_polarssl = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking PolarSSL version >= 1.1" >&5 $as_echo_n "checking PolarSSL version >= 1.1... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if POLARSSL_VERSION_NUMBER < 0x01010000 #error invalid version #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : use_system_polarssl=yes else use_system_polarssl=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_system_polarssl" >&5 $as_echo "$use_system_polarssl" >&6; } fi if test x$use_system_polarssl = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sha1_hmac in -lpolarssl" >&5 $as_echo_n "checking for sha1_hmac in -lpolarssl... " >&6; } if test "${ac_cv_lib_polarssl_sha1_hmac+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpolarssl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sha1_hmac (); int main () { return sha1_hmac (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_polarssl_sha1_hmac=yes else ac_cv_lib_polarssl_sha1_hmac=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_polarssl_sha1_hmac" >&5 $as_echo "$ac_cv_lib_polarssl_sha1_hmac" >&6; } if test "x$ac_cv_lib_polarssl_sha1_hmac" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPOLARSSL 1 _ACEOF LIBS="-lpolarssl $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be linking in Botan 1.10" >&5 $as_echo_n "checking whether we will be linking in Botan 1.10... " >&6; } # Check whether --enable-botan1.10 was given. if test "${enable_botan1_10+set}" = set; then : enableval=$enable_botan1_10; enable_botan110=yes else enable_botan110=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_botan110" >&5 $as_echo "$enable_botan110" >&6; } if test x"$enable_botan110" = "xyes"; then BOTAN110_TRUE= BOTAN110_FALSE='#' else BOTAN110_TRUE='#' BOTAN110_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be linking in Botan 1.8" >&5 $as_echo_n "checking whether we will be linking in Botan 1.8... " >&6; } # Check whether --enable-botan1.8 was given. if test "${enable_botan1_8+set}" = set; then : enableval=$enable_botan1_8; enable_botan18=yes else enable_botan18=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_botan18" >&5 $as_echo "$enable_botan18" >&6; } if test x"$enable_botan18" = "xyes"; then BOTAN18_TRUE= BOTAN18_FALSE='#' else BOTAN18_TRUE='#' BOTAN18_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be linking in Crypto++" >&5 $as_echo_n "checking whether we will be linking in Crypto++... " >&6; } # Check whether --enable-cryptopp was given. if test "${enable_cryptopp+set}" = set; then : enableval=$enable_cryptopp; enable_cryptopp=yes else enable_cryptopp=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cryptopp" >&5 $as_echo "$enable_cryptopp" >&6; } if test x"$enable_cryptopp" = "xyes"; then CRYPTOPP_TRUE= CRYPTOPP_FALSE='#' else CRYPTOPP_TRUE='#' CRYPTOPP_FALSE= fi if test "x$enable_botan110" = "xyes" then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BOTAN110" >&5 $as_echo_n "checking for BOTAN110... " >&6; } if test -n "$BOTAN110_CFLAGS"; then pkg_cv_BOTAN110_CFLAGS="$BOTAN110_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"botan-1.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "botan-1.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BOTAN110_CFLAGS=`$PKG_CONFIG --cflags "botan-1.10" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$BOTAN110_LIBS"; then pkg_cv_BOTAN110_LIBS="$BOTAN110_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"botan-1.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "botan-1.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BOTAN110_LIBS=`$PKG_CONFIG --libs "botan-1.10" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then BOTAN110_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "botan-1.10" 2>&1` else BOTAN110_PKG_ERRORS=`$PKG_CONFIG --print-errors "botan-1.10" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$BOTAN110_PKG_ERRORS" >&5 as_fn_error $? "Could not find botan 1.10" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Could not find botan 1.10" "$LINENO" 5 else BOTAN110_CFLAGS=$pkg_cv_BOTAN110_CFLAGS BOTAN110_LIBS=$pkg_cv_BOTAN110_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_BOTAN110=yes fi $as_echo "#define HAVE_BOTAN110 1" >>confdefs.h fi if test "x$enable_botan18" = "xyes" then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BOTAN18" >&5 $as_echo_n "checking for BOTAN18... " >&6; } if test -n "$BOTAN18_CFLAGS"; then pkg_cv_BOTAN18_CFLAGS="$BOTAN18_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"botan-1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "botan-1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BOTAN18_CFLAGS=`$PKG_CONFIG --cflags "botan-1.8" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$BOTAN18_LIBS"; then pkg_cv_BOTAN18_LIBS="$BOTAN18_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"botan-1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "botan-1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BOTAN18_LIBS=`$PKG_CONFIG --libs "botan-1.8" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then BOTAN18_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "botan-1.8" 2>&1` else BOTAN18_PKG_ERRORS=`$PKG_CONFIG --print-errors "botan-1.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$BOTAN18_PKG_ERRORS" >&5 as_fn_error $? "Could not find botan 1.8" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Could not find botan 1.8" "$LINENO" 5 else BOTAN18_CFLAGS=$pkg_cv_BOTAN18_CFLAGS BOTAN18_LIBS=$pkg_cv_BOTAN18_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_BOTAN18=yes fi $as_echo "#define HAVE_BOTAN18 1" >>confdefs.h fi # Check whether --enable-remotebackend_http was given. if test "${enable_remotebackend_http+set}" = set; then : enableval=$enable_remotebackend_http; enable_remotebackend_http=yes else enable_remotebackend_http=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable http connector in remotebackend" >&5 $as_echo_n "checking whether to enable http connector in remotebackend... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_remotebackend_http" >&5 $as_echo "$enable_remotebackend_http" >&6; } if test x"$enable_remotebackend_http" = "xyes"; then REMOTEBACKEND_HTTP_TRUE= REMOTEBACKEND_HTTP_FALSE='#' else REMOTEBACKEND_HTTP_TRUE='#' REMOTEBACKEND_HTTP_FALSE= fi if test "x$enable_remotebackend_http" = "xyes" then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBCURL" >&5 $as_echo_n "checking for LIBCURL... " >&6; } if test -n "$LIBCURL_CFLAGS"; then pkg_cv_LIBCURL_CFLAGS="$LIBCURL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcurl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBCURL_CFLAGS=`$PKG_CONFIG --cflags "libcurl" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBCURL_LIBS"; then pkg_cv_LIBCURL_LIBS="$LIBCURL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcurl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBCURL_LIBS=`$PKG_CONFIG --libs "libcurl" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBCURL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libcurl" 2>&1` else LIBCURL_PKG_ERRORS=`$PKG_CONFIG --print-errors "libcurl" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBCURL_PKG_ERRORS" >&5 as_fn_error $? "Could not find libcurl" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Could not find libcurl" "$LINENO" 5 else LIBCURL_CFLAGS=$pkg_cv_LIBCURL_CFLAGS LIBCURL_LIBS=$pkg_cv_LIBCURL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_LIBCURL=yes fi REMOTEBACKEND_HTTP=yes $as_echo "#define HAVE_LIBCURL 1" >>confdefs.h $as_echo "#define REMOTEBACKEND_HTTP 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we should build static binaries" >&5 $as_echo_n "checking whether we should build static binaries... " >&6; } # Check whether --enable-static-binaries was given. if test "${enable_static_binaries+set}" = set; then : enableval=$enable_static_binaries; case "${enableval}" in yes) static=true ;; no) static=false ;; *) as_fn_error $? "bad value ${enableval} for --enable-static-binaries" "$LINENO" 5 ;; esac else debug=false fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $static" >&5 $as_echo "$static" >&6; } if test x$static = xtrue; then ALLSTATIC_TRUE= ALLSTATIC_FALSE='#' else ALLSTATIC_TRUE='#' ALLSTATIC_FALSE= fi if test x$static = xtrue; then LDFLAGS="-all-static $LDFLAGS" fi modules="gmysql geo random" # Check whether --with-modules was given. if test "${with_modules+set}" = set; then : withval=$with_modules; modules="$withval" fi dynmodules="pipe" # Check whether --with-dynmodules was given. if test "${with_dynmodules+set}" = set; then : withval=$with_dynmodules; dynmodules="$withval" fi socketdir="/var/run" # Check whether --with-socketdir was given. if test "${with_socketdir+set}" = set; then : withval=$with_socketdir; socketdir="$withval" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be building the server" >&5 $as_echo_n "checking whether we will be building the server... " >&6; } # Check whether --enable-pdns-server was given. if test "${enable_pdns_server+set}" = set; then : enableval=$enable_pdns_server; enable_pdns_server=$enableval else enable_pdns_server=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_pdns_server" >&5 $as_echo "$enable_pdns_server" >&6; } if test x"$enable_pdns_server" = "xyes" then programdescend=pdns fi # Check whether --enable-gcc-skip-locking was given. if test "${enable_gcc_skip_locking+set}" = set; then : enableval=$enable_gcc_skip_locking; $as_echo "#define GCC_SKIP_LOCKING /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we will be building and installing the extra tools" >&5 $as_echo_n "checking whether we will be building and installing the extra tools... " >&6; } # Check whether --enable-tools was given. if test "${enable_tools+set}" = set; then : enableval=$enable_tools; enable_tools=$enableval else enable_tools=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_tools" >&5 $as_echo "$enable_tools" >&6; } if test x"$enable_tools" = "xyes"; then TOOLS_TRUE= TOOLS_FALSE='#' else TOOLS_TRUE='#' TOOLS_FALSE= fi for a in $modules $dynmodules do case "$a" in oracle|goracle) needoracle=yes ;; gmysql ) needmysql=yes ;; mydns ) needmysql=yes ;; gpgsql ) needpgsql=yes ;; gsqlite3 ) needsqlite3=yes ;; pdns ) needmysql=yes ;; ldap) for ac_header in ldap.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "ldap.h" "ac_cv_header_ldap_h" "$ac_includes_default" if test "x$ac_cv_header_ldap_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LDAP_H 1 _ACEOF else as_fn_error $? "ldap header (ldap.h) not found" "$LINENO" 5 fi done for ac_header in lber.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "lber.h" "ac_cv_header_lber_h" "$ac_includes_default" if test "x$ac_cv_header_lber_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LBER_H 1 _ACEOF else as_fn_error $? "ldap header (lber.h) not found" "$LINENO" 5 fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_set_option in -lldap_r" >&5 $as_echo_n "checking for ldap_set_option in -lldap_r... " >&6; } if test "${ac_cv_lib_ldap_r_ldap_set_option+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lldap_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ldap_set_option (); int main () { return ldap_set_option (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_ldap_r_ldap_set_option=yes else ac_cv_lib_ldap_r_ldap_set_option=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldap_r_ldap_set_option" >&5 $as_echo "$ac_cv_lib_ldap_r_ldap_set_option" >&6; } if test "x$ac_cv_lib_ldap_r_ldap_set_option" = x""yes; then : $as_echo "#define HAVE_LIBLDAP_R 1" >>confdefs.h LIBLDAP="ldap_r" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_set_option in -lldap" >&5 $as_echo_n "checking for ldap_set_option in -lldap... " >&6; } if test "${ac_cv_lib_ldap_ldap_set_option+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lldap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ldap_set_option (); int main () { return ldap_set_option (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_ldap_ldap_set_option=yes else ac_cv_lib_ldap_ldap_set_option=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldap_ldap_set_option" >&5 $as_echo "$ac_cv_lib_ldap_ldap_set_option" >&6; } if test "x$ac_cv_lib_ldap_ldap_set_option" = x""yes; then : $as_echo "#define HAVE_LIBLDAP 1" >>confdefs.h LIBLDAP="ldap" else as_fn_error $? "ldap library (libldap) not found" "$LINENO" 5 fi fi as_ac_Lib=`$as_echo "ac_cv_lib_$LIBLDAP''_ldap_initialize" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_initialize in -l$LIBLDAP" >&5 $as_echo_n "checking for ldap_initialize in -l$LIBLDAP... " >&6; } if eval "test \"\${$as_ac_Lib+set}\"" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$LIBLDAP $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ldap_initialize (); int main () { return ldap_initialize (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_LDAP_INITIALIZE 1" >>confdefs.h fi as_ac_Lib=`$as_echo "ac_cv_lib_$LIBLDAP''_ldap_sasl_bind" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldap_sasl_bind in -l$LIBLDAP" >&5 $as_echo_n "checking for ldap_sasl_bind in -l$LIBLDAP... " >&6; } if eval "test \"\${$as_ac_Lib+set}\"" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$LIBLDAP $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ldap_sasl_bind (); int main () { return ldap_sasl_bind (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_LDAP_SASL_BIND 1" >>confdefs.h fi ;; godbc ) needunixodbc=yes ;; opendbx) for ac_header in odbx.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "odbx.h" "ac_cv_header_odbx_h" "$ac_includes_default" if test "x$ac_cv_header_odbx_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ODBX_H 1 _ACEOF else as_fn_error $? "opendbx header (odbx.h) not found" "$LINENO" 5 fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for odbx_init in -lopendbx" >&5 $as_echo_n "checking for odbx_init in -lopendbx... " >&6; } if test "${ac_cv_lib_opendbx_odbx_init+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lopendbx $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char odbx_init (); int main () { return odbx_init (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_opendbx_odbx_init=yes else ac_cv_lib_opendbx_odbx_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opendbx_odbx_init" >&5 $as_echo "$ac_cv_lib_opendbx_odbx_init" >&6; } if test "x$ac_cv_lib_opendbx_odbx_init" = x""yes; then : $as_echo "#define HAVE_LIBOPENDBX 1" >>confdefs.h LIBOPENDBX="opendbx" fi ;; tinydns) needcdb=yes ;; esac done if test x"$needoracle" = "xyes"; then ORACLE_TRUE= ORACLE_FALSE='#' else ORACLE_TRUE='#' ORACLE_FALSE= fi if test "$needoracle" then # Check whether --with-oracle_includes was given. if test "${with_oracle_includes+set}" = set; then : withval=$with_oracle_includes; fi # Check whether --with-oracle_libs was given. if test "${with_oracle_libs+set}" = set; then : withval=$with_oracle_libs; fi if test x"$with_oracle_includes" = "x" then # check possible locations for p1 in /usr/include/oracle /usr/local/include/oracle do for p2 in $p1/*/client* do if test -d "$p2" then with_oracle_includes=$p2 fi done done fi if test x"$with_oracle_includes" = x && test "$ORACLE_HOME/rdbms/public" != "/rdbms/public"; then if test -d $ORACLE_HOME/rdbms/public; then with_oracle_includes=$ORACLE_HOME/rdbms/public fi fi # test header old_CXXFLAGS="$CXXFLAGS" old_CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS -I$with_oracle_includes" CPPFLAGS="$CPPFLAGS -I$with_oracle_includes" ac_fn_cxx_check_header_mongrel "$LINENO" "oci.h" "ac_cv_header_oci_h" "$ac_includes_default" if test "x$ac_cv_header_oci_h" = x""yes; then : ORACLE_CFLAGS="-I$with_oracle_includes" else as_fn_error $? "Could not find oci.h" "$LINENO" 5 fi CXXFLAGS="$old_CXXFLAGS" CPPFLAGS="$old_CPPFLAGS" if test x"$with_oracle_libs" = "x" then # check possible locationse for p1 in /usr/lib/oracle /usr/local/lib/oracle do for p2 in $p1/*/client*/lib do if test -d "$p2" then with_oracle_libs=$p2 fi done done fi if test x"$with_oracle_libs" = x && test "$ORACLE_HOME/lib" != "/lib"; then if test -d $ORACLE_HOME/lib; then with_oracle_libs=$ORACLE_HOME/lib fi fi # we have to check for client9 as well... # test -lclntsh old_LDFLAGS="$LDFLAGS" LDFLAGS="-L$with_oracle_libs -lnnz11 -locci" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCIEnvInit in -lclntsh" >&5 $as_echo_n "checking for OCIEnvInit in -lclntsh... " >&6; } if test "${ac_cv_lib_clntsh_OCIEnvInit+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lclntsh $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char OCIEnvInit (); int main () { return OCIEnvInit (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_clntsh_OCIEnvInit=yes else ac_cv_lib_clntsh_OCIEnvInit=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_clntsh_OCIEnvInit" >&5 $as_echo "$ac_cv_lib_clntsh_OCIEnvInit" >&6; } if test "x$ac_cv_lib_clntsh_OCIEnvInit" = x""yes; then : ORACLE_LIBS="-L$with_oracle_libs -lnnz11 -lclntsh -locci" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCIEnvInit in -lclient9" >&5 $as_echo_n "checking for OCIEnvInit in -lclient9... " >&6; } if test "${ac_cv_lib_client9_OCIEnvInit+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lclient9 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char OCIEnvInit (); int main () { return OCIEnvInit (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_client9_OCIEnvInit=yes else ac_cv_lib_client9_OCIEnvInit=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_client9_OCIEnvInit" >&5 $as_echo "$ac_cv_lib_client9_OCIEnvInit" >&6; } if test "x$ac_cv_lib_client9_OCIEnvInit" = x""yes; then : ORACLE_LIBS="-L$with_oracle_libs -lclient9 -lclntsh9" else as_fn_error $? "Could not find client libraries" "$LINENO" 5 fi fi LDFLAGS="$old_LDFLAGS" fi if test "$needmysql" then # Check whether --with-mysql was given. if test "${with_mysql+set}" = set; then : withval=$with_mysql; MYSQL_lib_check="$withval/lib/mysql $with_mysql/lib" MYSQL_inc_check="$withval/include/mysql" MYSQL_config_check="$withval/bin/mysql_config" else MYSQL_lib_check="/usr/local/mysql/lib/mysql /usr/local/lib/mysql /opt/mysql/lib/mysql \ /usr/lib/mysql /usr/lib64/mysql /usr/local/mysql/lib /usr/local/lib /opt/mysql/lib /usr/lib \ /usr/sfw/lib/ /usr/lib/x86_64-linux-gnu/" MYSQL_inc_check="/usr/local/mysql/include/mysql /usr/local/include/mysql \ /opt/mysql/include/mysql /opt/mysql/include /usr/include/mysql /usr/sfw/include/mysql" fi # Check whether --with-mysql-config was given. if test "${with_mysql_config+set}" = set; then : withval=$with_mysql_config; MYSQL_config_check=$withval fi # Check whether --with-mysql-lib was given. if test "${with_mysql_lib+set}" = set; then : withval=$with_mysql_lib; MYSQL_lib_check="$withval/lib/mysql $withval/mysql $withval" MYSQL_config_check="skip" fi # Check whether --with-mysql-includes was given. if test "${with_mysql_includes+set}" = set; then : withval=$with_mysql_includes; MYSQL_inc_check="$withval/include/mysql $withval/mysql $withval" MYSQL_config_check="skip" fi MYSQL_config="" if test "x$MYSQL_config_check" != "xskip"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_config" >&5 $as_echo_n "checking for mysql_config... " >&6; } if test "x$MYSQL_config_check" == "x"; then # check if it's in path for m in /bin /usr/bin /usr/local/bin /opt/csw/bin; do if test -x $m/mysql_config; then MYSQL_config=$m/mysql_config break fi done if test "x$MYSQL_config" == "x"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_config" >&5 $as_echo "$MYSQL_config" >&6; } fi else if test -x $MYSQL_config_check; then MYSQL_config="$MYSQL_config_check" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_config" >&5 $as_echo "$MYSQL_config" >&6; } else MYSQL_config="" as_fn_error $? "not found" "$LINENO" 5 fi fi fi if test "x$MYSQL_config" != "x"; then # use this to configure everything MYSQL_lib=`$MYSQL_config --libs` MYSQL_inc=`$MYSQL_config --include` else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MySQL library directory" >&5 $as_echo_n "checking for MySQL library directory... " >&6; } MYSQL_libdir= for m in $MYSQL_lib_check; do if test -d "$m" && \ (test -f "$m/libmysqlclient.so" || test -f "$m/libmysqlclient.a") then MYSQL_libdir=$m break fi done if test -z "$MYSQL_libdir"; then as_fn_error $? "Did not find the mysql library dir in '$MYSQL_lib_check'" "$LINENO" 5 fi case "$MYSQL_libdir" in /*) MYSQL_lib="-L$MYSQL_libdir -lmysqlclient" ;; *) as_fn_error $? "The MySQL library directory ($MYSQL_libdir) must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_libdir" >&5 $as_echo "$MYSQL_libdir" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MySQL include directory" >&5 $as_echo_n "checking for MySQL include directory... " >&6; } MYSQL_inc= for m in $MYSQL_inc_check; do if test -d "$m" && test -f "$m/mysql.h" then MYSQL_inc="$m" break fi done if test -z "$MYSQL_inc"; then as_fn_error $? "Did not find the mysql include dir in '$MYSQL_inc_check'" "$LINENO" 5 fi case "$MYSQL_inc" in /*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_inc" >&5 $as_echo "$MYSQL_inc" >&6; } ;; *) as_fn_error $? "The MySQL include directory ($MYSQL_inc) must be an absolute path." "$LINENO" 5 ;; esac MYSQL_inc="-I$MYSQL_inc" fi fi if test "$needpgsql" then # Check whether --with-pgsql was given. if test "${with_pgsql+set}" = set; then : withval=$with_pgsql; PGSQL_lib_check="$withval/lib/pgsql $with_pgsql/lib" PGSQL_inc_check="$withval/include/pgsql" else PGSQL_lib_check="/usr/local/pgsql/lib/pgsql /usr/local/lib/pgsql /opt/pgsql/lib/pgsql /usr/lib/pgsql /usr/local/pgsql/lib /usr/local/lib /opt/pgsql/lib /usr/lib /usr/lib64" PGSQL_inc_check="/usr/local/pgsql/include/pgsql /usr/include /usr/local/include/postgresql/ /usr/local/include /opt/pgsql/include/pgsql /opt/pgsql/include /usr/include/pgsql/ /usr/include/postgresql" fi # Check whether --with-pgsql-lib was given. if test "${with_pgsql_lib+set}" = set; then : withval=$with_pgsql_lib; PGSQL_lib_check="$withval/lib/pgsql $withval/pgsql $withval" fi # Check whether --with-pgsql-includes was given. if test "${with_pgsql_includes+set}" = set; then : withval=$with_pgsql_includes; PGSQL_inc_check="$withval/include/pgsql $withval/pgsql $withval" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PgSQL library directory" >&5 $as_echo_n "checking for PgSQL library directory... " >&6; } PGSQL_libdir= for m in $PGSQL_lib_check; do if test -d "$m" && \ (test -f "$m/libpq.a" || test -f "$m/libpq.so") then PGSQL_libdir=$m break fi done if test -z "$PGSQL_libdir"; then as_fn_error $? "Didn't find the pgsql library dir in '$PGSQL_lib_check'" "$LINENO" 5 fi case "$PGSQL_libdir" in /usr/lib ) PGSQL_lib="" ;; /usr/lib64 ) PGSQL_lib="" ;; /* ) PGSQL_lib="-L$PGSQL_libdir -Wl,-rpath,$PGSQL_libdir" LDFLAGS="$PGSQL_lib $LDFLAGS" ;; * ) as_fn_error $? "The PgSQL library directory ($PGSQL_libdir) must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_libdir" >&5 $as_echo "$PGSQL_libdir" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PgSQL include directory" >&5 $as_echo_n "checking for PgSQL include directory... " >&6; } PGSQL_incdir= for m in $PGSQL_inc_check; do if test -d "$m" && test -f "$m/libpq-fe.h" then PGSQL_incdir=$m break fi done if test -z "$PGSQL_incdir"; then as_fn_error $? "Didn't find the PgSQL include dir in '$PGSQL_inc_check'" "$LINENO" 5 fi case "$PGSQL_incdir" in /* ) ;; * ) as_fn_error $? "The PgSQL include directory ($PGSQL_incdir) must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_incdir" >&5 $as_echo "$PGSQL_incdir" >&6; } fi if test "$needsqlite3"; then SQLITE3_TRUE= SQLITE3_FALSE='#' else SQLITE3_TRUE='#' SQLITE3_FALSE= fi if test "$needsqlite3" then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLITE3" >&5 $as_echo_n "checking for SQLITE3... " >&6; } if test -n "$SQLITE3_CFLAGS"; then pkg_cv_SQLITE3_CFLAGS="$SQLITE3_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$SQLITE3PC\""; } >&5 ($PKG_CONFIG --exists --print-errors "$SQLITE3PC") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SQLITE3_CFLAGS=`$PKG_CONFIG --cflags "$SQLITE3PC" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$SQLITE3_LIBS"; then pkg_cv_SQLITE3_LIBS="$SQLITE3_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$SQLITE3PC\""; } >&5 ($PKG_CONFIG --exists --print-errors "$SQLITE3PC") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SQLITE3_LIBS=`$PKG_CONFIG --libs "$SQLITE3PC" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then SQLITE3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$SQLITE3PC" 2>&1` else SQLITE3_PKG_ERRORS=`$PKG_CONFIG --print-errors "$SQLITE3PC" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SQLITE3_PKG_ERRORS" >&5 as_fn_error $? "+Could not find sqlite3" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "+Could not find sqlite3" "$LINENO" 5 else SQLITE3_CFLAGS=$pkg_cv_SQLITE3_CFLAGS SQLITE3_LIBS=$pkg_cv_SQLITE3_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_SQLITE3=yes fi $as_echo "#define HAVE_SQLITE3 1" >>confdefs.h fi if test "$needcdb" then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CDB" >&5 $as_echo_n "checking for CDB... " >&6; } if test -n "$CDB_CFLAGS"; then pkg_cv_CDB_CFLAGS="$CDB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcdb\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcdb") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CDB_CFLAGS=`$PKG_CONFIG --cflags "libcdb" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$CDB_LIBS"; then pkg_cv_CDB_LIBS="$CDB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcdb\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcdb") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CDB_LIBS=`$PKG_CONFIG --libs "libcdb" 2>/dev/null` else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then CDB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libcdb" 2>&1` else CDB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libcdb" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$CDB_PKG_ERRORS" >&5 as_fn_error $? "+Could not find libcdb/tinycdb" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "+Could not find libcdb/tinycdb" "$LINENO" 5 else CDB_CFLAGS=$pkg_cv_CDB_CFLAGS CDB_LIBS=$pkg_cv_CDB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_CDB=yes fi fi if test "$needunixodbc" then # Check whether --with-unixodbc was given. if test "${with_unixodbc+set}" = set; then : withval=$with_unixodbc; UNIXODBC_lib_check="$withval/lib/unixodbc $with_unixodbc/lib $withval/lib" UNIXODBC_inc_check="$withval/include/unixodbc" else UNIXODBC_lib_check="/usr/local/unixodbc/lib/unixodbc /usr/local/lib/unixodbc /usr/lib/unixodbc /usr/local/unixodbc/lib /usr/local/lib /opt/unixodbc/lib /usr/lib" UNIXODBC_inc_check="/usr/local/unixodbc/include/unixodbc /usr/local/include/unixodbc/ /usr/local/include /opt/unixodbc/include/unixodbc /opt/unixodbc/include /usr/include/ /usr/include/unixodbc" fi # Check whether --with-unixodbc-lib was given. if test "${with_unixodbc_lib+set}" = set; then : withval=$with_unixodbc_lib; UNIXODBC_lib_check="$withval/lib/unixodbc $withval/unixodbc $withval" fi # Check whether --with-unixodbc-includes was given. if test "${with_unixodbc_includes+set}" = set; then : withval=$with_unixodbc_includes; UNIXODBC_inc_check="$withval/include $withval/include/unixodbc $withval/unixodbc $withval" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unixodbc library directory" >&5 $as_echo_n "checking for unixodbc library directory... " >&6; } UNIXODBC_libdir= for m in $UNIXODBC_lib_check; do if test -d "$m" && \ (test -f "$m/libodbc.so" || test -f "$m/libodbc.a") then UNIXODBC_libdir=$m break fi done if test -z "$UNIXODBC_libdir"; then as_fn_error $? "Didn't find the unixodbc library dir in '$UNIXODBC_lib_check'" "$LINENO" 5 fi case "$UNIXODBC_libdir" in /usr/lib ) UNIXODBC_lib="" ;; /* ) UNIXODBC_lib="-L$UNIXODBC_libdir -Wl,-rpath,$UNIXODBC_libdir" LDFLAGS="$UNIXODBC_lib $LDFLAGS" ;; * ) as_fn_error $? "The unixodbc library directory ($UNIXODBC_libdir) must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNIXODBC_libdir" >&5 $as_echo "$UNIXODBC_libdir" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unixodbc include directory" >&5 $as_echo_n "checking for unixodbc include directory... " >&6; } UNIXODBC_incdir= for m in $UNIXODBC_inc_check; do if test -d "$m" && test -f "$m/sql.h" then UNIXODBC_incdir=$m break fi done if test -z "$UNIXODBC_incdir"; then as_fn_error $? "Didn't find the unixodbc include dir in '$UNIXODBC_inc_check'" "$LINENO" 5 fi case "$UNIXODBC_incdir" in /* ) ;; * ) as_fn_error $? "The unixodbc include directory ($UNIXODBC_incdir) must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNIXODBC_incdir" >&5 $as_echo "$UNIXODBC_incdir" >&6; } # LIBS="$LIBS -lunixodbc" fi for a in $modules do moduledirs="$moduledirs ${a}backend" for b in `cat $srcdir/modules/${a}backend/OBJECTFILES` do moduleobjects="$moduleobjects ../modules/${a}backend/$b" done modulelibs="$modulelibs `cat $srcdir/modules/${a}backend/OBJECTLIBS`" if test ${a} = "gpgsql"; then LIBS="$LIBS $LIBCRYPT" case "$host_os" in freebsd*) ;; darwin*) modulelibs="$modulelibs -lresolv" ;; *) modulelibs="$modulelibs -lresolv -lnsl" ;; esac fi done for a in $dynmodules do moduledirs="$moduledirs ${a}backend" done export moduledirs moduleobjects modulelibs ac_config_files="$ac_config_files Makefile modules/Makefile pdns/Makefile codedocs/Makefile pdns/backends/Makefile pdns/backends/bind/Makefile pdns/pdns pdns/precursor modules/gmysqlbackend/Makefile modules/db2backend/Makefile modules/geobackend/Makefile modules/opendbxbackend/Makefile modules/pipebackend/Makefile modules/oraclebackend/Makefile modules/xdbbackend/Makefile modules/godbcbackend/Makefile modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile modules/gsqlite3backend/Makefile modules/goraclebackend/Makefile modules/mydnsbackend/Makefile modules/luabackend/Makefile modules/tinydnsbackend/Makefile modules/remotebackend/Makefile modules/randombackend/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${RELEASE_BUILD_TRUE}" && test -z "${RELEASE_BUILD_FALSE}"; then as_fn_error $? "conditional \"RELEASE_BUILD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${OS_MACOSX_TRUE}" && test -z "${OS_MACOSX_FALSE}"; then as_fn_error $? "conditional \"OS_MACOSX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${OS_MACOSX_TRUE}" && test -z "${OS_MACOSX_FALSE}"; then as_fn_error $? "conditional \"OS_MACOSX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBPOLARSSL_TRUE}" && test -z "${HAVE_LIBPOLARSSL_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBPOLARSSL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BOTAN110_TRUE}" && test -z "${BOTAN110_FALSE}"; then as_fn_error $? "conditional \"BOTAN110\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BOTAN18_TRUE}" && test -z "${BOTAN18_FALSE}"; then as_fn_error $? "conditional \"BOTAN18\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CRYPTOPP_TRUE}" && test -z "${CRYPTOPP_FALSE}"; then as_fn_error $? "conditional \"CRYPTOPP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${REMOTEBACKEND_HTTP_TRUE}" && test -z "${REMOTEBACKEND_HTTP_FALSE}"; then as_fn_error $? "conditional \"REMOTEBACKEND_HTTP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ALLSTATIC_TRUE}" && test -z "${ALLSTATIC_FALSE}"; then as_fn_error $? "conditional \"ALLSTATIC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TOOLS_TRUE}" && test -z "${TOOLS_FALSE}"; then as_fn_error $? "conditional \"TOOLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ORACLE_TRUE}" && test -z "${ORACLE_FALSE}"; then as_fn_error $? "conditional \"ORACLE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${SQLITE3_TRUE}" && test -z "${SQLITE3_FALSE}"; then as_fn_error $? "conditional \"SQLITE3\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by pdns $as_me 3.3, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ pdns config.status 3.3 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`' predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`' postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`' predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`' postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`' LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`' fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ AR \ AR_FLAGS \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ SHELL \ ECHO \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_wl \ lt_prog_compiler_pic \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_flag_spec_ld_CXX \ hardcode_libdir_separator_CXX \ fix_srcfile_path_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX; do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` ;; esac ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "modules/Makefile") CONFIG_FILES="$CONFIG_FILES modules/Makefile" ;; "pdns/Makefile") CONFIG_FILES="$CONFIG_FILES pdns/Makefile" ;; "codedocs/Makefile") CONFIG_FILES="$CONFIG_FILES codedocs/Makefile" ;; "pdns/backends/Makefile") CONFIG_FILES="$CONFIG_FILES pdns/backends/Makefile" ;; "pdns/backends/bind/Makefile") CONFIG_FILES="$CONFIG_FILES pdns/backends/bind/Makefile" ;; "pdns/pdns") CONFIG_FILES="$CONFIG_FILES pdns/pdns" ;; "pdns/precursor") CONFIG_FILES="$CONFIG_FILES pdns/precursor" ;; "modules/gmysqlbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/gmysqlbackend/Makefile" ;; "modules/db2backend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/db2backend/Makefile" ;; "modules/geobackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/geobackend/Makefile" ;; "modules/opendbxbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/opendbxbackend/Makefile" ;; "modules/pipebackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/pipebackend/Makefile" ;; "modules/oraclebackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/oraclebackend/Makefile" ;; "modules/xdbbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/xdbbackend/Makefile" ;; "modules/godbcbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/godbcbackend/Makefile" ;; "modules/gpgsqlbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/gpgsqlbackend/Makefile" ;; "modules/ldapbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/ldapbackend/Makefile" ;; "modules/gsqlite3backend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/gsqlite3backend/Makefile" ;; "modules/goraclebackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/goraclebackend/Makefile" ;; "modules/mydnsbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/mydnsbackend/Makefile" ;; "modules/luabackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/luabackend/Makefile" ;; "modules/tinydnsbackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/tinydnsbackend/Makefile" ;; "modules/remotebackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/remotebackend/Makefile" ;; "modules/randombackend/Makefile") CONFIG_FILES="$CONFIG_FILES modules/randombackend/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="CXX " # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == "file_magic". file_magic_cmd=$lt_file_magic_cmd # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name of the directory that contains temporary libtool files. objdir=$objdir # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that does not interpret backslashes. ECHO=$lt_ECHO # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $* )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[^=]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$@"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1+=\$2" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$1=\$$1\$2" } _LT_EOF ;; esac sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path=$lt_fix_srcfile_path_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi pdns-3.3/install-sh0000755000014601777760000003253712165464024015605 0ustar00jenkinsnogroup00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: pdns-3.3/missing0000755000014601777760000002623312165464024015174 0ustar00jenkinsnogroup00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: